| Current File : //usr/share/doc/dbus/api/dbus-transport-unix_8c_source.html |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>D-Bus: dbus-transport-unix.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">D-Bus
 <span id="projectnumber">1.8.20</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.7.6.1 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File List</span></a></li>
</ul>
</div>
</div>
<div class="header">
<div class="headertitle">
<div class="title">dbus-transport-unix.c</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */</span>
<a name="l00002"></a>00002 <span class="comment">/* dbus-transport-unix.c UNIX socket subclasses of DBusTransport</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2002, 2003, 2004 Red Hat Inc.</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * Licensed under the Academic Free License version 2.1</span>
<a name="l00007"></a>00007 <span class="comment"> * </span>
<a name="l00008"></a>00008 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00009"></a>00009 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00010"></a>00010 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00011"></a>00011 <span class="comment"> * (at your option) any later version.</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00014"></a>00014 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00015"></a>00015 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00016"></a>00016 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00017"></a>00017 <span class="comment"> * </span>
<a name="l00018"></a>00018 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00019"></a>00019 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00020"></a>00020 <span class="comment"> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA</span>
<a name="l00021"></a>00021 <span class="comment"> *</span>
<a name="l00022"></a>00022 <span class="comment"> */</span>
<a name="l00023"></a>00023
<a name="l00024"></a>00024 <span class="preprocessor">#include <config.h></span>
<a name="l00025"></a>00025
<a name="l00026"></a>00026 <span class="preprocessor">#include <stdio.h></span>
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="preprocessor">#include "dbus-internals.h"</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include "dbus-connection-internal.h"</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include "dbus-transport-unix.h"</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include "dbus-transport-socket.h"</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include "dbus-transport-protected.h"</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include "dbus-watch.h"</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include "dbus-sysdeps-unix.h"</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include "dbus-test.h"</span>
<a name="l00036"></a>00036
<a name="l00057"></a>00057 <a class="code" href="structDBusTransport.html" title="Object representing a transport such as a socket.">DBusTransport</a>*
<a name="l00058"></a><a class="code" href="group__DBusTransportUnix.html#gada3df30a229b4d29ccf30af83bd88fcc">00058</a> <a class="code" href="group__DBusTransportUnix.html#gada3df30a229b4d29ccf30af83bd88fcc" title="Creates a new transport for the given Unix domain socket path.">_dbus_transport_new_for_domain_socket</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> *path,
<a name="l00059"></a>00059 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> <span class="keyword">abstract</span>,
<a name="l00060"></a>00060 <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a> *error)
<a name="l00061"></a>00061 {
<a name="l00062"></a>00062 <span class="keywordtype">int</span> fd;
<a name="l00063"></a>00063 <a class="code" href="structDBusTransport.html" title="Object representing a transport such as a socket.">DBusTransport</a> *transport;
<a name="l00064"></a>00064 <a class="code" href="structDBusString.html">DBusString</a> address;
<a name="l00065"></a>00065
<a name="l00066"></a>00066 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
<a name="l00067"></a>00067
<a name="l00068"></a>00068 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&address))
<a name="l00069"></a>00069 {
<a name="l00070"></a>00070 <a class="code" href="group__DBusErrors.html#ga89d2ad4bde21f9e0057fac07a79885e3" title="Assigns an error name and message to a DBusError.">dbus_set_error</a> (error, <a class="code" href="group__DBusProtocol.html#gac32eaf0b92f798307853cd4fe0cf11c2" title="There was not enough memory to complete an operation.">DBUS_ERROR_NO_MEMORY</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00071"></a>00071 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00072"></a>00072 }
<a name="l00073"></a>00073
<a name="l00074"></a>00074 fd = -1;
<a name="l00075"></a>00075
<a name="l00076"></a>00076 <span class="keywordflow">if</span> ((<span class="keyword">abstract</span> &&
<a name="l00077"></a>00077 !<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&address, <span class="stringliteral">"unix:abstract="</span>)) ||
<a name="l00078"></a>00078 (!<span class="keyword">abstract</span> &&
<a name="l00079"></a>00079 !<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&address, <span class="stringliteral">"unix:path="</span>)) ||
<a name="l00080"></a>00080 !<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&address, path))
<a name="l00081"></a>00081 {
<a name="l00082"></a>00082 <a class="code" href="group__DBusErrors.html#ga89d2ad4bde21f9e0057fac07a79885e3" title="Assigns an error name and message to a DBusError.">dbus_set_error</a> (error, <a class="code" href="group__DBusProtocol.html#gac32eaf0b92f798307853cd4fe0cf11c2" title="There was not enough memory to complete an operation.">DBUS_ERROR_NO_MEMORY</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00083"></a>00083 <span class="keywordflow">goto</span> failed_0;
<a name="l00084"></a>00084 }
<a name="l00085"></a>00085
<a name="l00086"></a>00086 fd = <a class="code" href="group__DBusSysdepsUnix.html#ga0228009923a105d50a0849b24acbc31e" title="Creates a socket and connects it to the UNIX domain socket at the given path.">_dbus_connect_unix_socket</a> (path, <span class="keyword">abstract</span>, error);
<a name="l00087"></a>00087 <span class="keywordflow">if</span> (fd < 0)
<a name="l00088"></a>00088 {
<a name="l00089"></a>00089 _DBUS_ASSERT_ERROR_IS_SET (error);
<a name="l00090"></a>00090 <span class="keywordflow">goto</span> failed_0;
<a name="l00091"></a>00091 }
<a name="l00092"></a>00092
<a name="l00093"></a>00093 _dbus_verbose (<span class="stringliteral">"Successfully connected to unix socket %s\n"</span>,
<a name="l00094"></a>00094 path);
<a name="l00095"></a>00095
<a name="l00096"></a>00096 transport = <a class="code" href="group__DBusTransportSocket.html#gac714eaa33ff4ab5c01be1304b23339a7" title="Creates a new transport for the given socket file descriptor.">_dbus_transport_new_for_socket</a> (fd, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, &address);
<a name="l00097"></a>00097 <span class="keywordflow">if</span> (transport == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00098"></a>00098 {
<a name="l00099"></a>00099 <a class="code" href="group__DBusErrors.html#ga89d2ad4bde21f9e0057fac07a79885e3" title="Assigns an error name and message to a DBusError.">dbus_set_error</a> (error, <a class="code" href="group__DBusProtocol.html#gac32eaf0b92f798307853cd4fe0cf11c2" title="There was not enough memory to complete an operation.">DBUS_ERROR_NO_MEMORY</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00100"></a>00100 <span class="keywordflow">goto</span> failed_1;
<a name="l00101"></a>00101 }
<a name="l00102"></a>00102
<a name="l00103"></a>00103 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&address);
<a name="l00104"></a>00104
<a name="l00105"></a>00105 <span class="keywordflow">return</span> transport;
<a name="l00106"></a>00106
<a name="l00107"></a>00107 failed_1:
<a name="l00108"></a>00108 <a class="code" href="group__DBusSysdeps.html#ga701f9b3087c196404f66ff95b4ace0b8" title="Closes a socket.">_dbus_close_socket</a> (fd, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00109"></a>00109 failed_0:
<a name="l00110"></a>00110 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&address);
<a name="l00111"></a>00111 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00112"></a>00112 }
<a name="l00113"></a>00113
<a name="l00125"></a>00125 <span class="keyword">static</span> <a class="code" href="structDBusTransport.html" title="Object representing a transport such as a socket.">DBusTransport</a>*
<a name="l00126"></a>00126 _dbus_transport_new_for_exec (<span class="keyword">const</span> <span class="keywordtype">char</span> *path,
<a name="l00127"></a>00127 <span class="keywordtype">char</span> *<span class="keyword">const</span> argv[],
<a name="l00128"></a>00128 <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a> *error)
<a name="l00129"></a>00129 {
<a name="l00130"></a>00130 <span class="keywordtype">int</span> fd;
<a name="l00131"></a>00131 <a class="code" href="structDBusTransport.html" title="Object representing a transport such as a socket.">DBusTransport</a> *transport;
<a name="l00132"></a>00132 <a class="code" href="structDBusString.html">DBusString</a> address;
<a name="l00133"></a>00133 <span class="keywordtype">unsigned</span> i;
<a name="l00134"></a>00134 <span class="keywordtype">char</span> *escaped;
<a name="l00135"></a>00135
<a name="l00136"></a>00136 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
<a name="l00137"></a>00137
<a name="l00138"></a>00138 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&address))
<a name="l00139"></a>00139 {
<a name="l00140"></a>00140 <a class="code" href="group__DBusErrors.html#ga89d2ad4bde21f9e0057fac07a79885e3" title="Assigns an error name and message to a DBusError.">dbus_set_error</a> (error, <a class="code" href="group__DBusProtocol.html#gac32eaf0b92f798307853cd4fe0cf11c2" title="There was not enough memory to complete an operation.">DBUS_ERROR_NO_MEMORY</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00141"></a>00141 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00142"></a>00142 }
<a name="l00143"></a>00143
<a name="l00144"></a>00144 fd = -1;
<a name="l00145"></a>00145
<a name="l00146"></a>00146 escaped = <a class="code" href="group__DBusAddress.html#ga818e79423595cd2a306ec1b4dc1ab7f5" title="Escapes the given string as a value in a key=value pair for a D-Bus address.">dbus_address_escape_value</a> (path);
<a name="l00147"></a>00147 <span class="keywordflow">if</span> (!escaped)
<a name="l00148"></a>00148 {
<a name="l00149"></a>00149 <a class="code" href="group__DBusErrors.html#ga89d2ad4bde21f9e0057fac07a79885e3" title="Assigns an error name and message to a DBusError.">dbus_set_error</a> (error, <a class="code" href="group__DBusProtocol.html#gac32eaf0b92f798307853cd4fe0cf11c2" title="There was not enough memory to complete an operation.">DBUS_ERROR_NO_MEMORY</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00150"></a>00150 <span class="keywordflow">goto</span> failed;
<a name="l00151"></a>00151 }
<a name="l00152"></a>00152
<a name="l00153"></a>00153 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&address, <span class="stringliteral">"unixexec:path="</span>) ||
<a name="l00154"></a>00154 !<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&address, escaped))
<a name="l00155"></a>00155 {
<a name="l00156"></a>00156 <a class="code" href="group__DBusErrors.html#ga89d2ad4bde21f9e0057fac07a79885e3" title="Assigns an error name and message to a DBusError.">dbus_set_error</a> (error, <a class="code" href="group__DBusProtocol.html#gac32eaf0b92f798307853cd4fe0cf11c2" title="There was not enough memory to complete an operation.">DBUS_ERROR_NO_MEMORY</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00157"></a>00157 <a class="code" href="group__DBusMemory.html#ga34e666b19b015035a9a31e53da84b39a" title="Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().">dbus_free</a> (escaped);
<a name="l00158"></a>00158 <span class="keywordflow">goto</span> failed;
<a name="l00159"></a>00159 }
<a name="l00160"></a>00160
<a name="l00161"></a>00161 <a class="code" href="group__DBusMemory.html#ga34e666b19b015035a9a31e53da84b39a" title="Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().">dbus_free</a> (escaped);
<a name="l00162"></a>00162
<a name="l00163"></a>00163 <span class="keywordflow">if</span> (argv)
<a name="l00164"></a>00164 {
<a name="l00165"></a>00165 <span class="keywordflow">for</span> (i = 0; argv[i]; i++)
<a name="l00166"></a>00166 {
<a name="l00167"></a>00167 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> success;
<a name="l00168"></a>00168
<a name="l00169"></a>00169 escaped = <a class="code" href="group__DBusAddress.html#ga818e79423595cd2a306ec1b4dc1ab7f5" title="Escapes the given string as a value in a key=value pair for a D-Bus address.">dbus_address_escape_value</a> (argv[i]);
<a name="l00170"></a>00170 <span class="keywordflow">if</span> (!escaped)
<a name="l00171"></a>00171 {
<a name="l00172"></a>00172 <a class="code" href="group__DBusErrors.html#ga89d2ad4bde21f9e0057fac07a79885e3" title="Assigns an error name and message to a DBusError.">dbus_set_error</a> (error, <a class="code" href="group__DBusProtocol.html#gac32eaf0b92f798307853cd4fe0cf11c2" title="There was not enough memory to complete an operation.">DBUS_ERROR_NO_MEMORY</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00173"></a>00173 <span class="keywordflow">goto</span> failed;
<a name="l00174"></a>00174 }
<a name="l00175"></a>00175
<a name="l00176"></a>00176 success = <a class="code" href="group__DBusString.html#gab0078cf7e0e5bd784ec6d6e0cc3923a2" title="Appends a printf-style formatted string to the DBusString.">_dbus_string_append_printf</a> (&address, <span class="stringliteral">",argv%u=%s"</span>, i, escaped);
<a name="l00177"></a>00177 <a class="code" href="group__DBusMemory.html#ga34e666b19b015035a9a31e53da84b39a" title="Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().">dbus_free</a> (escaped);
<a name="l00178"></a>00178
<a name="l00179"></a>00179 <span class="keywordflow">if</span> (!success)
<a name="l00180"></a>00180 {
<a name="l00181"></a>00181 <a class="code" href="group__DBusErrors.html#ga89d2ad4bde21f9e0057fac07a79885e3" title="Assigns an error name and message to a DBusError.">dbus_set_error</a> (error, <a class="code" href="group__DBusProtocol.html#gac32eaf0b92f798307853cd4fe0cf11c2" title="There was not enough memory to complete an operation.">DBUS_ERROR_NO_MEMORY</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00182"></a>00182 <span class="keywordflow">goto</span> failed;
<a name="l00183"></a>00183 }
<a name="l00184"></a>00184 }
<a name="l00185"></a>00185 }
<a name="l00186"></a>00186
<a name="l00187"></a>00187 fd = <a class="code" href="group__DBusSysdepsUnix.html#gab9a5fd9662ae1ee18598d1736def70ea" title="Creates a UNIX domain socket and connects it to the specified process to execute.">_dbus_connect_exec</a> (path, argv, error);
<a name="l00188"></a>00188 <span class="keywordflow">if</span> (fd < 0)
<a name="l00189"></a>00189 {
<a name="l00190"></a>00190 _DBUS_ASSERT_ERROR_IS_SET (error);
<a name="l00191"></a>00191 <span class="keywordflow">goto</span> failed;
<a name="l00192"></a>00192 }
<a name="l00193"></a>00193
<a name="l00194"></a>00194 _dbus_verbose (<span class="stringliteral">"Successfully connected to process %s\n"</span>,
<a name="l00195"></a>00195 path);
<a name="l00196"></a>00196
<a name="l00197"></a>00197 transport = <a class="code" href="group__DBusTransportSocket.html#gac714eaa33ff4ab5c01be1304b23339a7" title="Creates a new transport for the given socket file descriptor.">_dbus_transport_new_for_socket</a> (fd, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, &address);
<a name="l00198"></a>00198 <span class="keywordflow">if</span> (transport == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00199"></a>00199 {
<a name="l00200"></a>00200 <a class="code" href="group__DBusErrors.html#ga89d2ad4bde21f9e0057fac07a79885e3" title="Assigns an error name and message to a DBusError.">dbus_set_error</a> (error, <a class="code" href="group__DBusProtocol.html#gac32eaf0b92f798307853cd4fe0cf11c2" title="There was not enough memory to complete an operation.">DBUS_ERROR_NO_MEMORY</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00201"></a>00201 <span class="keywordflow">goto</span> failed;
<a name="l00202"></a>00202 }
<a name="l00203"></a>00203
<a name="l00204"></a>00204 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&address);
<a name="l00205"></a>00205
<a name="l00206"></a>00206 <span class="keywordflow">return</span> transport;
<a name="l00207"></a>00207
<a name="l00208"></a>00208 failed:
<a name="l00209"></a>00209 <span class="keywordflow">if</span> (fd >= 0)
<a name="l00210"></a>00210 <a class="code" href="group__DBusSysdeps.html#ga701f9b3087c196404f66ff95b4ace0b8" title="Closes a socket.">_dbus_close_socket</a> (fd, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00211"></a>00211
<a name="l00212"></a>00212 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&address);
<a name="l00213"></a>00213 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00214"></a>00214 }
<a name="l00215"></a>00215
<a name="l00224"></a>00224 DBusTransportOpenResult
<a name="l00225"></a><a class="code" href="group__DBusTransportUnix.html#gafd694944860033155276df9162bdf72e">00225</a> <a class="code" href="group__DBusTransportUnix.html#gafd694944860033155276df9162bdf72e" title="Opens platform specific transport types.">_dbus_transport_open_platform_specific</a> (<a class="code" href="structDBusAddressEntry.html" title="Internals of DBusAddressEntry.">DBusAddressEntry</a> *entry,
<a name="l00226"></a>00226 <a class="code" href="structDBusTransport.html" title="Object representing a transport such as a socket.">DBusTransport</a> **transport_p,
<a name="l00227"></a>00227 <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a> *error)
<a name="l00228"></a>00228 {
<a name="l00229"></a>00229 <span class="keyword">const</span> <span class="keywordtype">char</span> *method;
<a name="l00230"></a>00230
<a name="l00231"></a>00231 method = <a class="code" href="group__DBusAddress.html#ga7e6b2572d6e637826acada01377b5487" title="Returns the method string of an address entry.">dbus_address_entry_get_method</a> (entry);
<a name="l00232"></a>00232 _dbus_assert (method != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00233"></a>00233
<a name="l00234"></a>00234 <span class="keywordflow">if</span> (strcmp (method, <span class="stringliteral">"unix"</span>) == 0)
<a name="l00235"></a>00235 {
<a name="l00236"></a>00236 <span class="keyword">const</span> <span class="keywordtype">char</span> *path = <a class="code" href="group__DBusAddress.html#gae6f014689b49099e835b1f97d032034e" title="Returns a value from a key of an entry.">dbus_address_entry_get_value</a> (entry, <span class="stringliteral">"path"</span>);
<a name="l00237"></a>00237 <span class="keyword">const</span> <span class="keywordtype">char</span> *tmpdir = <a class="code" href="group__DBusAddress.html#gae6f014689b49099e835b1f97d032034e" title="Returns a value from a key of an entry.">dbus_address_entry_get_value</a> (entry, <span class="stringliteral">"tmpdir"</span>);
<a name="l00238"></a>00238 <span class="keyword">const</span> <span class="keywordtype">char</span> *<span class="keyword">abstract</span> = <a class="code" href="group__DBusAddress.html#gae6f014689b49099e835b1f97d032034e" title="Returns a value from a key of an entry.">dbus_address_entry_get_value</a> (entry, <span class="stringliteral">"abstract"</span>);
<a name="l00239"></a>00239
<a name="l00240"></a>00240 <span class="keywordflow">if</span> (tmpdir != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00241"></a>00241 {
<a name="l00242"></a>00242 <a class="code" href="group__DBusAddressInternals.html#ga5b6409826263c7d62570c56889f7ddb2" title="Sets DBUS_ERROR_BAD_ADDRESS.">_dbus_set_bad_address</a> (error, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>,
<a name="l00243"></a>00243 <span class="stringliteral">"cannot use the \"tmpdir\" option for an address to connect to, only in an address to listen on"</span>);
<a name="l00244"></a>00244 <span class="keywordflow">return</span> DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
<a name="l00245"></a>00245 }
<a name="l00246"></a>00246
<a name="l00247"></a>00247 <span class="keywordflow">if</span> (path == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a> && <span class="keyword">abstract</span> == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00248"></a>00248 {
<a name="l00249"></a>00249 <a class="code" href="group__DBusAddressInternals.html#ga5b6409826263c7d62570c56889f7ddb2" title="Sets DBUS_ERROR_BAD_ADDRESS.">_dbus_set_bad_address</a> (error, <span class="stringliteral">"unix"</span>,
<a name="l00250"></a>00250 <span class="stringliteral">"path or abstract"</span>,
<a name="l00251"></a>00251 <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00252"></a>00252 <span class="keywordflow">return</span> DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
<a name="l00253"></a>00253 }
<a name="l00254"></a>00254
<a name="l00255"></a>00255 <span class="keywordflow">if</span> (path != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a> && <span class="keyword">abstract</span> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00256"></a>00256 {
<a name="l00257"></a>00257 <a class="code" href="group__DBusAddressInternals.html#ga5b6409826263c7d62570c56889f7ddb2" title="Sets DBUS_ERROR_BAD_ADDRESS.">_dbus_set_bad_address</a> (error, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>,
<a name="l00258"></a>00258 <span class="stringliteral">"can't specify both \"path\" and \"abstract\" options in an address"</span>);
<a name="l00259"></a>00259 <span class="keywordflow">return</span> DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
<a name="l00260"></a>00260 }
<a name="l00261"></a>00261
<a name="l00262"></a>00262 <span class="keywordflow">if</span> (path)
<a name="l00263"></a>00263 *transport_p = <a class="code" href="group__DBusTransportUnix.html#gada3df30a229b4d29ccf30af83bd88fcc" title="Creates a new transport for the given Unix domain socket path.">_dbus_transport_new_for_domain_socket</a> (path, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>,
<a name="l00264"></a>00264 error);
<a name="l00265"></a>00265 <span class="keywordflow">else</span>
<a name="l00266"></a>00266 *transport_p = <a class="code" href="group__DBusTransportUnix.html#gada3df30a229b4d29ccf30af83bd88fcc" title="Creates a new transport for the given Unix domain socket path.">_dbus_transport_new_for_domain_socket</a> (<span class="keyword">abstract</span>, <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>,
<a name="l00267"></a>00267 error);
<a name="l00268"></a>00268 <span class="keywordflow">if</span> (*transport_p == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00269"></a>00269 {
<a name="l00270"></a>00270 _DBUS_ASSERT_ERROR_IS_SET (error);
<a name="l00271"></a>00271 <span class="keywordflow">return</span> DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
<a name="l00272"></a>00272 }
<a name="l00273"></a>00273 <span class="keywordflow">else</span>
<a name="l00274"></a>00274 {
<a name="l00275"></a>00275 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
<a name="l00276"></a>00276 <span class="keywordflow">return</span> DBUS_TRANSPORT_OPEN_OK;
<a name="l00277"></a>00277 }
<a name="l00278"></a>00278 }
<a name="l00279"></a>00279 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp (method, <span class="stringliteral">"unixexec"</span>) == 0)
<a name="l00280"></a>00280 {
<a name="l00281"></a>00281 <span class="keyword">const</span> <span class="keywordtype">char</span> *path;
<a name="l00282"></a>00282 <span class="keywordtype">unsigned</span> i;
<a name="l00283"></a>00283 <span class="keywordtype">char</span> **argv;
<a name="l00284"></a>00284
<a name="l00285"></a>00285 path = <a class="code" href="group__DBusAddress.html#gae6f014689b49099e835b1f97d032034e" title="Returns a value from a key of an entry.">dbus_address_entry_get_value</a> (entry, <span class="stringliteral">"path"</span>);
<a name="l00286"></a>00286 <span class="keywordflow">if</span> (path == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00287"></a>00287 {
<a name="l00288"></a>00288 <a class="code" href="group__DBusAddressInternals.html#ga5b6409826263c7d62570c56889f7ddb2" title="Sets DBUS_ERROR_BAD_ADDRESS.">_dbus_set_bad_address</a> (error, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>,
<a name="l00289"></a>00289 <span class="stringliteral">"No process path specified"</span>);
<a name="l00290"></a>00290 <span class="keywordflow">return</span> DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
<a name="l00291"></a>00291 }
<a name="l00292"></a>00292
<a name="l00293"></a>00293 <span class="comment">/* First count argv arguments */</span>
<a name="l00294"></a>00294 <span class="keywordflow">for</span> (i = 1; ; i++)
<a name="l00295"></a>00295 {
<a name="l00296"></a>00296 <span class="keywordtype">char</span> t[4+20+1]; <span class="comment">/* "argv" plus space for a formatted base 10 64bit integer, plus NUL */</span>
<a name="l00297"></a>00297
<a name="l00298"></a>00298 snprintf (t, <span class="keyword">sizeof</span>(t), <span class="stringliteral">"argv%u"</span>, i);
<a name="l00299"></a>00299
<a name="l00300"></a>00300 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusAddress.html#gae6f014689b49099e835b1f97d032034e" title="Returns a value from a key of an entry.">dbus_address_entry_get_value</a> (entry, t))
<a name="l00301"></a>00301 <span class="keywordflow">break</span>;
<a name="l00302"></a>00302 }
<a name="l00303"></a>00303
<a name="l00304"></a>00304 <span class="comment">/* Allocate string array */</span>
<a name="l00305"></a>00305 argv = <a class="code" href="group__DBusMemory.html#gaba9d823abda7f4cadbaf5177d3b8b793" title="Safe macro for using dbus_malloc0().">dbus_new0</a> (<span class="keywordtype">char</span>*, i+1);
<a name="l00306"></a>00306 <span class="keywordflow">if</span> (!argv)
<a name="l00307"></a>00307 {
<a name="l00308"></a>00308 <a class="code" href="group__DBusErrors.html#ga89d2ad4bde21f9e0057fac07a79885e3" title="Assigns an error name and message to a DBusError.">dbus_set_error</a> (error, <a class="code" href="group__DBusProtocol.html#gac32eaf0b92f798307853cd4fe0cf11c2" title="There was not enough memory to complete an operation.">DBUS_ERROR_NO_MEMORY</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00309"></a>00309 <span class="keywordflow">return</span> DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
<a name="l00310"></a>00310 }
<a name="l00311"></a>00311
<a name="l00312"></a>00312 <span class="comment">/* Fill in string array */</span>
<a name="l00313"></a>00313 <span class="keywordflow">for</span> (i = 0; ; i++)
<a name="l00314"></a>00314 {
<a name="l00315"></a>00315 <span class="keywordtype">char</span> t[4+20+1];
<a name="l00316"></a>00316 <span class="keyword">const</span> <span class="keywordtype">char</span> *p;
<a name="l00317"></a>00317
<a name="l00318"></a>00318 snprintf (t, <span class="keyword">sizeof</span>(t), <span class="stringliteral">"argv%u"</span>, i);
<a name="l00319"></a>00319
<a name="l00320"></a>00320 p = <a class="code" href="group__DBusAddress.html#gae6f014689b49099e835b1f97d032034e" title="Returns a value from a key of an entry.">dbus_address_entry_get_value</a> (entry, t);
<a name="l00321"></a>00321 <span class="keywordflow">if</span> (!p)
<a name="l00322"></a>00322 {
<a name="l00323"></a>00323 <span class="keywordflow">if</span> (i == 0)
<a name="l00324"></a>00324 <span class="comment">/* If argv0 isn't specified, fill in the path instead */</span>
<a name="l00325"></a>00325 p = path;
<a name="l00326"></a>00326 <span class="keywordflow">else</span>
<a name="l00327"></a>00327 <span class="keywordflow">break</span>;
<a name="l00328"></a>00328 }
<a name="l00329"></a>00329
<a name="l00330"></a>00330 argv[i] = <a class="code" href="group__DBusInternalsUtils.html#ga9d00d77f6595b9d7ac1baf59d44bf58c" title="Duplicates a string.">_dbus_strdup</a> (p);
<a name="l00331"></a>00331 <span class="keywordflow">if</span> (!argv[i])
<a name="l00332"></a>00332 {
<a name="l00333"></a>00333 <a class="code" href="group__DBusMemory.html#gac200b2dbc8b3f6ecac4d42426fb97b40" title="Frees a NULL-terminated array of strings.">dbus_free_string_array</a> (argv);
<a name="l00334"></a>00334 <a class="code" href="group__DBusErrors.html#ga89d2ad4bde21f9e0057fac07a79885e3" title="Assigns an error name and message to a DBusError.">dbus_set_error</a> (error, <a class="code" href="group__DBusProtocol.html#gac32eaf0b92f798307853cd4fe0cf11c2" title="There was not enough memory to complete an operation.">DBUS_ERROR_NO_MEMORY</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00335"></a>00335 <span class="keywordflow">return</span> DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
<a name="l00336"></a>00336 }
<a name="l00337"></a>00337 }
<a name="l00338"></a>00338
<a name="l00339"></a>00339 *transport_p = _dbus_transport_new_for_exec (path, argv, error);
<a name="l00340"></a>00340 <a class="code" href="group__DBusMemory.html#gac200b2dbc8b3f6ecac4d42426fb97b40" title="Frees a NULL-terminated array of strings.">dbus_free_string_array</a> (argv);
<a name="l00341"></a>00341
<a name="l00342"></a>00342 <span class="keywordflow">if</span> (*transport_p == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00343"></a>00343 {
<a name="l00344"></a>00344 _DBUS_ASSERT_ERROR_IS_SET (error);
<a name="l00345"></a>00345 <span class="keywordflow">return</span> DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
<a name="l00346"></a>00346 }
<a name="l00347"></a>00347 <span class="keywordflow">else</span>
<a name="l00348"></a>00348 {
<a name="l00349"></a>00349 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
<a name="l00350"></a>00350 <span class="keywordflow">return</span> DBUS_TRANSPORT_OPEN_OK;
<a name="l00351"></a>00351 }
<a name="l00352"></a>00352 }
<a name="l00353"></a>00353 <span class="preprocessor">#ifdef DBUS_ENABLE_LAUNCHD</span>
<a name="l00354"></a>00354 <span class="preprocessor"></span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp (method, <span class="stringliteral">"launchd"</span>) == 0)
<a name="l00355"></a>00355 {
<a name="l00356"></a>00356 <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a> tmp_error = <a class="code" href="group__DBusErrorInternals.html#ga961cc70e3891282a65205c4c8418d88e" title="Expands to a suitable initializer for a DBusError on the stack.">DBUS_ERROR_INIT</a>;
<a name="l00357"></a>00357 <span class="keyword">const</span> <span class="keywordtype">char</span> *launchd_env_var = <a class="code" href="group__DBusAddress.html#gae6f014689b49099e835b1f97d032034e" title="Returns a value from a key of an entry.">dbus_address_entry_get_value</a> (entry, <span class="stringliteral">"env"</span>);
<a name="l00358"></a>00358 <span class="keyword">const</span> <span class="keywordtype">char</span> *launchd_socket;
<a name="l00359"></a>00359 <a class="code" href="structDBusString.html">DBusString</a> socket_path;
<a name="l00360"></a>00360 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> valid_socket;
<a name="l00361"></a>00361
<a name="l00362"></a>00362 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&socket_path))
<a name="l00363"></a>00363 {
<a name="l00364"></a>00364 _DBUS_SET_OOM (error);
<a name="l00365"></a>00365 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00366"></a>00366 }
<a name="l00367"></a>00367
<a name="l00368"></a>00368 <span class="keywordflow">if</span> (launchd_env_var == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00369"></a>00369 {
<a name="l00370"></a>00370 <a class="code" href="group__DBusAddressInternals.html#ga5b6409826263c7d62570c56889f7ddb2" title="Sets DBUS_ERROR_BAD_ADDRESS.">_dbus_set_bad_address</a> (error, <span class="stringliteral">"launchd"</span>, <span class="stringliteral">"env"</span>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00371"></a>00371 <span class="keywordflow">return</span> DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
<a name="l00372"></a>00372 }
<a name="l00373"></a>00373
<a name="l00374"></a>00374 valid_socket = <a class="code" href="group__DBusSysdepsUnix.html#ga6425e8cf4a38c71a48309b436322d4db" title="quries launchd for a specific env var which holds the socket path.">_dbus_lookup_launchd_socket</a> (&socket_path, launchd_env_var, error);
<a name="l00375"></a>00375
<a name="l00376"></a>00376 <span class="keywordflow">if</span> (<a class="code" href="group__DBusErrors.html#gab0ed62e9fc2685897eb2d41467c89405" title="Checks whether an error occurred (the error is set).">dbus_error_is_set</a>(error))
<a name="l00377"></a>00377 {
<a name="l00378"></a>00378 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a>(&socket_path);
<a name="l00379"></a>00379 <span class="keywordflow">return</span> DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
<a name="l00380"></a>00380 }
<a name="l00381"></a>00381
<a name="l00382"></a>00382 <span class="keywordflow">if</span> (!valid_socket)
<a name="l00383"></a>00383 {
<a name="l00384"></a>00384 <a class="code" href="group__DBusErrors.html#ga89d2ad4bde21f9e0057fac07a79885e3" title="Assigns an error name and message to a DBusError.">dbus_set_error</a>(&tmp_error, <a class="code" href="group__DBusProtocol.html#ga3fa04eb600edda4afc2dd9fe2e0f8b02" title="A D-Bus bus address was malformed.">DBUS_ERROR_BAD_ADDRESS</a>,
<a name="l00385"></a>00385 <span class="stringliteral">"launchd's env var %s does not exist"</span>, launchd_env_var);
<a name="l00386"></a>00386 <a class="code" href="group__DBusErrors.html#gaac6c14ead14829ee4e090f39de6a7568" title="Frees an error that's been set (or just initialized), then reinitializes the error as in dbus_error_i...">dbus_error_free</a>(error);
<a name="l00387"></a>00387 <a class="code" href="group__DBusErrors.html#ga0a27fb9f1af0c2bfd105d7e8622b93f4" title="Moves an error src into dest, freeing src and overwriting dest.">dbus_move_error</a>(&tmp_error, error);
<a name="l00388"></a>00388 <span class="keywordflow">return</span> DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
<a name="l00389"></a>00389 }
<a name="l00390"></a>00390
<a name="l00391"></a>00391 launchd_socket = <a class="code" href="group__DBusString.html#ga33e20241ae7d784624f97d89b1a0539e" title="Gets the raw character buffer from a const string.">_dbus_string_get_const_data</a>(&socket_path);
<a name="l00392"></a>00392 *transport_p = <a class="code" href="group__DBusTransportUnix.html#gada3df30a229b4d29ccf30af83bd88fcc" title="Creates a new transport for the given Unix domain socket path.">_dbus_transport_new_for_domain_socket</a> (launchd_socket, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>, error);
<a name="l00393"></a>00393
<a name="l00394"></a>00394 <span class="keywordflow">if</span> (*transport_p == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00395"></a>00395 {
<a name="l00396"></a>00396 _DBUS_ASSERT_ERROR_IS_SET (error);
<a name="l00397"></a>00397 <span class="keywordflow">return</span> DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
<a name="l00398"></a>00398 }
<a name="l00399"></a>00399 <span class="keywordflow">else</span>
<a name="l00400"></a>00400 {
<a name="l00401"></a>00401 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
<a name="l00402"></a>00402 <span class="keywordflow">return</span> DBUS_TRANSPORT_OPEN_OK;
<a name="l00403"></a>00403 }
<a name="l00404"></a>00404 }
<a name="l00405"></a>00405 <span class="preprocessor">#endif</span>
<a name="l00406"></a>00406 <span class="preprocessor"></span> <span class="keywordflow">else</span>
<a name="l00407"></a>00407 {
<a name="l00408"></a>00408 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
<a name="l00409"></a>00409 <span class="keywordflow">return</span> DBUS_TRANSPORT_OPEN_NOT_HANDLED;
<a name="l00410"></a>00410 }
<a name="l00411"></a>00411 }
<a name="l00412"></a>00412
<a name="l00415"></a>00415 <span class="preprocessor">#ifdef DBUS_ENABLE_EMBEDDED_TESTS</span>
<a name="l00416"></a>00416 <span class="preprocessor"></span>
<a name="l00417"></a>00417 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00418"></a>00418 _dbus_transport_unix_test (<span class="keywordtype">void</span>)
<a name="l00419"></a>00419 {
<a name="l00420"></a>00420 <a class="code" href="structDBusConnection.html" title="Implementation details of DBusConnection.">DBusConnection</a> *c;
<a name="l00421"></a>00421 <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a> error;
<a name="l00422"></a>00422 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> ret;
<a name="l00423"></a>00423 <span class="keyword">const</span> <span class="keywordtype">char</span> *address;
<a name="l00424"></a>00424
<a name="l00425"></a>00425 <a class="code" href="group__DBusErrors.html#ga8937f0b7cdf8554fa6305158ce453fbe" title="Initializes a DBusError structure.">dbus_error_init</a> (&error);
<a name="l00426"></a>00426
<a name="l00427"></a>00427 c = <a class="code" href="group__DBusConnection.html#gacd32f819820266598c6b6847dfddaf9c" title="Gets a connection to a remote address.">dbus_connection_open</a> (<span class="stringliteral">"unixexec:argv0=false,argv1=foobar,path=/bin/false"</span>, &error);
<a name="l00428"></a>00428 _dbus_assert (c != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00429"></a>00429 _dbus_assert (!<a class="code" href="group__DBusErrors.html#gab0ed62e9fc2685897eb2d41467c89405" title="Checks whether an error occurred (the error is set).">dbus_error_is_set</a> (&error));
<a name="l00430"></a>00430
<a name="l00431"></a>00431 address = _dbus_connection_get_address (c);
<a name="l00432"></a>00432 _dbus_assert (address != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00433"></a>00433
<a name="l00434"></a>00434 <span class="comment">/* Let's see if the address got parsed, reordered and formatted correctly */</span>
<a name="l00435"></a>00435 ret = strcmp (address, <span class="stringliteral">"unixexec:path=/bin/false,argv0=false,argv1=foobar"</span>) == 0;
<a name="l00436"></a>00436
<a name="l00437"></a>00437 <a class="code" href="group__DBusConnection.html#ga6385ff09bc108238c4429e7c195dab25" title="Decrements the reference count of a DBusConnection, and finalizes it if the count reaches zero...">dbus_connection_unref</a> (c);
<a name="l00438"></a>00438
<a name="l00439"></a>00439 <span class="keywordflow">return</span> ret;
<a name="l00440"></a>00440 }
<a name="l00441"></a>00441
<a name="l00442"></a>00442 <span class="preprocessor">#endif</span>
</pre></div></div><!-- contents -->
<hr class="footer"/><address class="footer"><small>
Generated on Thu Mar 3 2016 17:50:32 for D-Bus by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>
</body>
</html>