Commit | Line | Data |
---|---|---|
efa86080 DE |
1 | /* Remote target system call callback support. |
2 | Copyright 1997 Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of GDB. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2 of the License, or | |
9 | (at your option) any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software | |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
19 | ||
9d10b92d DE |
20 | #ifndef CALLBACK_H |
21 | #define CALLBACK_H | |
22 | ||
8902803f MM |
23 | #ifndef va_start |
24 | #include <ansidecl.h> | |
25 | #ifdef ANSI_PROTOTYPES | |
26 | #include <stdarg.h> | |
27 | #else | |
28 | #include <varargs.h> | |
29 | #endif | |
30 | #endif | |
31 | ||
9d10b92d DE |
32 | typedef struct host_callback_struct host_callback; |
33 | ||
34 | #define MAX_CALLBACK_FDS 10 | |
35 | ||
36 | struct host_callback_struct | |
37 | { | |
38 | int (*close) PARAMS ((host_callback *,int)); | |
39 | int (*get_errno) PARAMS ((host_callback *)); | |
40 | int (*isatty) PARAMS ((host_callback *, int)); | |
41 | int (*lseek) PARAMS ((host_callback *, int, long , int)); | |
42 | int (*open) PARAMS ((host_callback *, const char*, int mode)); | |
43 | int (*read) PARAMS ((host_callback *,int, char *, int)); | |
44 | int (*read_stdin) PARAMS (( host_callback *, char *, int)); | |
45 | int (*rename) PARAMS ((host_callback *, const char *, const char *)); | |
46 | int (*system) PARAMS ((host_callback *, const char *)); | |
47 | long (*time) PARAMS ((host_callback *, long *)); | |
48 | int (*unlink) PARAMS ((host_callback *, const char *)); | |
49 | int (*write) PARAMS ((host_callback *,int, const char *, int)); | |
50 | int (*write_stdout) PARAMS ((host_callback *, const char *, int)); | |
6d685937 AC |
51 | void (*flush_stdout) PARAMS ((host_callback *)); |
52 | int (*write_stderr) PARAMS ((host_callback *, const char *, int)); | |
53 | void (*flush_stderr) PARAMS ((host_callback *)); | |
9d10b92d DE |
54 | |
55 | /* Used when the target has gone away, so we can close open | |
e1144153 | 56 | handles and free memory etc etc. */ |
9d10b92d DE |
57 | int (*shutdown) PARAMS ((host_callback *)); |
58 | int (*init) PARAMS ((host_callback *)); | |
59 | ||
6d685937 | 60 | /* depreciated, use vprintf_filtered - Talk to the user on a console. */ |
9d10b92d | 61 | void (*printf_filtered) PARAMS ((host_callback *, const char *, ...)); |
6d685937 | 62 | |
efa86080 DE |
63 | /* Talk to the user on a console. |
64 | The `void *' is actually `va_list *'. */ | |
8902803f | 65 | void (*vprintf_filtered) PARAMS ((host_callback *, const char *, va_list)); |
6d685937 | 66 | |
efa86080 | 67 | /* Same as vprintf_filtered but to stderr. */ |
8902803f | 68 | void (*evprintf_filtered) PARAMS ((host_callback *, const char *, va_list)); |
efa86080 | 69 | |
e1144153 DE |
70 | /* Print an error message and "exit". |
71 | In the case of gdb "exiting" means doing a longjmp back to the main | |
72 | command loop. */ | |
73 | void (*error) PARAMS ((host_callback *, const char *, ...)); | |
9d10b92d DE |
74 | |
75 | int last_errno; /* host format */ | |
76 | ||
77 | int fdmap[MAX_CALLBACK_FDS]; | |
78 | char fdopen[MAX_CALLBACK_FDS]; | |
79 | char alwaysopen[MAX_CALLBACK_FDS]; | |
80 | }; | |
81 | ||
82 | extern host_callback default_callback; | |
83 | ||
84 | /* Mapping of host/target values. */ | |
85 | /* ??? For debugging purposes, one might want to add a string of the | |
86 | name of the symbol. */ | |
87 | ||
88 | typedef struct { | |
89 | int host_val; | |
90 | int target_val; | |
91 | } target_defs_map; | |
92 | ||
93 | extern target_defs_map errno_map[]; | |
94 | extern target_defs_map open_map[]; | |
95 | ||
96 | extern int host_to_target_errno PARAMS ((int)); | |
97 | extern int target_to_host_open PARAMS ((int)); | |
98 | ||
99 | #endif |