annotate src/win32.c @ 611:38db05db9cb5

[xemacs-hg @ 2001-06-08 12:21:09 by ben] ------ gc-in-window-procedure fixes ------ alloc.c: Create "post-gc actions", to avoid those dreaded "GC during window procedure" problems. event-msw.c: Abort, clean and simple, when GC in window procedure. We want to flush these puppies out. glyphs-msw.c: Use a post-gc action when destroying subwindows. lisp.h: Declare register_post_gc_action(). scrollbar-msw.c: Use a post-gc action when unshowing scrollbar windows, if in gc. redisplay.c: Add comment about the utter evilness of what's going down here. ------ cygwin setitimer fixes ------ Makefile.in.in: Compile profile.c only when HAVE_SETITIMER. nt.c: Style fixes. nt.c: Move setitimer() emulation to win32.c, because Cygwin needs it too. profile.c: Make sure we don't compile if no setitimer(). Use qxe_setitimer() instead of just plain setitimer(). signal.c: Define qxe_setitimer() as an encapsulation around setitimer() -- call setitimer() directly unless Cygwin or MS Win, in which case we use our simulated version in win32.c. systime.h: Prototype mswindows_setitimer() and qxe_setitimer(). Long comment about "qxe" and the policy regarding encapsulation. win32.c: Move setitimer() emulation here, so Cygwin can use it. Rename a couple of functions and variables to be longer and more descriptive. In setitimer_helper_proc(), send the signal using either mswindows_raise() or (on Cygwin) kill(). If for some reason we are still getting lockups, we'll change the kill() to directly invoke the signal handlers. ------ windows shell fixes ------ callproc.c, ntproc.c: Comments about how these two files must die. callproc.c: On MS Windows, init shell-file-name from SHELL, then COMSPEC, not just COMSPEC. (more correct and closer to FSF.) Don't force a value for SHELL into the environment. (Comments added to explain why not.) nt.c: Don't shove a fabricated SHELL into the environment. See above. ------ misc fixes ------ glyphs-shared.c: Style correction. xemacs-faq.texi: Merge in the rest of Hrvoje's Windows FAQ. Redo section 7 to update current reality and add condensed versions of new changes for 21.1 and 21.4. (Not quite done for 21.4.) Lots more Windows updates. process.el: Need to quote a null argument, too. From Dan Holmsand. startup.el: startup.el: Call MS Windows init function. win32-native.el: Correct comments at top. Correctly handle passing arguments to Cygwin programs and to bash. Fix quoting of zero-length arguments (from Dan Holmsand). Set shell-command-switch based on shell-file-name, which in turn comes from env var SHELL.
author ben
date Fri, 08 Jun 2001 12:21:27 +0000
parents 5fd7ba8b56e7
children 023b83f4e54b
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"
611
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
25
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
26 #include "syssignal.h"
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
27 #include "systime.h"
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
28 #include "syswindows.h"
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 BOOL (WINAPI *pfSwitchToThread_t) (VOID);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
31 pfSwitchToThread_t xSwitchToThread;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
32
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
33 typedef HKL (WINAPI *pfGetKeyboardLayout_t) (DWORD);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
34 pfGetKeyboardLayout_t xGetKeyboardLayout;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
35 typedef BOOL (WINAPI *pfSetMenuDefaultItem_t) (HMENU, UINT, UINT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
36 pfSetMenuDefaultItem_t xSetMenuDefaultItem;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
37 typedef BOOL (WINAPI *pfInsertMenuItemA_t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
38 (HMENU, UINT, BOOL, LPCMENUITEMINFOA);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
39 pfInsertMenuItemA_t xInsertMenuItemA;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
40 typedef BOOL (WINAPI *pfInsertMenuItemW_t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
41 (HMENU, UINT, BOOL, LPCMENUITEMINFOW);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
42 pfInsertMenuItemW_t xInsertMenuItemW;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
43 typedef HANDLE (WINAPI *pfLoadImageA_t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
44 (HINSTANCE, LPCSTR, UINT, int, int, UINT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
45 pfLoadImageA_t xLoadImageA;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
46 typedef HANDLE (WINAPI *pfLoadImageW_t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
47 (HINSTANCE, LPCWSTR, UINT, int, int, UINT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
48 pfLoadImageW_t xLoadImageW;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
49 typedef ATOM (WINAPI *pfRegisterClassExA_t) (CONST WNDCLASSEXA *);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
50 pfRegisterClassExA_t xRegisterClassExA;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
51 typedef ATOM (WINAPI *pfRegisterClassExW_t) (CONST WNDCLASSEXW *);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
52 pfRegisterClassExW_t xRegisterClassExW;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
53
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
54 typedef int (WINAPI *pfEnumFontFamiliesExA_t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
55 (HDC, LPLOGFONTA, FONTENUMPROCA, LPARAM, DWORD);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
56 pfEnumFontFamiliesExA_t xEnumFontFamiliesExA;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
57 typedef int (WINAPI *pfEnumFontFamiliesExW_t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
58 (HDC, LPLOGFONTW, FONTENUMPROCW, LPARAM, DWORD);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
59 pfEnumFontFamiliesExW_t xEnumFontFamiliesExW;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
60
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
61 typedef DWORD (WINAPI *pfSHGetFileInfoA_t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
62 (LPCSTR, DWORD, SHFILEINFOA FAR *, UINT, UINT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
63 pfSHGetFileInfoA_t xSHGetFileInfoA;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
64 typedef DWORD (WINAPI *pfSHGetFileInfoW_t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
65 (LPCWSTR, DWORD, SHFILEINFOW FAR *, UINT, UINT);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
66 pfSHGetFileInfoW_t xSHGetFileInfoW;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
67
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
68 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
69 (
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
70 IN LPCWSTR servername OPTIONAL,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
71 IN DWORD level,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
72 IN DWORD filter,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
73 OUT LPBYTE *bufptr,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
74 IN DWORD prefmaxlen,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
75 OUT LPDWORD entriesread,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
76 OUT LPDWORD totalentries,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
77 IN OUT LPDWORD resume_handle OPTIONAL
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
78 );
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
79 pfNetUserEnum_t xNetUserEnum;
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
80
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
81 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
82 (
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
83 IN LPVOID Buffer
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
84 );
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
85 pfNetApiBufferFree_t xNetApiBufferFree;
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
86
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
87 Lisp_Object
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
88 tstr_to_local_file_format (Extbyte *pathout)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
89 {
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 576
diff changeset
90 Bufbyte *ttlff;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
91 Lisp_Object 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 EXTERNAL_TO_C_STRING (pathout, ttlff, Qmswindows_tstr);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
94 WIN32_TO_LOCAL_FILE_FORMAT (ttlff, in);
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 return in;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
97 }
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 static void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
100 init_potentially_nonexistent_functions (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
101 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
102 HMODULE h_kernel = GetModuleHandle ("kernel32");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
103 HMODULE h_user = GetModuleHandle ("user32");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
104 HMODULE h_gdi = GetModuleHandle ("gdi32");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
105 HMODULE h_shell = GetModuleHandle ("shell32");
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
106 /* 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
107 HMODULE h_netapi = LoadLibrary ("netapi32.dll");
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
108
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
109 if (h_kernel)
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 xSwitchToThread =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
112 (pfSwitchToThread_t) GetProcAddress (h_kernel, "SwitchToThread");
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
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
115 if (h_user)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
116 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
117 xGetKeyboardLayout =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
118 (pfGetKeyboardLayout_t) GetProcAddress (h_user, "GetKeyboardLayout");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
119 xSetMenuDefaultItem =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
120 (pfSetMenuDefaultItem_t) GetProcAddress (h_user, "SetMenuDefaultItem");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
121 xInsertMenuItemA =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
122 (pfInsertMenuItemA_t) GetProcAddress (h_user, "InsertMenuItemA");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
123 xInsertMenuItemW =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
124 (pfInsertMenuItemW_t) GetProcAddress (h_user, "InsertMenuItemW");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
125 xLoadImageA =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
126 (pfLoadImageA_t) GetProcAddress (h_user, "LoadImageA");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
127 xLoadImageW =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
128 (pfLoadImageW_t) GetProcAddress (h_user, "LoadImageW");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
129 xRegisterClassExA =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
130 (pfRegisterClassExA_t) GetProcAddress (h_user, "RegisterClassExA");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
131 xRegisterClassExW =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
132 (pfRegisterClassExW_t) GetProcAddress (h_user, "RegisterClassExW");
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
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
135 if (h_gdi)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
136 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
137 xEnumFontFamiliesExA =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
138 (pfEnumFontFamiliesExA_t) GetProcAddress (h_gdi, "EnumFontFamiliesExA");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
139 xEnumFontFamiliesExW =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
140 (pfEnumFontFamiliesExW_t) GetProcAddress (h_gdi, "EnumFontFamiliesExW");
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
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
143 if (h_shell)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
144 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
145 xSHGetFileInfoA =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
146 (pfSHGetFileInfoA_t) GetProcAddress (h_shell, "SHGetFileInfoA");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
147 xSHGetFileInfoW =
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
148 (pfSHGetFileInfoW_t) GetProcAddress (h_shell, "SHGetFileInfoW");
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
149 }
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
150
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
151 if (h_netapi)
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
152 {
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
153 xNetUserEnum =
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
154 (pfNetUserEnum_t) GetProcAddress (h_netapi, "NetUserEnum");
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
155 xNetApiBufferFree =
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
156 (pfNetApiBufferFree_t) GetProcAddress (h_netapi, "NetApiBufferFree");
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 442
diff changeset
157 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
158 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
159
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
160 DEFUN ("mswindows-shell-execute", Fmswindows_shell_execute, 2, 4, 0, /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
161 Get Windows to perform OPERATION on DOCUMENT.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
162 This is a wrapper around the ShellExecute system function, which
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
163 invokes the application registered to handle OPERATION for DOCUMENT.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
164 OPERATION is typically \"open\", \"print\" or \"explore\" (but can be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
165 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
166 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
167 a directory to open in the Windows Explorer.
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 If DOCUMENT is a program executable, PARAMETERS can be a string
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
170 containing command line parameters, but otherwise should be nil.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
171
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
172 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
173 or minimized. If SHOW-FLAG is nil, the application is displayed normally,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
174 otherwise it is an integer representing a ShowWindow flag:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
175
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
176 0 - start hidden
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
177 1 - start normally
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
178 3 - start maximized
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
179 6 - start minimized
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
180 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
181 (operation, document, parameters, show_flag))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
182 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
183 /* Encode filename and current directory. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
184 Lisp_Object current_dir = Ffile_name_directory (document);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
185 char* path = NULL;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
186 char* doc = NULL;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
187 Extbyte* f=0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
188 int ret;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
189 struct gcpro gcpro1, gcpro2;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
190
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
191 CHECK_STRING (document);
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 if (NILP (current_dir))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
194 current_dir = current_buffer->directory;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
195
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
196 GCPRO2 (current_dir, document);
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 /* Use mule and cygwin-safe APIs top get at file data. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
199 if (STRINGP (current_dir))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
200 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
201 TO_EXTERNAL_FORMAT (LISP_STRING, current_dir,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
202 C_STRING_ALLOCA, f,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
203 Qfile_name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
204 #ifdef CYGWIN
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
205 CYGWIN_WIN32_PATH (f, path);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
206 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
207 path = f;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
208 #endif
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
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
211 if (STRINGP (document))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
212 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
213 TO_EXTERNAL_FORMAT (LISP_STRING, document,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
214 C_STRING_ALLOCA, f,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
215 Qfile_name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
216 #ifdef CYGWIN
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
217 CYGWIN_WIN32_PATH (f, doc);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
218 #else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
219 doc = f;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
220 #endif
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
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
223 UNGCPRO;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
224
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
225 ret = (int) ShellExecute (NULL,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
226 (STRINGP (operation) ?
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 578
diff changeset
227 /* !!#### more mule bogosity */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 578
diff changeset
228 (char *) XSTRING_DATA (operation) : NULL),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
229 doc,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
230 (STRINGP (parameters) ?
593
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 578
diff changeset
231 /* !!#### more mule bogosity */
5fd7ba8b56e7 [xemacs-hg @ 2001-05-31 12:45:27 by ben]
ben
parents: 578
diff changeset
232 (char *) XSTRING_DATA (parameters) : NULL),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
233 path,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
234 (INTP (show_flag) ?
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
235 XINT (show_flag) : SW_SHOWDEFAULT));
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
236
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
237 if (ret > 32)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
238 return Qt;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
239
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
240 if (ret == ERROR_FILE_NOT_FOUND)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 531
diff changeset
241 signal_error (Qfile_error, "file not found", document);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
242 else if (ret == ERROR_PATH_NOT_FOUND)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 531
diff changeset
243 signal_error (Qfile_error, "path not found", current_dir);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
244 else if (ret == ERROR_BAD_FORMAT)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 531
diff changeset
245 signal_error (Qfile_error, "bad executable format", document);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
246 else
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 531
diff changeset
247 signal_error (Qinternal_error, "internal error", Qunbound);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
248
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
249 return Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
250 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
251
611
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
252
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
253 /*--------------------------------------------------------------------*/
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
254 /* Async timers */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
255 /*--------------------------------------------------------------------*/
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
256
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
257 /* setitimer() does not exist on native MS Windows, and appears broken
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
258 on Cygwin (random lockups when BROKEN_SIGIO is defined), so we
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
259 emulate in both cases by using multimedia timers. */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
260
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
261 /* We emulate two timers, one for SIGALRM, another for SIGPROF.
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
262
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
263 itimerproc() function has an implementation limitation: it does
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
264 not allow to set *both* interval and period. If an attempt is
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
265 made to set both, and then they are unequal, the function
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
266 asserts.
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
267
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
268 Minimum timer resolution on Win32 systems varies, and is greater
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
269 than or equal than 1 ms. The resolution is always wrapped not to
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
270 attempt to get below the system defined limit.
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
271 */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
272
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
273 /* Timer precision, denominator of one fraction: for 100 ms
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
274 interval, request 10 ms precision
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
275 */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
276 const int setitimer_helper_timer_prec = 10;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
277
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
278 /* Last itimervals, as set by calls to setitimer */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
279 static struct itimerval it_alarm;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
280 static struct itimerval it_prof;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
281
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
282 /* Timer IDs as returned by MM */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
283 MMRESULT tid_alarm = 0;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
284 MMRESULT tid_prof = 0;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
285
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
286 static void CALLBACK
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
287 setitimer_helper_proc (UINT uID, UINT uMsg, DWORD dwUser,
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
288 DWORD dw1, DWORD dw2)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
289 {
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
290 /* Just raise the signal indicated by the dwUser parameter */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
291 #ifdef CYGWIN
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
292 kill (getpid (), dwUser);
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
293 #else
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
294 mswindows_raise (dwUser);
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
295 #endif
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
296 }
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
297
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
298 /* Divide time in ms specified by IT by DENOM. Return 1 ms
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
299 if division results in zero */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
300 static UINT
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
301 setitimer_helper_period (const struct itimerval* it, UINT denom)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
302 {
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
303 static TIMECAPS time_caps;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
304
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
305 UINT res;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
306 const struct timeval* tv =
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
307 (it->it_value.tv_sec == 0 && it->it_value.tv_usec == 0)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
308 ? &it->it_interval : &it->it_value;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
309
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
310 /* Zero means stop timer */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
311 if (tv->tv_sec == 0 && tv->tv_usec == 0)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
312 return 0;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
313
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
314 /* Convert to ms and divide by denom */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
315 res = (tv->tv_sec * 1000 + (tv->tv_usec + 500) / 1000) / denom;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
316
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
317 /* Converge to minimum timer resolution */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
318 if (time_caps.wPeriodMin == 0)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
319 timeGetDevCaps (&time_caps, sizeof(time_caps));
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
320
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
321 if (res < time_caps.wPeriodMin)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
322 res = time_caps.wPeriodMin;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
323
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
324 return res;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
325 }
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
326
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
327 static int
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
328 setitimer_helper (const struct itimerval* itnew,
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
329 struct itimerval* itold, struct itimerval* itcurrent,
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
330 MMRESULT* tid, DWORD sigkind)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
331 {
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
332 UINT delay, resolution, event_type;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
333
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
334 /* First stop the old timer */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
335 if (*tid)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
336 {
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
337 timeKillEvent (*tid);
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
338 timeEndPeriod (setitimer_helper_period (itcurrent,
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
339 setitimer_helper_timer_prec));
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
340 *tid = 0;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
341 }
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
342
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
343 /* Return old itimerval if requested */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
344 if (itold)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
345 *itold = *itcurrent;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
346
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
347 *itcurrent = *itnew;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
348
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
349 /* Determine if to start new timer */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
350 delay = setitimer_helper_period (itnew, 1);
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
351 if (delay)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
352 {
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
353 resolution = setitimer_helper_period (itnew,
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
354 setitimer_helper_timer_prec);
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
355 event_type = (itnew->it_value.tv_sec == 0 &&
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
356 itnew->it_value.tv_usec == 0)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
357 ? TIME_ONESHOT : TIME_PERIODIC;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
358 timeBeginPeriod (resolution);
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
359 *tid = timeSetEvent (delay, resolution, setitimer_helper_proc, sigkind,
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
360 event_type);
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
361 }
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
362
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
363 return !delay || *tid;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
364 }
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
365
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
366 int
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
367 mswindows_setitimer (int kind, const struct itimerval *itnew,
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
368 struct itimerval *itold)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
369 {
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
370 /* In this version, both interval and value are allowed
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
371 only if they are equal. */
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
372 assert ((itnew->it_value.tv_sec == 0 && itnew->it_value.tv_usec == 0)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
373 || (itnew->it_interval.tv_sec == 0 &&
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
374 itnew->it_interval.tv_usec == 0)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
375 || (itnew->it_value.tv_sec == itnew->it_interval.tv_sec &&
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
376 itnew->it_value.tv_usec == itnew->it_interval.tv_usec));
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
377
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
378 if (kind == ITIMER_REAL)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
379 return setitimer_helper (itnew, itold, &it_alarm, &tid_alarm, SIGALRM);
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
380 else if (kind == ITIMER_PROF)
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
381 return setitimer_helper (itnew, itold, &it_prof, &tid_prof, SIGPROF);
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
382 else
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
383 return errno = EINVAL;
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
384 }
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
385
38db05db9cb5 [xemacs-hg @ 2001-06-08 12:21:09 by ben]
ben
parents: 593
diff changeset
386
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
387 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
388 syms_of_win32 (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
389 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
390 DEFSUBR (Fmswindows_shell_execute);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
391 }
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
392
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
393 void
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
394 init_win32 (void)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
395 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
396 init_potentially_nonexistent_functions ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents:
diff changeset
397 }