100
|
1 /* Support routines for the NT version of XEmacs.
|
|
2 Copyright (C) 1994 Free Software Foundation, Inc.
|
|
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 /* Adapted for XEmacs by David Hobley <david@spook-le0.cia.com.au> */
|
209
|
22 /* Sync'ed with Emacs 19.34.6 by Marc Paquette <marcpa@cam.org> */
|
100
|
23
|
|
24 /* #define FULL_DEBUG */
|
|
25
|
398
|
26 #ifndef INCLUDED_nt_h_
|
|
27 #define INCLUDED_nt_h_
|
|
28
|
239
|
29 #ifdef DEBUG_XEMACS
|
100
|
30 #define DebPrint(stuff) _DebPrint stuff
|
|
31 #else
|
|
32 #define DebPrint(stuff)
|
|
33 #endif
|
|
34
|
|
35 #define R_OK 4
|
|
36 #define W_OK 2
|
398
|
37 #ifdef X_OK
|
|
38 #undef X_OK
|
|
39 #endif
|
100
|
40 #define X_OK 1
|
|
41 #define F_OK 0
|
|
42
|
|
43 /* ------------------------------------------------------------------------- */
|
|
44
|
|
45 /* child_process.status values */
|
|
46 enum {
|
|
47 STATUS_READ_ERROR = -1,
|
|
48 STATUS_READ_READY,
|
|
49 STATUS_READ_IN_PROGRESS,
|
|
50 STATUS_READ_FAILED,
|
|
51 STATUS_READ_SUCCEEDED,
|
|
52 STATUS_READ_ACKNOWLEDGED
|
|
53 };
|
|
54
|
|
55 /* This structure is used for both pipes and sockets; for
|
|
56 a socket, the process handle in pi is NULL. */
|
|
57 typedef struct _child_process
|
|
58 {
|
|
59 int fd;
|
|
60 int pid;
|
|
61 HANDLE char_avail;
|
|
62 HANDLE char_consumed;
|
|
63 HANDLE thrd;
|
209
|
64 HWND hwnd;
|
100
|
65 PROCESS_INFORMATION procinfo;
|
|
66 volatile int status;
|
|
67 char chr;
|
|
68 } child_process;
|
|
69
|
|
70 #define MAX_CHILDREN MAXDESC/2
|
|
71 #define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL)
|
|
72
|
|
73 /* parallel array of private info on file handles */
|
|
74 typedef struct
|
|
75 {
|
|
76 unsigned flags;
|
|
77 HANDLE hnd;
|
|
78 child_process * cp;
|
|
79 } filedesc;
|
|
80
|
408
|
81 extern filedesc fd_info [];
|
100
|
82
|
|
83 /* fd_info flag definitions */
|
|
84 #define FILE_READ 0x0001
|
|
85 #define FILE_WRITE 0x0002
|
|
86 #define FILE_BINARY 0x0010
|
209
|
87 #define FILE_LAST_CR 0x0020
|
|
88 #define FILE_AT_EOF 0x0040
|
|
89 #define FILE_SEND_SIGCHLD 0x0080
|
100
|
90 #define FILE_PIPE 0x0100
|
|
91 #define FILE_SOCKET 0x0200
|
|
92
|
|
93 extern child_process * new_child (void);
|
|
94 extern void delete_child (child_process *cp);
|
|
95
|
|
96 /* ------------------------------------------------------------------------- */
|
|
97
|
209
|
98 /* Get long (aka "true") form of file name, if it exists. */
|
|
99 extern BOOL win32_get_long_filename (char * name, char * buf, int size);
|
100
|
100
|
|
101 /* Prepare our standard handles for proper inheritance by child processes. */
|
|
102 extern void prepare_standard_handles (int in, int out,
|
|
103 int err, HANDLE handles[4]);
|
|
104
|
|
105 /* Reset our standard handles to their original state. */
|
|
106 extern void reset_standard_handles (int in, int out,
|
|
107 int err, HANDLE handles[4]);
|
|
108
|
|
109 /* Return the string resource associated with KEY of type TYPE. */
|
|
110 extern LPBYTE nt_get_resource (char * key, LPDWORD type);
|
|
111
|
288
|
112 void set_process_dir (const char * dir);
|
|
113 time_t convert_time (FILETIME ft);
|
|
114
|
408
|
115 extern void init_ntproc (void);
|
406
|
116 extern void term_ntproc (int unused);
|
100
|
117
|
408
|
118 /* ----------------------------------------------------------------- */
|
|
119 /* Useful routines for manipulating memory-mapped files. */
|
|
120
|
|
121 typedef struct file_data
|
|
122 {
|
|
123 const char *name;
|
|
124 unsigned long size;
|
|
125 HANDLE file;
|
|
126 HANDLE file_mapping;
|
|
127 char *file_base;
|
|
128 } file_data;
|
|
129
|
|
130 #define OFFSET_TO_RVA(var,section) \
|
|
131 (section->VirtualAddress + ((DWORD)(var) - section->PointerToRawData))
|
|
132
|
|
133 #define RVA_TO_OFFSET(var,section) \
|
|
134 (section->PointerToRawData + ((DWORD)(var) - section->VirtualAddress))
|
|
135
|
|
136 #define RVA_TO_PTR(var,section,filedata) \
|
|
137 ((void *)(RVA_TO_OFFSET(var,section) + (filedata).file_base))
|
|
138
|
|
139 int open_input_file (file_data *p_file, const char *name);
|
|
140 int open_output_file (file_data *p_file, const char *name, unsigned long size);
|
|
141 void close_file_data (file_data *p_file);
|
|
142 void mswindows_executable_type (const char * filename, int * is_dos_app,
|
|
143 int * is_cygnus_app);
|
|
144
|
|
145 /* In process-nt.c */
|
|
146 extern int compare_env (const void *strp1, const void *strp2);
|
|
147
|
398
|
148 #endif /* INCLUDED_nt_h_ */
|