"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "dbus/dbus-sysdeps-win.c" between
dbus-1.13.14.tar.xz and dbus-1.13.16.tar.xz

About: D-Bus is an inter-process communication (IPC) system, allowing multiple, concurrently-running applications to communicate with one another. D-Bus supplies both a system daemon and a per-user-login-session daemon. Development version.

dbus-sysdeps-win.c  (dbus-1.13.14.tar.xz):dbus-sysdeps-win.c  (dbus-1.13.16.tar.xz)
skipping to change at line 85 skipping to change at line 85
#define O_BINARY 0 #define O_BINARY 0
#endif #endif
#ifndef PROCESS_QUERY_LIMITED_INFORMATION #ifndef PROCESS_QUERY_LIMITED_INFORMATION
/* MinGW32 < 4 does not define this value in its headers */ /* MinGW32 < 4 does not define this value in its headers */
#define PROCESS_QUERY_LIMITED_INFORMATION (0x1000) #define PROCESS_QUERY_LIMITED_INFORMATION (0x1000)
#endif #endif
typedef int socklen_t; typedef int socklen_t;
/* uncomment to enable windows event based poll implementation */
//#define USE_CHRIS_IMPL
void void
_dbus_win_set_errno (int err) _dbus_win_set_errno (int err)
{ {
#ifdef DBUS_WINCE #ifdef DBUS_WINCE
SetLastError (err); SetLastError (err);
#else #else
errno = err; errno = err;
#endif #endif
} }
skipping to change at line 1140 skipping to change at line 1143
out0: out0:
closesocket (temp); closesocket (temp);
dbus_set_error (error, _dbus_error_from_errno (errno), dbus_set_error (error, _dbus_error_from_errno (errno),
"Could not setup socket pair: %s", "Could not setup socket pair: %s",
_dbus_strerror_from_errno ()); _dbus_strerror_from_errno ());
return FALSE; return FALSE;
} }
#ifdef DBUS_ENABLE_VERBOSE_MODE
static dbus_bool_t
_dbus_dump_fd_events (DBusPollFD *fds, int n_fds)
{
DBusString msg = _DBUS_STRING_INIT_INVALID;
dbus_bool_t result = FALSE;
int i;
if (!_dbus_string_init (&msg))
goto oom;
for (i = 0; i < n_fds; i++)
{
DBusPollFD *fdp = &fds[i];
if (!_dbus_string_append (&msg, i > 0 ? "\n\t" : "\t"))
goto oom;
if ((fdp->events & _DBUS_POLLIN) &&
!_dbus_string_append_printf (&msg, "R:%Iu ", fdp->fd.sock))
goto oom;
if ((fdp->events & _DBUS_POLLOUT) &&
!_dbus_string_append_printf (&msg, "W:%Iu ", fdp->fd.sock))
goto oom;
if (!_dbus_string_append_printf (&msg, "E:%Iu", fdp->fd.sock))
goto oom;
}
_dbus_verbose ("%s\n", _dbus_string_get_const_data (&msg));
result = TRUE;
oom:
_dbus_string_free (&msg);
return result;
}
#ifdef USE_CHRIS_IMPL
static dbus_bool_t
_dbus_dump_fd_revents (DBusPollFD *fds, int n_fds)
{
DBusString msg = _DBUS_STRING_INIT_INVALID;
dbus_bool_t result = FALSE;
int i;
if (!_dbus_string_init (&msg))
goto oom;
for (i = 0; i < n_fds; i++)
{
DBusPollFD *fdp = &fds[i];
if (!_dbus_string_append (&msg, i > 0 ? "\n\t" : "\t"))
goto oom;
if ((fdp->revents & _DBUS_POLLIN) &&
!_dbus_string_append_printf (&msg, "R:%Iu ", fdp->fd.sock))
goto oom;
if ((fdp->revents & _DBUS_POLLOUT) &&
!_dbus_string_append_printf (&msg, "W:%Iu ", fdp->fd.sock))
goto oom;
if ((fdp->revents & _DBUS_POLLERR) &&
!_dbus_string_append_printf (&msg, "E:%Iu", fdp->fd.sock))
goto oom;
}
_dbus_verbose ("%s\n", _dbus_string_get_const_data (&msg));
result = TRUE;
oom:
_dbus_string_free (&msg);
return result;
}
#else
static dbus_bool_t
_dbus_dump_fdset (DBusPollFD *fds, int n_fds, fd_set *read_set, fd_set *write_se
t, fd_set *err_set)
{
DBusString msg = _DBUS_STRING_INIT_INVALID;
dbus_bool_t result = FALSE;
int i;
if (!_dbus_string_init (&msg))
goto oom;
for (i = 0; i < n_fds; i++)
{
DBusPollFD *fdp = &fds[i];
if (!_dbus_string_append (&msg, i > 0 ? "\n\t" : "\t"))
goto oom;
if (FD_ISSET (fdp->fd.sock, read_set) &&
!_dbus_string_append_printf (&msg, "R:%Iu ", fdp->fd.sock))
goto oom;
if (FD_ISSET (fdp->fd.sock, write_set) &&
!_dbus_string_append_printf (&msg, "W:%Iu ", fdp->fd.sock))
goto oom;
if (FD_ISSET (fdp->fd.sock, err_set) &&
!_dbus_string_append_printf (&msg, "E:%Iu", fdp->fd.sock))
goto oom;
}
_dbus_verbose ("%s\n", _dbus_string_get_const_data (&msg));
result = TRUE;
oom:
_dbus_string_free (&msg);
return result;
}
#endif
#endif
#ifdef USE_CHRIS_IMPL
/** /**
* Wrapper for poll(). * Windows event based implementation for _dbus_poll().
* *
* @param fds the file descriptors to poll * @param fds the file descriptors to poll
* @param n_fds number of descriptors in the array * @param n_fds number of descriptors in the array
* @param timeout_milliseconds timeout or -1 for infinite * @param timeout_milliseconds timeout or -1 for infinite
* @returns numbers of fds with revents, or <0 on error * @returns numbers of fds with revents, or <0 on error
*/ */
int static int
_dbus_poll (DBusPollFD *fds, _dbus_poll_events (DBusPollFD *fds,
int n_fds, int n_fds,
int timeout_milliseconds) int timeout_milliseconds)
{ {
#define USE_CHRIS_IMPL 0
#if USE_CHRIS_IMPL
#define DBUS_POLL_CHAR_BUFFER_SIZE 2000
char msg[DBUS_POLL_CHAR_BUFFER_SIZE];
char *msgp;
int ret = 0; int ret = 0;
int i; int i;
struct timeval tv; DWORD ready;
int ready;
#define DBUS_STACK_WSAEVENTS 256 #define DBUS_STACK_WSAEVENTS 256
WSAEVENT eventsOnStack[DBUS_STACK_WSAEVENTS]; WSAEVENT eventsOnStack[DBUS_STACK_WSAEVENTS];
WSAEVENT *pEvents = NULL; WSAEVENT *pEvents = NULL;
if (n_fds > DBUS_STACK_WSAEVENTS) if (n_fds > DBUS_STACK_WSAEVENTS)
pEvents = calloc(sizeof(WSAEVENT), n_fds); pEvents = calloc(sizeof(WSAEVENT), n_fds);
else else
pEvents = eventsOnStack; pEvents = eventsOnStack;
if (pEvents == NULL)
{
_dbus_win_set_errno (ENOMEM);
ret = -1;
goto oom;
}
#ifdef DBUS_ENABLE_VERBOSE_MODE #ifdef DBUS_ENABLE_VERBOSE_MODE
msgp = msg; _dbus_verbose ("_dbus_poll: to=%d", timeout_milliseconds);
msgp += sprintf (msgp, "WSAEventSelect: to=%d\n\t", timeout_milliseconds); if (!_dbus_dump_fd_events (fds, n_fds))
for (i = 0; i < n_fds; i++)
{ {
DBusPollFD *fdp = &fds[i]; _dbus_win_set_errno (ENOMEM);
ret = -1;
if (fdp->events & _DBUS_POLLIN) goto oom;
msgp += sprintf (msgp, "R:%Iu ", fdp->fd.sock);
if (fdp->events & _DBUS_POLLOUT)
msgp += sprintf (msgp, "W:%Iu ", fdp->fd.sock);
msgp += sprintf (msgp, "E:%Iu\n\t", fdp->fd.sock);
// FIXME: more robust code for long msg
// create on heap when msg[] becomes too small
if (msgp >= msg + DBUS_POLL_CHAR_BUFFER_SIZE)
{
_dbus_assert_not_reached ("buffer overflow in _dbus_poll");
}
} }
msgp += sprintf (msgp, "\n");
_dbus_verbose ("%s",msg);
#endif #endif
for (i = 0; i < n_fds; i++)
pEvents[i] = WSA_INVALID_EVENT;
for (i = 0; i < n_fds; i++) for (i = 0; i < n_fds; i++)
{ {
DBusPollFD *fdp = &fds[i]; DBusPollFD *fdp = &fds[i];
WSAEVENT ev; WSAEVENT ev;
long lNetworkEvents = FD_OOB; long lNetworkEvents = FD_OOB;
ev = WSACreateEvent(); ev = WSACreateEvent();
if (fdp->events & _DBUS_POLLIN) if (fdp->events & _DBUS_POLLIN)
lNetworkEvents |= FD_READ | FD_ACCEPT | FD_CLOSE; lNetworkEvents |= FD_READ | FD_ACCEPT | FD_CLOSE;
if (fdp->events & _DBUS_POLLOUT) if (fdp->events & _DBUS_POLLOUT)
lNetworkEvents |= FD_WRITE | FD_CONNECT; lNetworkEvents |= FD_WRITE | FD_CONNECT;
WSAEventSelect(fdp->fd.sock, ev, lNetworkEvents); WSAEventSelect (fdp->fd.sock, ev, lNetworkEvents);
pEvents[i] = ev; pEvents[i] = ev;
} }
ready = WSAWaitForMultipleEvents (n_fds, pEvents, FALSE, timeout_milliseconds, FALSE); ready = WSAWaitForMultipleEvents (n_fds, pEvents, FALSE, timeout_milliseconds, FALSE);
if (DBUS_SOCKET_API_RETURNS_ERROR (ready)) if (ready == WSA_WAIT_FAILED)
{ {
DBUS_SOCKET_SET_ERRNO (); DBUS_SOCKET_SET_ERRNO ();
if (errno != WSAEWOULDBLOCK) if (errno != WSAEWOULDBLOCK)
_dbus_verbose ("WSAWaitForMultipleEvents: failed: %s\n", _dbus_strerror_ from_errno ()); _dbus_verbose ("WSAWaitForMultipleEvents: failed: %s\n", _dbus_strerror_ from_errno ());
ret = -1; ret = -1;
} }
else if (ready == WSA_WAIT_TIMEOUT) else if (ready == WSA_WAIT_TIMEOUT)
{ {
_dbus_verbose ("WSAWaitForMultipleEvents: WSA_WAIT_TIMEOUT\n"); _dbus_verbose ("WSAWaitForMultipleEvents: WSA_WAIT_TIMEOUT\n");
ret = 0; ret = 0;
} }
else if (ready >= WSA_WAIT_EVENT_0 && ready < (int)(WSA_WAIT_EVENT_0 + n_fds)) else if (ready < (WSA_WAIT_EVENT_0 + n_fds))
{ {
msgp = msg;
msgp += sprintf (msgp, "WSAWaitForMultipleEvents: =%d\n\t", ready);
for (i = 0; i < n_fds; i++) for (i = 0; i < n_fds; i++)
{ {
DBusPollFD *fdp = &fds[i]; DBusPollFD *fdp = &fds[i];
WSANETWORKEVENTS ne; WSANETWORKEVENTS ne;
fdp->revents = 0; fdp->revents = 0;
WSAEnumNetworkEvents(fdp->fd.sock, pEvents[i], &ne); WSAEnumNetworkEvents (fdp->fd.sock, pEvents[i], &ne);
if (ne.lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE)) if (ne.lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE))
fdp->revents |= _DBUS_POLLIN; fdp->revents |= _DBUS_POLLIN;
if (ne.lNetworkEvents & (FD_WRITE | FD_CONNECT)) if (ne.lNetworkEvents & (FD_WRITE | FD_CONNECT))
fdp->revents |= _DBUS_POLLOUT; fdp->revents |= _DBUS_POLLOUT;
if (ne.lNetworkEvents & (FD_OOB)) if (ne.lNetworkEvents & (FD_OOB))
fdp->revents |= _DBUS_POLLERR; fdp->revents |= _DBUS_POLLERR;
if (ne.lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE))
msgp += sprintf (msgp, "R:%Iu ", fdp->fd.sock);
if (ne.lNetworkEvents & (FD_WRITE | FD_CONNECT))
msgp += sprintf (msgp, "W:%Iu ", fdp->fd.sock);
if (ne.lNetworkEvents & (FD_OOB))
msgp += sprintf (msgp, "E:%Iu ", fdp->fd.sock);
msgp += sprintf (msgp, "lNetworkEvents:%d ", ne.lNetworkEvents);
if(ne.lNetworkEvents) if(ne.lNetworkEvents)
ret++; ret++;
WSAEventSelect(fdp->fd.sock, pEvents[i], 0); WSAEventSelect (fdp->fd.sock, pEvents[i], 0);
} }
#ifdef DBUS_ENABLE_VERBOSE_MODE
msgp += sprintf (msgp, "\n"); _dbus_verbose ("_dbus_poll: to=%d", timeout_milliseconds);
_dbus_verbose ("%s",msg); if (!_dbus_dump_fd_revents (fds, n_fds))
{
_dbus_win_set_errno (ENOMEM);
ret = -1;
goto oom;
}
#endif
} }
else else
{ {
_dbus_verbose ("WSAWaitForMultipleEvents: failed for unknown reason!"); _dbus_verbose ("WSAWaitForMultipleEvents: failed for unknown reason!");
ret = -1; ret = -1;
} }
for(i = 0; i < n_fds; i++) oom:
if (pEvents != NULL)
{ {
WSACloseEvent(pEvents[i]); for (i = 0; i < n_fds; i++)
{
if (pEvents[i] != WSA_INVALID_EVENT)
WSACloseEvent (pEvents[i]);
}
if (n_fds > DBUS_STACK_WSAEVENTS)
free (pEvents);
} }
if (n_fds > DBUS_STACK_WSAEVENTS)
free(pEvents);
return ret; return ret;
}
#else /* USE_CHRIS_IMPL */ #else
/**
#ifdef DBUS_ENABLE_VERBOSE_MODE * Select based implementation for _dbus_poll().
#define DBUS_POLL_CHAR_BUFFER_SIZE 2000 *
char msg[DBUS_POLL_CHAR_BUFFER_SIZE]; * @param fds the file descriptors to poll
char *msgp; * @param n_fds number of descriptors in the array
#endif * @param timeout_milliseconds timeout or -1 for infinite
* @returns numbers of fds with revents, or <0 on error
*/
static int
_dbus_poll_select (DBusPollFD *fds,
int n_fds,
int timeout_milliseconds)
{
fd_set read_set, write_set, err_set; fd_set read_set, write_set, err_set;
SOCKET max_fd = 0; SOCKET max_fd = 0;
int i; int i;
struct timeval tv; struct timeval tv;
int ready; int ready;
FD_ZERO (&read_set); FD_ZERO (&read_set);
FD_ZERO (&write_set); FD_ZERO (&write_set);
FD_ZERO (&err_set); FD_ZERO (&err_set);
#ifdef DBUS_ENABLE_VERBOSE_MODE #ifdef DBUS_ENABLE_VERBOSE_MODE
msgp = msg; _dbus_verbose("_dbus_poll: to=%d", timeout_milliseconds);
msgp += sprintf (msgp, "select: to=%d\n\t", timeout_milliseconds); if (!_dbus_dump_fd_events (fds, n_fds))
for (i = 0; i < n_fds; i++)
{ {
DBusPollFD *fdp = &fds[i]; ready = -1;
goto oom;
if (fdp->events & _DBUS_POLLIN)
msgp += sprintf (msgp, "R:%Iu ", fdp->fd.sock);
if (fdp->events & _DBUS_POLLOUT)
msgp += sprintf (msgp, "W:%Iu ", fdp->fd.sock);
msgp += sprintf (msgp, "E:%Iu\n\t", fdp->fd.sock);
// FIXME: more robust code for long msg
// create on heap when msg[] becomes too small
if (msgp >= msg + DBUS_POLL_CHAR_BUFFER_SIZE)
{
_dbus_assert_not_reached ("buffer overflow in _dbus_poll");
}
} }
msgp += sprintf (msgp, "\n");
_dbus_verbose ("%s",msg);
#endif #endif
for (i = 0; i < n_fds; i++) for (i = 0; i < n_fds; i++)
{ {
DBusPollFD *fdp = &fds[i]; DBusPollFD *fdp = &fds[i];
if (fdp->events & _DBUS_POLLIN) if (fdp->events & _DBUS_POLLIN)
FD_SET (fdp->fd.sock, &read_set); FD_SET (fdp->fd.sock, &read_set);
if (fdp->events & _DBUS_POLLOUT) if (fdp->events & _DBUS_POLLOUT)
FD_SET (fdp->fd.sock, &write_set); FD_SET (fdp->fd.sock, &write_set);
skipping to change at line 1369 skipping to change at line 1453
DBUS_SOCKET_SET_ERRNO (); DBUS_SOCKET_SET_ERRNO ();
if (errno != WSAEWOULDBLOCK) if (errno != WSAEWOULDBLOCK)
_dbus_verbose ("select: failed: %s\n", _dbus_strerror_from_errno ()); _dbus_verbose ("select: failed: %s\n", _dbus_strerror_from_errno ());
} }
else if (ready == 0) else if (ready == 0)
_dbus_verbose ("select: = 0\n"); _dbus_verbose ("select: = 0\n");
else else
if (ready > 0) if (ready > 0)
{ {
#ifdef DBUS_ENABLE_VERBOSE_MODE #ifdef DBUS_ENABLE_VERBOSE_MODE
msgp = msg; _dbus_verbose ("select: to=%d\n", ready);
msgp += sprintf (msgp, "select: = %d:\n\t", ready); if (!_dbus_dump_fdset (fds, n_fds, &read_set, &write_set, &err_set))
for (i = 0; i < n_fds; i++)
{ {
DBusPollFD *fdp = &fds[i]; _dbus_win_set_errno (ENOMEM);
ready = -1;
if (FD_ISSET (fdp->fd.sock, &read_set)) goto oom;
msgp += sprintf (msgp, "R:%Iu ", fdp->fd.sock);
if (FD_ISSET (fdp->fd.sock, &write_set))
msgp += sprintf (msgp, "W:%Iu ", fdp->fd.sock);
if (FD_ISSET (fdp->fd.sock, &err_set))
msgp += sprintf (msgp, "E:%Iu\n\t", fdp->fd.sock);
} }
msgp += sprintf (msgp, "\n");
_dbus_verbose ("%s",msg);
#endif #endif
for (i = 0; i < n_fds; i++) for (i = 0; i < n_fds; i++)
{ {
DBusPollFD *fdp = &fds[i]; DBusPollFD *fdp = &fds[i];
fdp->revents = 0; fdp->revents = 0;
if (FD_ISSET (fdp->fd.sock, &read_set)) if (FD_ISSET (fdp->fd.sock, &read_set))
fdp->revents |= _DBUS_POLLIN; fdp->revents |= _DBUS_POLLIN;
if (FD_ISSET (fdp->fd.sock, &write_set)) if (FD_ISSET (fdp->fd.sock, &write_set))
fdp->revents |= _DBUS_POLLOUT; fdp->revents |= _DBUS_POLLOUT;
if (FD_ISSET (fdp->fd.sock, &err_set)) if (FD_ISSET (fdp->fd.sock, &err_set))
fdp->revents |= _DBUS_POLLERR; fdp->revents |= _DBUS_POLLERR;
} }
} }
oom:
return ready; return ready;
#endif /* USE_CHRIS_IMPL */ }
#endif
/**
* Wrapper for poll().
*
* @param fds the file descriptors to poll
* @param n_fds number of descriptors in the array
* @param timeout_milliseconds timeout or -1 for infinite
* @returns numbers of fds with revents, or <0 on error
*/
int
_dbus_poll (DBusPollFD *fds,
int n_fds,
int timeout_milliseconds)
{
#ifdef USE_CHRIS_IMPL
return _dbus_poll_events (fds, n_fds, timeout_milliseconds);
#else
return _dbus_poll_select (fds, n_fds, timeout_milliseconds);
#endif
} }
/****************************************************************************** /******************************************************************************
Original CVS version of dbus-sysdeps.c Original CVS version of dbus-sysdeps.c
******************************************************************************/ ******************************************************************************/
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/* dbus-sysdeps.c Wrappers around system/libc features (internal to D-Bus implem entation) /* dbus-sysdeps.c Wrappers around system/libc features (internal to D-Bus implem entation)
* *
skipping to change at line 3135 skipping to change at line 3228
goto out; goto out;
} }
if (!SearchPathA(NULL, daemon_name, NULL, sizeof(dbus_exe_path), dbus_exe_path , &lpFile)) if (!SearchPathA(NULL, daemon_name, NULL, sizeof(dbus_exe_path), dbus_exe_path , &lpFile))
{ {
// Look in directory containing dbus shared library // Look in directory containing dbus shared library
HMODULE hmod; HMODULE hmod;
char dbus_module_path[MAX_PATH]; char dbus_module_path[MAX_PATH];
DWORD rc; DWORD rc;
_dbus_verbose( "did not found dbus daemon executable on default search pat _dbus_verbose ("did not found dbus daemon executable on default search pat
h, " h, "
"trying path where dbus shared library is located"); "trying path where dbus shared library is located");
hmod = _dbus_win_get_dll_hmodule(); hmod = _dbus_win_get_dll_hmodule ();
rc = GetModuleFileNameA(hmod, dbus_module_path, sizeof(dbus_module_path)); rc = GetModuleFileNameA (hmod, dbus_module_path, sizeof(dbus_module_path))
;
if (rc <= 0) if (rc <= 0)
{ {
dbus_set_error_const (error, DBUS_ERROR_FAILED, "could not retrieve db us shared library file name"); dbus_set_error_const (error, DBUS_ERROR_FAILED, "could not retrieve db us shared library file name");
retval = FALSE; retval = FALSE;
goto out; goto out;
} }
else else
{ {
char *ext_idx = strrchr(dbus_module_path, '\\'); char *ext_idx = strrchr (dbus_module_path, '\\');
if (ext_idx) if (ext_idx)
*ext_idx = '\0'; *ext_idx = '\0';
if (!SearchPathA(dbus_module_path, daemon_name, NULL, sizeof(dbus_exe_ path), dbus_exe_path, &lpFile)) if (!SearchPathA (dbus_module_path, daemon_name, NULL, sizeof(dbus_exe _path), dbus_exe_path, &lpFile))
{ {
dbus_set_error_const (error, DBUS_ERROR_FAILED, "could not find db dbus_set_error (error, DBUS_ERROR_FAILED,
us-daemon executable"); "Could not find dbus-daemon executable. "
"Please add the path to %s to your PATH "
"environment variable or start the daemon manually
",
daemon_name);
retval = FALSE; retval = FALSE;
fprintf (stderr, "please add the path to %s to your PATH environme
nt variable\n", daemon_name);
fprintf (stderr, "or start the daemon manually\n\n");
goto out; goto out;
} }
_dbus_verbose( "found dbus daemon executable at %s",dbus_module_path); _dbus_verbose ("found dbus daemon executable at %s", dbus_module_path) ;
} }
} }
// Create process // Create process
ZeroMemory( &si, sizeof(si) ); ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si); si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) ); ZeroMemory( &pi, sizeof(pi) );
_snprintf(dbus_args, sizeof(dbus_args) - 1, "\"%s\" %s", dbus_exe_path, " --s ession"); _snprintf(dbus_args, sizeof(dbus_args) - 1, "\"%s\" %s", dbus_exe_path, " --s ession");
skipping to change at line 3810 skipping to change at line 3905
{ {
case DBUS_SYSTEM_LOG_INFO: s = "info"; break; case DBUS_SYSTEM_LOG_INFO: s = "info"; break;
case DBUS_SYSTEM_LOG_WARNING: s = "warning"; break; case DBUS_SYSTEM_LOG_WARNING: s = "warning"; break;
case DBUS_SYSTEM_LOG_SECURITY: s = "security"; break; case DBUS_SYSTEM_LOG_SECURITY: s = "security"; break;
case DBUS_SYSTEM_LOG_ERROR: s = "error"; break; case DBUS_SYSTEM_LOG_ERROR: s = "error"; break;
default: _dbus_assert_not_reached ("invalid log severity"); default: _dbus_assert_not_reached ("invalid log severity");
} }
if (log_flags & DBUS_LOG_FLAGS_SYSTEM_LOG) if (log_flags & DBUS_LOG_FLAGS_SYSTEM_LOG)
{ {
char buf[1024]; DBusString out = _DBUS_STRING_INIT_INVALID;
char format[1024]; const char *message = NULL;
DBUS_VA_COPY (tmp, args); DBUS_VA_COPY (tmp, args);
snprintf (format, sizeof (format), "%s: %s", s, msg);
vsnprintf(buf, sizeof(buf), format, tmp); if (!_dbus_string_init (&out))
OutputDebugStringA(buf); goto out;
if (!_dbus_string_append_printf (&out, "%s: ", s))
goto out;
if (!_dbus_string_append_printf_valist (&out, msg, tmp))
goto out;
message = _dbus_string_get_const_data (&out);
out:
if (message != NULL)
{
OutputDebugStringA (message);
}
else
{
OutputDebugStringA ("Out of memory while formatting message: '''");
OutputDebugStringA (msg);
OutputDebugStringA ("'''");
}
va_end (tmp); va_end (tmp);
_dbus_string_free (&out);
} }
if (log_flags & DBUS_LOG_FLAGS_STDERR) if (log_flags & DBUS_LOG_FLAGS_STDERR)
{ {
DBUS_VA_COPY (tmp, args); DBUS_VA_COPY (tmp, args);
fprintf (stderr, "%s[%lu]: %s: ", log_tag, _dbus_pid_for_log (), s); fprintf (stderr, "%s[%lu]: %s: ", log_tag, _dbus_pid_for_log (), s);
vfprintf (stderr, msg, tmp); vfprintf (stderr, msg, tmp);
fprintf (stderr, "\n"); fprintf (stderr, "\n");
va_end (tmp); va_end (tmp);
} }
 End of changes. 44 change blocks. 
133 lines changed or deleted 246 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)