* dbus/dbus-sysdeps-win.h, dbus/dbus-sysdeps-win.c, dbus/dbus-sysdeps-util-win.c...
[platform/upstream/dbus.git] / dbus / dbus-sysdeps-win.h
1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* dbus-sysdeps.c Wrappers around system/libc features (internal to D-BUS implementation)
3  * 
4  * Copyright (C) 2002, 2003  Red Hat, Inc.
5  * Copyright (C) 2003 CodeFactory AB
6  * Copyright (C) 2005 Novell, Inc.
7  *
8  * Licensed under the Academic Free License version 2.1
9  * 
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  * 
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23  *
24  */
25
26 #ifndef DBUS_SYSDEPS_WIN_H
27 #define DBUS_SYSDEPS_WIN_H
28
29 #define _WINSOCKAPI_
30
31 #include "dbus-hash.h"
32 #include "dbus-string.h"
33 #include <ctype.h>
34 #include <malloc.h>
35 #include <windows.h>
36
37 #include <aclapi.h>
38 #include <lm.h>
39 #include <io.h>
40 #include <share.h>
41 #include <direct.h>
42
43 #define mkdir(path, mode) _mkdir (path)
44
45 #ifndef DBUS_WINCE
46 #ifndef S_ISREG
47 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
48 #endif
49 #endif
50
51 /* Declarations missing in mingw's headers */
52 extern BOOL WINAPI ConvertStringSidToSidA (LPCSTR  StringSid, PSID *Sid);
53 extern BOOL WINAPI ConvertSidToStringSidA (PSID Sid, LPSTR *StringSid);
54
55
56 #define DBUS_CONSOLE_DIR "/var/run/console/"
57
58 typedef struct
59   {
60     int fd;               /* File descriptor, SOCKET or file HANDLE */
61     int port_file_fd;     /* File descriptor for file containing
62                            * port number for "pseudo-unix" sockets
63                            */
64     DBusString port_file; /* File name for said file */
65     dbus_bool_t close_on_exec;
66     dbus_bool_t non_blocking;
67     int is_used; 
68   }
69 DBusSocket;
70
71 extern DBusSocket *win_fds;
72 extern int win32_n_fds;
73
74
75 void _dbus_win_startup_winsock (void);
76 void _dbus_win_warn_win_error  (const char *message,
77                                 int         code);
78 extern const char* _dbus_lm_strerror  (int error_number);
79
80
81 dbus_bool_t
82 fill_win_user_info_from_uid (dbus_uid_t    uid,
83                              DBusUserInfo *info,
84                              DBusError    *error);
85 dbus_bool_t
86 fill_win_user_info_from_name (wchar_t      *wname,
87                               DBusUserInfo *info,
88                               DBusError    *error);
89
90 dbus_bool_t _dbus_win_account_to_sid (const wchar_t *waccount,
91                                       void         **ppsid,
92                                       DBusError     *error);
93
94 dbus_bool_t
95 _dbus_win32_sid_to_name_and_domain (dbus_uid_t  uid,
96                                     wchar_t   **wname,
97                                     wchar_t   **wdomain,
98                                     DBusError  *error);
99
100
101 /* Don't define DBUS_CONSOLE_DIR on Win32 */
102
103 wchar_t    *_dbus_win_utf8_to_utf16 (const char  *str,
104                                      DBusError   *error);
105 char       *_dbus_win_utf16_to_utf8 (const wchar_t *str,
106                                      DBusError *error);
107
108 void        _dbus_win_set_error_from_win_error (DBusError *error, int code);
109
110 dbus_uid_t  _dbus_win_sid_to_uid_t (void        *psid);
111 dbus_bool_t _dbus_uid_t_to_win_sid (dbus_uid_t   uid,
112                                     void       **ppsid);
113 dbus_bool_t
114 _dbus_account_to_win_sid (const wchar_t  *waccount,
115                           void          **ppsid,
116                           DBusError      *error);
117 dbus_bool_t
118 _dbus_win_sid_to_name_and_domain (dbus_uid_t uid,
119                                   wchar_t  **wname,
120                                   wchar_t  **wdomain,
121                                   DBusError *error);
122
123 typedef struct DBusFile DBusFile;
124
125 dbus_bool_t _dbus_file_open (DBusFile   *file,
126                              const char *filename,
127                              int         oflag,
128                              int         pmode);
129
130 dbus_bool_t _dbus_file_close (DBusFile  *file,
131                               DBusError *error);
132
133
134 int _dbus_file_read  (DBusFile   *file,
135                       DBusString *buffer,
136                       int         count);
137
138 int _dbus_file_write (DBusFile         *file,
139                       const DBusString *buffer,
140                       int               start,
141                       int               len);
142
143 #define FDATA private_data
144 struct DBusFile
145   {
146     int FDATA;
147   };
148
149
150 void _dbus_handle_to_socket (int          handle,
151                              DBusSocket **socket);
152 int  _dbus_socket_to_handle (DBusSocket  *socket);
153
154 dbus_bool_t
155 fill_user_info (DBusUserInfo       *info,
156                 dbus_uid_t          uid,
157                 const DBusString   *username,
158                 DBusError          *error);
159
160 // replace with a windows version
161 dbus_bool_t _dbus_open_unix_socket (int              *fd,
162                                     DBusError        *error);
163 int _dbus_connect_unix_socket (const char     *path,
164                                dbus_bool_t     abstract,
165                                DBusError      *error);
166 int _dbus_listen_unix_socket  (const char     *path,
167                                dbus_bool_t     abstract,
168                                DBusError      *error);
169
170 #endif
171
172 /** @} end of sysdeps-win.h */
173
174