* dbus/dbus-sysdeps-win.c, dbus/dbus-sysdeps-spawn-win.c, dbus/dbus-sysdeps-win.h...
[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 #undef interface
37
38 #include <aclapi.h>
39 #include <lm.h>
40 #include <io.h>
41 #include <share.h>
42 #include <direct.h>
43
44 #define mkdir(path, mode) _mkdir (path)
45
46 #ifndef DBUS_WINCE
47 #ifndef S_ISREG
48 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
49 #endif
50 #endif
51
52 /* Declarations missing in mingw's headers */
53 extern BOOL WINAPI ConvertStringSidToSidA (LPCSTR  StringSid, PSID *Sid);
54 extern BOOL WINAPI ConvertSidToStringSidA (PSID Sid, LPSTR *StringSid);
55
56
57 #define DBUS_CONSOLE_DIR "/var/run/console/"
58
59
60 //#define ENABLE_DBUSSOCKET
61
62 #ifdef ENABLE_DBUSSOCKET
63 typedef struct
64   {
65     int fd;               /* File descriptor, SOCKET or file HANDLE */
66     int port_file_fd;     /* File descriptor for file containing
67                            * port number for "pseudo-unix" sockets
68                            */
69     DBusString port_file; /* File name for said file */
70     dbus_bool_t close_on_exec;
71     dbus_bool_t non_blocking;
72     int is_used; 
73   }
74 DBusSocket;
75
76 extern DBusSocket *win_fds;
77 extern int win32_n_fds;
78 #endif
79
80
81 void _dbus_win_startup_winsock (void);
82 void _dbus_win_warn_win_error  (const char *message,
83                                 int         code);
84 extern const char* _dbus_lm_strerror  (int error_number);
85
86 #ifdef ENABLE_DBUSUSERINFO
87 dbus_bool_t
88 fill_win_user_info_from_uid (dbus_uid_t    uid,
89                              DBusUserInfo *info,
90                              DBusError    *error);
91 dbus_bool_t
92 fill_win_user_info_from_name (wchar_t      *wname,
93                               DBusUserInfo *info,
94                               DBusError    *error);
95
96 dbus_bool_t
97 fill_user_info (DBusUserInfo       *info,
98                 dbus_uid_t          uid,
99                 const DBusString   *username,
100                 DBusError          *error);
101 #endif
102
103 dbus_bool_t _dbus_win_account_to_sid (const wchar_t *waccount,
104                                       void         **ppsid,
105                                       DBusError     *error);
106
107 dbus_bool_t
108 _dbus_win32_sid_to_name_and_domain (dbus_uid_t  uid,
109                                     wchar_t   **wname,
110                                     wchar_t   **wdomain,
111                                     DBusError  *error);
112
113
114 /* Don't define DBUS_CONSOLE_DIR on Win32 */
115
116 wchar_t    *_dbus_win_utf8_to_utf16 (const char  *str,
117                                      DBusError   *error);
118 char       *_dbus_win_utf16_to_utf8 (const wchar_t *str,
119                                      DBusError *error);
120
121 void        _dbus_win_set_error_from_win_error (DBusError *error, int code);
122
123 dbus_uid_t  _dbus_win_sid_to_uid_t (void        *psid);
124 dbus_bool_t _dbus_uid_t_to_win_sid (dbus_uid_t   uid,
125                                     void       **ppsid);
126 dbus_bool_t
127 _dbus_account_to_win_sid (const wchar_t  *waccount,
128                           void          **ppsid,
129                           DBusError      *error);
130 dbus_bool_t
131 _dbus_win_sid_to_name_and_domain (dbus_uid_t uid,
132                                   wchar_t  **wname,
133                                   wchar_t  **wdomain,
134                                   DBusError *error);
135
136 typedef struct DBusFile DBusFile;
137
138 dbus_bool_t _dbus_file_open (DBusFile   *file,
139                              const char *filename,
140                              int         oflag,
141                              int         pmode);
142
143 dbus_bool_t _dbus_file_close (DBusFile  *file,
144                               DBusError *error);
145
146
147 int _dbus_file_read  (DBusFile   *file,
148                       DBusString *buffer,
149                       int         count);
150
151 int _dbus_file_write (DBusFile         *file,
152                       const DBusString *buffer,
153                       int               start,
154                       int               len);
155
156 dbus_bool_t _dbus_file_exists (const char *filename);
157
158
159 #define FDATA private_data
160 struct DBusFile
161   {
162     int FDATA;
163   };
164
165 #ifdef ENABLE_DBUSSOCKET
166 void _dbus_handle_to_socket (int          handle,
167                              DBusSocket **socket);
168 int  _dbus_socket_to_handle (DBusSocket  *socket);
169 #endif
170
171
172 dbus_bool_t _dbus_get_config_file_name(DBusString *config_file, 
173                                        char *s);
174
175
176
177 #endif
178
179 /** @} end of sysdeps-win.h */
180
181