annotate src/nt.h @ 682:e558c78d22f8

[xemacs-hg @ 2001-12-02 15:27:37 by youngs] 2001-12-03 Steve Youngs <youngs@xemacs.org> * package-get.el (package-get-update-base-from-buffer): Add autoload for 'mc-verify'.
author youngs
date Sun, 02 Dec 2001 15:27:38 +0000
parents c9c1c4ce8f0f
children 943eaba38521
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Support routines for the NT version of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1994 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 /* Adapted for XEmacs by David Hobley <david@spook-le0.cia.com.au> */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 /* Sync'ed with Emacs 19.34.6 by Marc Paquette <marcpa@cam.org> */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 /* #define FULL_DEBUG */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
26 #ifndef INCLUDED_nt_h_
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
27 #define INCLUDED_nt_h_
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
28
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
29 #include "syswindows.h"
606
c9c1c4ce8f0f [xemacs-hg @ 2001-06-02 06:55:26 by ben]
ben
parents: 592
diff changeset
30 #include "systime.h" /* because of struct utimbuf below */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
31
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #ifdef DEBUG_XEMACS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #define DebPrint(stuff) _DebPrint stuff
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #define DebPrint(stuff)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 /* ------------------------------------------------------------------------- */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 /* child_process.status values */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 enum {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 STATUS_READ_ERROR = -1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 STATUS_READ_READY,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 STATUS_READ_IN_PROGRESS,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 STATUS_READ_FAILED,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 STATUS_READ_SUCCEEDED,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 STATUS_READ_ACKNOWLEDGED
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 /* This structure is used for both pipes and sockets; for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 a socket, the process handle in pi is NULL. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 typedef struct _child_process
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 int fd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 int pid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 HANDLE char_avail;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 HANDLE char_consumed;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 HANDLE thrd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 HWND hwnd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 PROCESS_INFORMATION procinfo;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 volatile int status;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 char chr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 } child_process;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 #define MAX_CHILDREN MAXDESC/2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 #define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 /* parallel array of private info on file handles */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 unsigned flags;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 HANDLE hnd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 child_process * cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 } filedesc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
76 extern filedesc fd_info [];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 /* fd_info flag definitions */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 #define FILE_READ 0x0001
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 #define FILE_WRITE 0x0002
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 #define FILE_BINARY 0x0010
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 #define FILE_LAST_CR 0x0020
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 #define FILE_AT_EOF 0x0040
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 #define FILE_SEND_SIGCHLD 0x0080
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 #define FILE_PIPE 0x0100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 #define FILE_SOCKET 0x0200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 extern child_process * new_child (void);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 extern void delete_child (child_process *cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 /* ------------------------------------------------------------------------- */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 /* Get long (aka "true") form of file name, if it exists. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 extern BOOL win32_get_long_filename (char * name, char * buf, int size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 /* Prepare our standard handles for proper inheritance by child processes. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 extern void prepare_standard_handles (int in, int out,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 int err, HANDLE handles[4]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 /* Reset our standard handles to their original state. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 extern void reset_standard_handles (int in, int out,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 int err, HANDLE handles[4]);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 /* Return the string resource associated with KEY of type TYPE. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 extern LPBYTE nt_get_resource (char * key, LPDWORD type);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 void set_process_dir (const char * dir);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 time_t convert_time (FILETIME ft);
592
4f6ba8f1fb3d [xemacs-hg @ 2001-05-31 12:03:37 by adrian]
adrian
parents: 442
diff changeset
109 int mswindows_utime (Lisp_Object path, struct utimbuf *times);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
111 extern void init_ntproc (void);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
112 extern void term_ntproc (int unused);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
113
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
114 /* ----------------------------------------------------------------- */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
115 /* Useful routines for manipulating memory-mapped files. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
116
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
117 typedef struct file_data
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
118 {
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
119 const char *name;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
120 unsigned long size;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
121 HANDLE file;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
122 HANDLE file_mapping;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
123 char *file_base;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
124 } file_data;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
125
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
126 #define OFFSET_TO_RVA(var,section) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
127 (section->VirtualAddress + ((DWORD)(var) - section->PointerToRawData))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
128
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
129 #define RVA_TO_OFFSET(var,section) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
130 (section->PointerToRawData + ((DWORD)(var) - section->VirtualAddress))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
131
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
132 #define RVA_TO_PTR(var,section,filedata) \
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
133 ((void *)(RVA_TO_OFFSET(var,section) + (filedata).file_base))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
134
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
135 int open_input_file (file_data *p_file, const char *name);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
136 int open_output_file (file_data *p_file, const char *name, unsigned long size);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
137 void close_file_data (file_data *p_file);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
138 void mswindows_executable_type (const char * filename, int * is_dos_app,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
139 int * is_cygnus_app);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
140
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
141 /* In process-nt.c */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
142 extern int compare_env (const void *strp1, const void *strp2);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
143
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
144 void mswindows_set_errno (unsigned long win32_error);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
145 void mswindows_set_last_errno (void);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
146
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
147 void wait_for_termination (HANDLE pid);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
148
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
149 int mswindows_fstat (int handle, struct stat *buffer);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
150 int mswindows_stat (const char * path, struct stat * buf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
152 #endif /* INCLUDED_nt_h_ */