index.html
Main Page
|
modules.html
Modules
|
namespaces.html
Namespace List
|
hierarchy.html
Class Hierarchy
|
annotated.html
Data Structures
|
dirs.html
Directories
|
files.html
File List
|
namespacemembers.html
Namespace Members
|
functions.html
Data Fields
|
pages.html
Related Pages
dir_000004.html
dbus
dbus-sysdeps.h
00001
/* -*- mode: C; c-file-style: "gnu" -*- */
00002
/* dbus-sysdeps.h Wrappers around system/libc features (internal to D-BUS implementation)
00003
*
00004
* Copyright (C) 2002, 2003  Red Hat, Inc.
00005
* Copyright (C) 2003 CodeFactory AB
00006
*
00007
* Licensed under the Academic Free License version 2.1
00008
*
00009
* This program is free software; you can redistribute it and/or modify
00010
* it under the terms of the GNU General Public License as published by
00011
* the Free Software Foundation; either version 2 of the License, or
00012
* (at your option) any later version.
00013
*
00014
* This program is distributed in the hope that it will be useful,
00015
* but WITHOUT ANY WARRANTY; without even the implied warranty of
00016
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017
* GNU General Public License for more details.
00018
*
00019
* You should have received a copy of the GNU General Public License
00020
* along with this program; if not, write to the Free Software
00021
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022
*
00023
*/
00024
00025
#ifndef DBUS_SYSDEPS_H
00026
#define DBUS_SYSDEPS_H
00027
00028
#include <config.h>
00029
00030
#include <dbus/dbus-errors.h>
00031
00032
/* this is perhaps bogus, but strcmp() etc. are faster if we use the
00033
* stuff straight out of string.h, so have this here for now.
00034
*/
00035
#include <string.h>
00036
00037
/* and it would just be annoying to abstract this */
00038
#include <errno.h>
00039
00040
group__DBusMacros.html#ga0
DBUS_BEGIN_DECLS
00041
00042
/* The idea of this file is to encapsulate everywhere that we're
00043
* relying on external libc features, for ease of security
00044
* auditing. The idea is from vsftpd. This also gives us a chance to
00045
* make things more convenient to use, e.g.  by reading into a
00046
* DBusString. Operating system headers aren't intended to be used
00047
* outside of this file and a limited number of others (such as
00048
* dbus-memory.c)
00049
*/
00050
00051
typedef
struct
structDBusString.html
DBusString
DBusString;
00052
00053
#if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
00054
#define _DBUS_GNUC_PRINTF( format_idx, arg_idx )    \
00055
__attribute__((__format__ (__printf__, format_idx, arg_idx)))
00056
#define _DBUS_GNUC_SCANF( format_idx, arg_idx )     \
00057
__attribute__((__format__ (__scanf__, format_idx, arg_idx)))
00058
#define _DBUS_GNUC_FORMAT( arg_idx )                \
00059
__attribute__((__format_arg__ (arg_idx)))
00060
#define _DBUS_GNUC_NORETURN                         \
00061
__attribute__((__noreturn__))
00062
#else
/* !__GNUC__ */
00063
#define _DBUS_GNUC_PRINTF( format_idx, arg_idx )
00064
#define _DBUS_GNUC_SCANF( format_idx, arg_idx )
00065
#define _DBUS_GNUC_FORMAT( arg_idx )
00066
#define _DBUS_GNUC_NORETURN
00067
#endif
/* !__GNUC__ */
00068
00069
void
_dbus_abort (
void
) _DBUS_GNUC_NORETURN;
00070
00071 const
char
*
group__DBusInternalsUtils.html#ga57
_dbus_getenv
(const
char
*varname);
00072
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga56
_dbus_setenv
(const
char
*varname,
00073                           const
char
*value);
00074
00075
int
group__DBusInternalsUtils.html#ga58
_dbus_read
(
int
fd,
00076                      DBusString       *buffer,
00077
int
count);
00078
int
group__DBusInternalsUtils.html#ga59
_dbus_write
(
int
fd,
00079                      const DBusString *buffer,
00080
int
start,
00081
int
len);
00082
int
group__DBusInternalsUtils.html#ga60
_dbus_write_two
(
int
fd,
00083                      const DBusString *buffer1,
00084
int
start1,
00085
int
len1,
00086                      const DBusString *buffer2,
00087
int
start2,
00088
int
len2);
00089
00090 typedef
unsigned
long
dbus_pid_t;
00091 typedef
unsigned
long
dbus_uid_t;
00092 typedef
unsigned
long
dbus_gid_t;
00093
00094 #define DBUS_PID_UNSET ((dbus_pid_t) -1)
00095 #define DBUS_UID_UNSET ((dbus_uid_t) -1)
00096 #define DBUS_GID_UNSET ((dbus_gid_t) -1)
00097
00098 #define DBUS_PID_FORMAT "%lu"
00099 #define DBUS_UID_FORMAT "%lu"
00100 #define DBUS_GID_FORMAT "%lu"
00101
structDBusCredentials.html
00105
typedef struct
00106 {
structDBusCredentials.html#o0
00107
dbus_pid_t pid;
structDBusCredentials.html#o1
00108
dbus_uid_t uid;
structDBusCredentials.html#o2
00109
dbus_gid_t gid;
00110 }
structDBusCredentials.html
DBusCredentials
;
00111
00112
int
group__DBusInternalsUtils.html#ga61
_dbus_connect_unix_socket
(
const
char
*path,
00113
group__DBusTypes.html#ga2
dbus_bool_t
abstract
,
00114
structDBusError.html
DBusError
*error);
00115
int
group__DBusInternalsUtils.html#ga62
_dbus_listen_unix_socket
(
const
char
*path,
00116
group__DBusTypes.html#ga2
dbus_bool_t
abstract
,
00117
structDBusError.html
DBusError
*error);
00118
int
group__DBusInternalsUtils.html#ga63
_dbus_connect_tcp_socket
(
const
char
*host,
00119
group__DBusTypes.html#ga3
dbus_uint32_t
port,
00120
structDBusError.html
DBusError
*error);
00121
int
group__DBusInternalsUtils.html#ga64
_dbus_listen_tcp_socket
(
const
char
*host,
00122
group__DBusTypes.html#ga3
dbus_uint32_t
port,
00123
structDBusError.html
DBusError
*error);
00124
int
group__DBusInternalsUtils.html#ga68
_dbus_accept
(
int
listen_fd);
00125
00126
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga66
_dbus_read_credentials_unix_socket
(
int
client_fd,
00127
structDBusCredentials.html
DBusCredentials
*credentials,
00128
structDBusError.html
DBusError
*error);
00129
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga67
_dbus_send_credentials_unix_socket
(
int
server_fd,
00130
structDBusError.html
DBusError
*error);
00131
00132
00133
void
group__DBusInternalsUtils.html#ga74
_dbus_credentials_clear
(
structDBusCredentials.html
DBusCredentials
*credentials);
00134
void
group__DBusInternalsUtils.html#ga75
_dbus_credentials_from_current_process
(
structDBusCredentials.html
DBusCredentials
*credentials);
00135
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga76
_dbus_credentials_match
(
const
structDBusCredentials.html
DBusCredentials
*expected_credentials,
00136
const
structDBusCredentials.html
DBusCredentials
*provided_credentials);
00137
00138
00139
typedef
struct
structDBusUserInfo.html
DBusUserInfo
DBusUserInfo;
00140
typedef
struct
structDBusGroupInfo.html
DBusGroupInfo
DBusGroupInfo;
00141
structDBusUserInfo.html
00145
struct
DBusUserInfo
00146 {
structDBusUserInfo.html#o0
00147
dbus_uid_t
structDBusUserInfo.html#o0
uid
;
structDBusUserInfo.html#o1
00148
dbus_gid_t
structDBusUserInfo.html#o1
primary_gid
;
structDBusUserInfo.html#o2
00149
dbus_gid_t *
structDBusUserInfo.html#o2
group_ids
;
structDBusUserInfo.html#o3
00150
int
structDBusUserInfo.html#o3
n_group_ids
;
structDBusUserInfo.html#o4
00151
char
*
structDBusUserInfo.html#o4
username
;
structDBusUserInfo.html#o5
00152
char
*
structDBusUserInfo.html#o5
homedir
;
00153 };
00154
structDBusGroupInfo.html
00158
struct
DBusGroupInfo
00159 {
structDBusGroupInfo.html#o0
00160
dbus_gid_t
structDBusGroupInfo.html#o0
gid
;
structDBusGroupInfo.html#o1
00161
char
*
structDBusGroupInfo.html#o1
groupname
;
00162 };
00163
00164
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga71
_dbus_user_info_fill
(DBusUserInfo     *info,
00165
const
DBusString *username,
00166
structDBusError.html
DBusError
*error);
00167
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga72
_dbus_user_info_fill_uid
(DBusUserInfo     *info,
00168                                       dbus_uid_t        uid,
00169
structDBusError.html
DBusError
*error);
00170
void
group__DBusInternalsUtils.html#ga73
_dbus_user_info_free
(DBusUserInfo     *info);
00171
00172
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga53
_dbus_group_info_fill
(DBusGroupInfo    *info,
00173
const
DBusString *groupname,
00174
structDBusError.html
DBusError
*error);
00175
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga54
_dbus_group_info_fill_gid
(DBusGroupInfo    *info,
00176                                        dbus_gid_t        gid,
00177
structDBusError.html
DBusError
*error);
00178
void
group__DBusInternalsUtils.html#ga55
_dbus_group_info_free
(DBusGroupInfo    *info);
00179
00180
00181
unsigned
long
group__DBusInternalsUtils.html#ga77
_dbus_getpid
(
void
);
00182 dbus_uid_t
group__DBusInternalsUtils.html#ga78
_dbus_getuid
(
void
);
00183 dbus_gid_t    _dbus_getgid (
void
);
00184
00185
typedef
struct
structDBusAtomic.html
DBusAtomic
DBusAtomic;
00186
structDBusAtomic.html
00190
struct
DBusAtomic
00191 {
structDBusAtomic.html#o0
00192
volatile
group__DBusTypes.html#ga4
dbus_int32_t
structDBusAtomic.html#o0
value
;
00193 };
00194
00195
group__DBusTypes.html#ga4
dbus_int32_t
group__DBusInternalsUtils.html#ga80
_dbus_atomic_inc
(DBusAtomic *atomic);
00196
group__DBusTypes.html#ga4
dbus_int32_t
group__DBusInternalsUtils.html#ga81
_dbus_atomic_dec
(DBusAtomic *atomic);
00197
00198
#define _DBUS_POLLIN      0x0001
/* There is data to read */
00199
#define _DBUS_POLLPRI     0x0002
/* There is urgent data to read */
00200
#define _DBUS_POLLOUT     0x0004
/* Writing now will not block */
00201
#define _DBUS_POLLERR     0x0008
/* Error condition */
00202
#define _DBUS_POLLHUP     0x0010
/* Hung up */
00203
#define _DBUS_POLLNVAL    0x0020
/* Invalid request: fd not open */
00204
structDBusPollFD.html
00208
typedef
struct
00209
{
structDBusPollFD.html#o0
00210
int
fd;
structDBusPollFD.html#o1
00211
short
events;
structDBusPollFD.html#o2
00212
short
revents;
00213 }
structDBusPollFD.html
DBusPollFD
;
00214
00215
int
group__DBusInternalsUtils.html#ga82
_dbus_poll
(
structDBusPollFD.html
DBusPollFD
*fds,
00216
int
n_fds,
00217
int
timeout_milliseconds);
00218
00219
void
group__DBusInternalsUtils.html#ga83
_dbus_sleep_milliseconds
(
int
milliseconds);
00220
00221
void
group__DBusInternalsUtils.html#ga84
_dbus_get_current_time
(
long
*tv_sec,
00222
long
*tv_usec);
00223
00224
00225
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga85
_dbus_file_get_contents
(DBusString       *str,
00226
const
DBusString *filename,
00227
structDBusError.html
DBusError
*error);
00228
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga86
_dbus_string_save_to_file
(
const
DBusString *str,
00229
const
DBusString *filename,
00230
structDBusError.html
DBusError
*error);
00231
00232
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga87
_dbus_create_file_exclusively
(
const
DBusString *filename,
00233
structDBusError.html
DBusError
*error);
00234
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga88
_dbus_delete_file
(
const
DBusString *filename,
00235
structDBusError.html
DBusError
*error);
00236
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga89
_dbus_create_directory
(
const
DBusString *filename,
00237
structDBusError.html
DBusError
*error);
00238
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga43
_dbus_delete_directory
(
const
DBusString *filename,
00239
structDBusError.html
DBusError
*error);
00240
00241
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga90
_dbus_concat_dir_and_file
(DBusString       *dir,
00242
const
DBusString *next_component);
00243
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusString.html#ga59
_dbus_string_get_dirname
(
const
DBusString *filename,
00244                                        DBusString       *dirname);
00245
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga46
_dbus_path_is_absolute
(
const
DBusString *filename);
00246
00247
typedef
struct
structDBusDirIter.html
DBusDirIter
DBusDirIter;
00248
00249 DBusDirIter*
group__DBusInternalsUtils.html#ga48
_dbus_directory_open
(
const
DBusString *filename,
00250
structDBusError.html
DBusError
*error);
00251
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga49
_dbus_directory_get_next_file
(DBusDirIter      *iter,
00252                                             DBusString       *filename,
00253
structDBusError.html
DBusError
*error);
00254
void
group__DBusInternalsUtils.html#ga50
_dbus_directory_close
(DBusDirIter      *iter);
00255
00256
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusString.html#ga63
_dbus_check_dir_is_private_to_user
(DBusString *dir,
00257
structDBusError.html
DBusError
*error);
00258
00259
void
group__DBusInternalsUtils.html#ga93
_dbus_generate_random_bytes_buffer
(
char
*buffer,
00260
int
n_bytes);
00261
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga94
_dbus_generate_random_bytes
(DBusString *str,
00262
int
n_bytes);
00263
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga95
_dbus_generate_random_ascii
(DBusString *str,
00264
int
n_bytes);
00265
00266
const
char
*_dbus_errno_to_string  (
int
errnum);
00267
const
char
*
group__DBusInternalsUtils.html#ga99
_dbus_error_from_errno
(
int
error_number);
00268
00269
void
group__DBusInternalsUtils.html#ga97
_dbus_disable_sigpipe
(
void
);
00270
00271
void
group__DBusInternalsUtils.html#ga98
_dbus_fd_set_close_on_exec
(
int
fd);
00272
00273
void
group__DBusInternalsUtils.html#ga100
_dbus_exit
(
int
code) _DBUS_GNUC_NORETURN;
00274
structDBusStat.html
00278
typedef
struct
00279
{
structDBusStat.html#o0
00280
unsigned
long
mode;
structDBusStat.html#o1
00281
unsigned
long
nlink;
structDBusStat.html#o2
00282
dbus_uid_t    uid;
structDBusStat.html#o3
00283
dbus_gid_t    gid;
structDBusStat.html#o4
00284
unsigned
long
size;
structDBusStat.html#o5
00285
unsigned
long
atime;
structDBusStat.html#o6
00286
unsigned
long
mtime;
structDBusStat.html#o7
00287
unsigned
long
ctime;
00288 }
structDBusStat.html
DBusStat
;
00289
00290
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga47
_dbus_stat
(
const
DBusString *filename,
00291
structDBusStat.html
DBusStat
*statbuf,
00292
structDBusError.html
DBusError
*error);
00293
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga104
_dbus_full_duplex_pipe
(
int
*fd1,
00294
int
*fd2,
00295
group__DBusTypes.html#ga2
dbus_bool_t
blocking,
00296
structDBusError.html
DBusError
*error);
00297
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga101
_dbus_close
(
int
fd,
00298
structDBusError.html
DBusError
*error);
00299
00300
void
_dbus_print_backtrace  (
void
);
00301
00302
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga39
_dbus_become_daemon
(
const
DBusString *pidfile,
00303
int
print_pid_fd,
00304
structDBusError.html
DBusError
*error);
00305
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga40
_dbus_write_pid_file
(
const
DBusString *filename,
00306
unsigned
long
pid,
00307
structDBusError.html
DBusError
*error);
00308
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga41
_dbus_change_identity
(
unsigned
long
uid,
00309
unsigned
long
gid,
00310
structDBusError.html
DBusError
*error);
00311
00312
typedef
void (* DBusSignalHandler) (
int
sig);
00313
00314
void
group__DBusInternalsUtils.html#ga42
_dbus_set_signal_handler
(
int
sig,
00315                                DBusSignalHandler handler);
00316
00317
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga44
_dbus_file_exists
(
const
char
*file);
00318
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga45
_dbus_user_at_console
(
const
char
*username,
00319
structDBusError.html
DBusError
*error);
00320
00321
/* Define DBUS_VA_COPY() to do the right thing for copying va_list variables.
00322
* config.h may have already defined DBUS_VA_COPY as va_copy or __va_copy.
00323
*/
00324
#if !defined (DBUS_VA_COPY)
00325
#  if defined (__GNUC__) && defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32))
00326
#    define DBUS_VA_COPY(ap1, ap2)   (*(ap1) = *(ap2))
00327
#  elif defined (DBUS_VA_COPY_AS_ARRAY)
00328
#    define DBUS_VA_COPY(ap1, ap2)   memcpy ((ap1), (ap2), sizeof (va_list))
00329
#  else
/* va_list is a pointer */
00330
#    define DBUS_VA_COPY(ap1, ap2)   ((ap1) = (ap2))
00331
#  endif
/* va_list is a pointer */
00332
#endif
/* !DBUS_VA_COPY */
00333
00334
/* On x86 there is an 80-bit FPU, and if you do "a == b" it may have a
00335
* or b in an 80-bit register, thus failing to compare the two 64-bit
00336
* doubles for bitwise equality.
00337
*/
00338
#define _DBUS_BYTE_OF_PRIMITIVE(p, i) \
00339
(((const char*)&(p))[(i)])
00340
#define _DBUS_DOUBLES_BITWISE_EQUAL(a, b)                                       \
00341
(_DBUS_BYTE_OF_PRIMITIVE (a, 0) == _DBUS_BYTE_OF_PRIMITIVE (b, 0) &&       \
00342
_DBUS_BYTE_OF_PRIMITIVE (a, 1) == _DBUS_BYTE_OF_PRIMITIVE (b, 1) &&       \
00343
_DBUS_BYTE_OF_PRIMITIVE (a, 2) == _DBUS_BYTE_OF_PRIMITIVE (b, 2) &&       \
00344
_DBUS_BYTE_OF_PRIMITIVE (a, 3) == _DBUS_BYTE_OF_PRIMITIVE (b, 3) &&       \
00345
_DBUS_BYTE_OF_PRIMITIVE (a, 4) == _DBUS_BYTE_OF_PRIMITIVE (b, 4) &&       \
00346
_DBUS_BYTE_OF_PRIMITIVE (a, 5) == _DBUS_BYTE_OF_PRIMITIVE (b, 5) &&       \
00347
_DBUS_BYTE_OF_PRIMITIVE (a, 6) == _DBUS_BYTE_OF_PRIMITIVE (b, 6) &&       \
00348
_DBUS_BYTE_OF_PRIMITIVE (a, 7) == _DBUS_BYTE_OF_PRIMITIVE (b, 7))
00349
00350
group__DBusTypes.html#ga2
dbus_bool_t
group__DBusInternalsUtils.html#ga103
_dbus_parse_uid
(
const
DBusString  *uid_str,
00351                              dbus_uid_t        *uid);
00352
00353
group__DBusMacros.html#ga1
DBUS_END_DECLS
00354
00355
#endif
/* DBUS_SYSDEPS_H */
Generated on Tue Sep 13 01:28:07 2005 for D-BUS by
http://www.doxygen.org/index.html
doxygen
1.4.4
