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