]> sourceware.org Git - newlib-cygwin.git/blob - winsup/cygwin/include/cygwin/cygserver.h
* include/cygwin/version.h: Reorganize last two api versions so that btowc and
[newlib-cygwin.git] / winsup / cygwin / include / cygwin / cygserver.h
1 /* cygserver.h
2
3 Copyright 2001, 2002 Red Hat Inc.
4
5 Written by Egor Duda <deo@logos-m.ru>
6
7 This file is part of Cygwin.
8
9 This software is a copyrighted work licensed under the terms of the
10 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
11 details. */
12
13 #ifndef _CYGSERVER_H_
14 #define _CYGSERVER_H_
15
16 #ifdef __GNUC__
17 #define CYGSERVER_PACKED __attribute__ ((packed))
18 #else
19 #define CYGSERVER_PACKED
20 #endif
21
22 #define CYGWIN_SERVER_VERSION_MAJOR 1
23 #define CYGWIN_SERVER_VERSION_API 1
24 #define CYGWIN_SERVER_VERSION_MINOR 0
25 #define CYGWIN_SERVER_VERSION_PATCH 0
26
27 typedef enum {
28 CYGSERVER_UNKNOWN = 0,
29 CYGSERVER_OK,
30 CYGSERVER_UNAVAIL
31 } cygserver_states;
32
33 /*---------------------------------------------------------------------------*
34 * class client_request
35 *---------------------------------------------------------------------------*/
36
37 class transport_layer_base;
38
39 #ifndef __INSIDE_CYGWIN__
40 class process_cache;
41 #endif
42
43 class client_request
44 {
45 protected:
46 typedef enum {
47 CYGSERVER_REQUEST_INVALID,
48 CYGSERVER_REQUEST_GET_VERSION,
49 CYGSERVER_REQUEST_SHUTDOWN,
50 CYGSERVER_REQUEST_ATTACH_TTY,
51 CYGSERVER_REQUEST_SHM,
52 CYGSERVER_REQUEST_LAST
53 } request_code_t;
54
55 struct header_t
56 {
57 size_t msglen;
58 union
59 {
60 request_code_t request_code;
61 ssize_t error_code;
62 };
63
64 header_t () {};
65 header_t (request_code_t, size_t);
66 } CYGSERVER_PACKED;
67
68 public:
69 #ifndef __INSIDE_CYGWIN__
70 static void handle_request (transport_layer_base *, process_cache *);
71 #endif
72
73 client_request (request_code_t request_code,
74 void *buf = NULL,
75 size_t bufsiz = 0);
76 virtual ~client_request ();
77
78 request_code_t request_code () const { return _header.request_code; }
79
80 ssize_t error_code () const { return _header.error_code; };
81 void error_code (ssize_t error_code) { _header.error_code = error_code; };
82
83 size_t msglen () const { return _header.msglen; };
84 void msglen (size_t len) { _header.msglen = len; };
85
86 int make_request ();
87
88 protected:
89 virtual void send (transport_layer_base *);
90
91 private:
92 header_t _header;
93 void * const _buf;
94 const size_t _buflen;
95
96 #ifndef __INSIDE_CYGWIN__
97 void handle (transport_layer_base *, process_cache *);
98 virtual void serve (transport_layer_base *, process_cache *) = 0;
99 #endif
100 };
101
102 /*---------------------------------------------------------------------------*
103 * class client_request_get_version
104 *---------------------------------------------------------------------------*/
105
106 class client_request_get_version : public client_request
107 {
108 private:
109 struct request_get_version
110 {
111 DWORD major, api, minor, patch;
112 } CYGSERVER_PACKED;
113
114 public:
115 client_request_get_version ();
116 bool check_version () const;
117
118 private:
119 struct request_get_version version;
120
121 #ifndef __INSIDE_CYGWIN__
122 virtual void serve (transport_layer_base *, process_cache *);
123 #endif
124 };
125
126 /*---------------------------------------------------------------------------*
127 * class client_request_shutdown
128 *
129 * Nb. This whole class is only !__INSIDE_CYGWIN__ since it is used
130 * solely by cygserver itself.
131 *---------------------------------------------------------------------------*/
132
133 #ifndef __INSIDE_CYGWIN__
134
135 class client_request_shutdown : public client_request
136 {
137 public:
138 client_request_shutdown ();
139
140 private:
141 virtual void serve (transport_layer_base *, process_cache *);
142 };
143
144 #endif /* !__INSIDE_CYGWIN__ */
145
146 /*---------------------------------------------------------------------------*
147 * class client_request_attach_tty
148 *---------------------------------------------------------------------------*/
149
150 class client_request_attach_tty : public client_request
151 {
152 private:
153 struct request_attach_tty
154 {
155 DWORD pid, master_pid;
156 HANDLE from_master, to_master;
157 } CYGSERVER_PACKED;
158
159 public:
160 #ifdef __INSIDE_CYGWIN__
161 client_request_attach_tty (DWORD nmaster_pid,
162 HANDLE nfrom_master, HANDLE nto_master);
163 #else
164 client_request_attach_tty ();
165 #endif
166
167 HANDLE from_master () const { return req.from_master; };
168 HANDLE to_master () const { return req.to_master; };
169
170 protected:
171 virtual void send (transport_layer_base *);
172
173 private:
174 struct request_attach_tty req;
175
176 #ifndef __INSIDE_CYGWIN__
177 virtual void serve (transport_layer_base *, process_cache *);
178 #endif
179 };
180
181 extern bool check_cygserver_available ();
182 extern void cygserver_init ();
183
184 #endif /* _CYGSERVER_H_ */
This page took 0.043067 seconds and 5 git commands to generate.