Cygwin: (mostly) drop NT4 and Samba < 3.0 support
[newlib-cygwin.git] / winsup / cygwin / local_includes / cygserver.h
blob2788fa377fe23b9000e025082fac888d55f513cf
1 /* cygserver.h
3 Written by Egor Duda <deo@logos-m.ru>
5 This file is part of Cygwin.
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
9 details. */
11 #ifndef _CYGSERVER_H_
12 #define _CYGSERVER_H_
14 #define CYGWIN_SERVER_VERSION_MAJOR 1
15 #define CYGWIN_SERVER_VERSION_API 4
16 #define CYGWIN_SERVER_VERSION_MINOR 0
17 #define CYGWIN_SERVER_VERSION_PATCH 0
19 typedef enum {
20 CYGSERVER_UNKNOWN = 0,
21 CYGSERVER_OK,
22 CYGSERVER_UNAVAIL
23 } cygserver_states;
25 /*---------------------------------------------------------------------------*
26 * class client_request
27 *---------------------------------------------------------------------------*/
29 class transport_layer_base;
31 #ifndef __INSIDE_CYGWIN__
32 class process_cache;
33 #endif
35 class client_request
37 protected:
38 typedef enum {
39 CYGSERVER_REQUEST_INVALID,
40 CYGSERVER_REQUEST_GET_VERSION,
41 CYGSERVER_REQUEST_SHUTDOWN,
42 CYGSERVER_REQUEST_ATTACH_TTY,
43 CYGSERVER_REQUEST_MSG,
44 CYGSERVER_REQUEST_SEM,
45 CYGSERVER_REQUEST_SHM,
46 CYGSERVER_REQUEST_SETPWD,
47 CYGSERVER_REQUEST_PWDGRP,
48 CYGSERVER_REQUEST_LAST
49 } request_code_t;
51 struct header_t
53 size_t msglen;
54 union
56 request_code_t request_code;
57 int error_code;
60 header_t () {};
61 header_t (request_code_t, size_t);
64 public:
65 #ifndef __INSIDE_CYGWIN__
66 static void handle_request (transport_layer_base *, process_cache *);
67 #endif
69 client_request (request_code_t request_code,
70 void *buf = NULL,
71 size_t bufsiz = 0);
72 virtual ~client_request ();
74 request_code_t request_code () const { return _header.request_code; }
76 int error_code () const { return _header.error_code; };
77 void error_code (int error_code) { _header.error_code = error_code; };
79 size_t msglen () const { return _header.msglen; };
80 void msglen (size_t len) { _header.msglen = len; };
82 int make_request ();
84 protected:
85 virtual void send (transport_layer_base *);
87 private:
88 header_t _header;
89 void * const _buf;
90 const size_t _buflen;
92 #ifndef __INSIDE_CYGWIN__
93 void handle (transport_layer_base *, process_cache *);
94 virtual void serve (transport_layer_base *, process_cache *) = 0;
95 #endif
98 /*---------------------------------------------------------------------------*
99 * class client_request_get_version
100 *---------------------------------------------------------------------------*/
102 class client_request_get_version : public client_request
104 private:
105 struct request_get_version
107 DWORD major, api, minor, patch;
110 public:
111 client_request_get_version ();
112 bool check_version () const;
114 private:
115 struct request_get_version version;
117 #ifndef __INSIDE_CYGWIN__
118 virtual void serve (transport_layer_base *, process_cache *);
119 #endif
122 /*---------------------------------------------------------------------------*
123 * class client_request_shutdown
125 * Nb. This whole class is only !__INSIDE_CYGWIN__ since it is used
126 * solely by cygserver itself.
127 *---------------------------------------------------------------------------*/
129 #ifndef __INSIDE_CYGWIN__
131 class client_request_shutdown : public client_request
133 public:
134 client_request_shutdown ();
136 private:
137 virtual void serve (transport_layer_base *, process_cache *);
140 #endif /* !__INSIDE_CYGWIN__ */
142 /*---------------------------------------------------------------------------*
143 * class client_request_attach_tty
144 *---------------------------------------------------------------------------*/
146 class client_request_attach_tty : public client_request
148 private:
149 struct request_attach_tty
151 DWORD pid, master_pid;
152 HANDLE from_master, to_master;
155 public:
156 #ifdef __INSIDE_CYGWIN__
157 client_request_attach_tty (DWORD nmaster_pid,
158 HANDLE nfrom_master, HANDLE nto_master);
159 #else
160 client_request_attach_tty ();
161 #endif
163 HANDLE from_master () const { return req.from_master; };
164 HANDLE to_master () const { return req.to_master; };
166 protected:
167 virtual void send (transport_layer_base *);
169 private:
170 struct request_attach_tty req;
172 #ifndef __INSIDE_CYGWIN__
173 virtual void serve (transport_layer_base *, process_cache *);
174 #endif
177 #ifndef __INSIDE_CYGWIN__
178 extern PSID admininstrator_group_sid;
179 #endif
181 extern bool check_cygserver_available ();
182 extern void cygserver_init ();
184 #endif /* _CYGSERVER_H_ */