Current File : //usr/share/doc/dbus/api/dbus-server-socket_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-server-socket.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
   &#160;<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&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;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&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">dbus-server-socket.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: &quot;gnu&quot;; indent-tabs-mode: nil; -*- */</span>
<a name="l00002"></a>00002 <span class="comment">/* dbus-server-socket.c Server implementation for sockets</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2002, 2003, 2004, 2006  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 &lt;config.h&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &quot;dbus-internals.h&quot;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &quot;dbus-server-socket.h&quot;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &quot;dbus-transport-socket.h&quot;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include &quot;dbus-connection-internal.h&quot;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &quot;dbus-memory.h&quot;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &quot;dbus-nonce.h&quot;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &quot;dbus-string.h&quot;</span>
<a name="l00032"></a>00032 
<a name="l00044"></a><a class="code" href="group__DBusServerSocket.html#gace7aafbe2ae3cdbfbce3b01972dde0ce">00044</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structDBusServerSocket.html" title="Implementation details of DBusServerSocket.">DBusServerSocket</a> <a class="code" href="structDBusServerSocket.html" title="Implementation details of DBusServerSocket.">DBusServerSocket</a>;
<a name="l00045"></a>00045 
<a name="l00050"></a><a class="code" href="structDBusServerSocket.html">00050</a> <span class="keyword">struct </span><a class="code" href="structDBusServerSocket.html" title="Implementation details of DBusServerSocket.">DBusServerSocket</a>
<a name="l00051"></a>00051 {
<a name="l00052"></a><a class="code" href="structDBusServerSocket.html#ad811bada4239e72eaf91efdb2de9b5e9">00052</a>   <a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> <a class="code" href="structDBusServerSocket.html#ad811bada4239e72eaf91efdb2de9b5e9" title="Parent class members.">base</a>;   
<a name="l00053"></a><a class="code" href="structDBusServerSocket.html#a0585f7f6633ec428ab4a0863cbf4ffb1">00053</a>   <span class="keywordtype">int</span> <a class="code" href="structDBusServerSocket.html#a0585f7f6633ec428ab4a0863cbf4ffb1" title="Number of active file handles.">n_fds</a>;         
<a name="l00054"></a><a class="code" href="structDBusServerSocket.html#ab78b3c3d95035fa0428d89ce4acf375e">00054</a>   <span class="keywordtype">int</span> *<a class="code" href="structDBusServerSocket.html#ab78b3c3d95035fa0428d89ce4acf375e" title="File descriptor or -1 if disconnected.">fds</a>;          
<a name="l00055"></a><a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522">00055</a>   <a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> **<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>; 
<a name="l00056"></a><a class="code" href="structDBusServerSocket.html#ad9467f2872fbf623e72642650af7feb0">00056</a>   <span class="keywordtype">char</span> *<a class="code" href="structDBusServerSocket.html#ad9467f2872fbf623e72642650af7feb0" title="Name of domain socket, to unlink if appropriate.">socket_name</a>; 
<a name="l00057"></a><a class="code" href="structDBusServerSocket.html#a6ea3eebf42eba2469bf64eb0f91e1f97">00057</a>   <a class="code" href="structDBusNonceFile.html">DBusNonceFile</a> *<a class="code" href="structDBusServerSocket.html#a6ea3eebf42eba2469bf64eb0f91e1f97" title="Nonce file used to authenticate clients.">noncefile</a>; 
<a name="l00058"></a>00058 };
<a name="l00059"></a>00059 
<a name="l00060"></a>00060 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00061"></a>00061 socket_finalize (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server)
<a name="l00062"></a>00062 {
<a name="l00063"></a>00063   <a class="code" href="structDBusServerSocket.html" title="Implementation details of DBusServerSocket.">DBusServerSocket</a> *socket_server = (<a class="code" href="structDBusServerSocket.html" title="Implementation details of DBusServerSocket.">DBusServerSocket</a>*) server;
<a name="l00064"></a>00064   <span class="keywordtype">int</span> i;
<a name="l00065"></a>00065 
<a name="l00066"></a>00066   <a class="code" href="group__DBusServerInternals.html#ga93b5bca90e69122d5acbbeef2b4ca03e" title="Finalizes the members of the DBusServer base class.">_dbus_server_finalize_base</a> (server);
<a name="l00067"></a>00067 
<a name="l00068"></a>00068   <span class="keywordflow">for</span> (i = 0 ; i &lt; socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a0585f7f6633ec428ab4a0863cbf4ffb1" title="Number of active file handles.">n_fds</a> ; i++)
<a name="l00069"></a>00069     <span class="keywordflow">if</span> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>[i])
<a name="l00070"></a>00070       {
<a name="l00071"></a>00071         <a class="code" href="group__DBusWatchInternals.html#ga7d27dfc13a3ccfbaa99ceab331bb46f0" title="Decrements the reference count of a DBusWatch object and finalizes the object if the count reaches ze...">_dbus_watch_unref</a> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>[i]);
<a name="l00072"></a>00072         socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>[i] = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00073"></a>00073       }
<a name="l00074"></a>00074 
<a name="l00075"></a>00075   <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> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#ab78b3c3d95035fa0428d89ce4acf375e" title="File descriptor or -1 if disconnected.">fds</a>);
<a name="l00076"></a>00076   <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> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>);
<a name="l00077"></a>00077   <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> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#ad9467f2872fbf623e72642650af7feb0" title="Name of domain socket, to unlink if appropriate.">socket_name</a>);
<a name="l00078"></a>00078   <span class="keywordflow">if</span> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a6ea3eebf42eba2469bf64eb0f91e1f97" title="Nonce file used to authenticate clients.">noncefile</a>)
<a name="l00079"></a>00079         _dbus_noncefile_delete (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a6ea3eebf42eba2469bf64eb0f91e1f97" title="Nonce file used to authenticate clients.">noncefile</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00080"></a>00080   <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> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a6ea3eebf42eba2469bf64eb0f91e1f97" title="Nonce file used to authenticate clients.">noncefile</a>);
<a name="l00081"></a>00081   <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> (server);
<a name="l00082"></a>00082 }
<a name="l00083"></a>00083 
<a name="l00084"></a>00084 <span class="comment">/* Return value is just for memory, not other failures. */</span>
<a name="l00085"></a>00085 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00086"></a>00086 handle_new_client_fd_and_unlock (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l00087"></a>00087                                  <span class="keywordtype">int</span>         client_fd)
<a name="l00088"></a>00088 {
<a name="l00089"></a>00089   <a class="code" href="structDBusConnection.html" title="Implementation details of DBusConnection.">DBusConnection</a> *connection;
<a name="l00090"></a>00090   <a class="code" href="structDBusTransport.html" title="Object representing a transport such as a socket.">DBusTransport</a> *transport;
<a name="l00091"></a>00091   <a class="code" href="group__DBusServer.html#ga8478cd198973f6a6cb224ec23175faa7" title="Called when a new connection to the server is available.">DBusNewConnectionFunction</a> new_connection_function;
<a name="l00092"></a>00092   <span class="keywordtype">void</span> *new_connection_data;
<a name="l00093"></a>00093 
<a name="l00094"></a>00094   _dbus_verbose (<span class="stringliteral">&quot;Creating new client connection with fd %d\n&quot;</span>, client_fd);
<a name="l00095"></a>00095 
<a name="l00096"></a>00096   HAVE_LOCK_CHECK (server);
<a name="l00097"></a>00097 
<a name="l00098"></a>00098   <span class="keywordflow">if</span> (!_dbus_set_fd_nonblocking (client_fd, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>))
<a name="l00099"></a>00099     {
<a name="l00100"></a>00100       SERVER_UNLOCK (server);
<a name="l00101"></a>00101       <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00102"></a>00102     }
<a name="l00103"></a>00103 
<a name="l00104"></a>00104   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> (client_fd, &amp;server-&gt;<a class="code" href="structDBusServer.html#a79cd5d1b25412d56b7fd41902d575794" title="Hex-encoded version of GUID.">guid_hex</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00105"></a>00105   <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="l00106"></a>00106     {
<a name="l00107"></a>00107       <a class="code" href="group__DBusSysdeps.html#ga701f9b3087c196404f66ff95b4ace0b8" title="Closes a socket.">_dbus_close_socket</a> (client_fd, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00108"></a>00108       SERVER_UNLOCK (server);
<a name="l00109"></a>00109       <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00110"></a>00110     }
<a name="l00111"></a>00111 
<a name="l00112"></a>00112   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusTransport.html#ga345827326824547201e8c517474af135" title="Sets the SASL authentication mechanisms supported by this transport.">_dbus_transport_set_auth_mechanisms</a> (transport,
<a name="l00113"></a>00113                                             (<span class="keyword">const</span> <span class="keywordtype">char</span> **) server-&gt;<a class="code" href="structDBusServer.html#adc1032bbed41413e5d0e01578f2bfffc" title="Array of allowed authentication mechanisms.">auth_mechanisms</a>))
<a name="l00114"></a>00114     {
<a name="l00115"></a>00115       <a class="code" href="group__DBusTransport.html#gab7c53c32a2320c81aae8ce4345762e73" title="Decrements the reference count for the transport.">_dbus_transport_unref</a> (transport);
<a name="l00116"></a>00116       SERVER_UNLOCK (server);
<a name="l00117"></a>00117       <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00118"></a>00118     }
<a name="l00119"></a>00119 
<a name="l00120"></a>00120   <span class="comment">/* note that client_fd is now owned by the transport, and will be</span>
<a name="l00121"></a>00121 <span class="comment">   * closed on transport disconnection/finalization</span>
<a name="l00122"></a>00122 <span class="comment">   */</span>
<a name="l00123"></a>00123 
<a name="l00124"></a>00124   connection = <a class="code" href="group__DBusConnectionInternals.html#ga2cdffe9215251b69cb39ff36b9f50e6c" title="Creates a new connection for the given transport.">_dbus_connection_new_for_transport</a> (transport);
<a name="l00125"></a>00125   <a class="code" href="group__DBusTransport.html#gab7c53c32a2320c81aae8ce4345762e73" title="Decrements the reference count for the transport.">_dbus_transport_unref</a> (transport);
<a name="l00126"></a>00126   transport = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>; <span class="comment">/* now under the connection lock */</span>
<a name="l00127"></a>00127 
<a name="l00128"></a>00128   <span class="keywordflow">if</span> (connection == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00129"></a>00129     {
<a name="l00130"></a>00130       SERVER_UNLOCK (server);
<a name="l00131"></a>00131       <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00132"></a>00132     }
<a name="l00133"></a>00133 
<a name="l00134"></a>00134   <span class="comment">/* See if someone wants to handle this new connection, self-referencing</span>
<a name="l00135"></a>00135 <span class="comment">   * for paranoia.</span>
<a name="l00136"></a>00136 <span class="comment">   */</span>
<a name="l00137"></a>00137   new_connection_function = server-&gt;<a class="code" href="structDBusServer.html#a964ff125a29a7dac02f81e1a26233ff6" title="Callback to invoke when a new connection is created.">new_connection_function</a>;
<a name="l00138"></a>00138   new_connection_data = server-&gt;<a class="code" href="structDBusServer.html#acfba406ae6f288887feaccc3d621d094" title="Data for new connection callback.">new_connection_data</a>;
<a name="l00139"></a>00139 
<a name="l00140"></a>00140   <a class="code" href="group__DBusServerInternals.html#ga987e9bf42ab4e4cededa8e8f65c54e2e" title="Like dbus_server_ref() but does not acquire the lock (must already be held)">_dbus_server_ref_unlocked</a> (server);
<a name="l00141"></a>00141   SERVER_UNLOCK (server);
<a name="l00142"></a>00142 
<a name="l00143"></a>00143   <span class="keywordflow">if</span> (new_connection_function)
<a name="l00144"></a>00144     {
<a name="l00145"></a>00145       (* new_connection_function) (server, connection,
<a name="l00146"></a>00146                                    new_connection_data);
<a name="l00147"></a>00147     }
<a name="l00148"></a>00148   <a class="code" href="group__DBusServer.html#ga95d0b6cb9795b4919aa08f667807c555" title="Decrements the reference count of a DBusServer.">dbus_server_unref</a> (server);
<a name="l00149"></a>00149 
<a name="l00150"></a>00150   <span class="comment">/* If no one grabbed a reference, the connection will die. */</span>
<a name="l00151"></a>00151   <a class="code" href="group__DBusConnectionInternals.html#ga9f9665902c763bd1ddf9d9bc57d7a7ba" title="Used internally to handle the semantics of dbus_server_set_new_connection_function().">_dbus_connection_close_if_only_one_ref</a> (connection);
<a name="l00152"></a>00152   <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> (connection);
<a name="l00153"></a>00153 
<a name="l00154"></a>00154   <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00155"></a>00155 }
<a name="l00156"></a>00156 
<a name="l00157"></a>00157 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00158"></a>00158 socket_handle_watch (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a>    *watch,
<a name="l00159"></a>00159                    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>  flags,
<a name="l00160"></a>00160                    <span class="keywordtype">void</span>         *data)
<a name="l00161"></a>00161 {
<a name="l00162"></a>00162   <a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server = data;
<a name="l00163"></a>00163   <a class="code" href="structDBusServerSocket.html" title="Implementation details of DBusServerSocket.">DBusServerSocket</a> *socket_server = data;
<a name="l00164"></a>00164 
<a name="l00165"></a>00165 <span class="preprocessor">#ifndef DBUS_DISABLE_ASSERT</span>
<a name="l00166"></a>00166 <span class="preprocessor"></span>  <span class="keywordtype">int</span> i;
<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> found = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00168"></a>00168 <span class="preprocessor">#endif</span>
<a name="l00169"></a>00169 <span class="preprocessor"></span>
<a name="l00170"></a>00170   SERVER_LOCK (server);
<a name="l00171"></a>00171 
<a name="l00172"></a>00172 <span class="preprocessor">#ifndef DBUS_DISABLE_ASSERT</span>
<a name="l00173"></a>00173 <span class="preprocessor"></span>  <span class="keywordflow">for</span> (i = 0 ; i &lt; socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a0585f7f6633ec428ab4a0863cbf4ffb1" title="Number of active file handles.">n_fds</a> ; i++)
<a name="l00174"></a>00174     {
<a name="l00175"></a>00175       <span class="keywordflow">if</span> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>[i] == watch)
<a name="l00176"></a>00176         found = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00177"></a>00177     }
<a name="l00178"></a>00178   _dbus_assert (found);
<a name="l00179"></a>00179 <span class="preprocessor">#endif</span>
<a name="l00180"></a>00180 <span class="preprocessor"></span>
<a name="l00181"></a>00181   _dbus_verbose (<span class="stringliteral">&quot;Handling client connection, flags 0x%x\n&quot;</span>, flags);
<a name="l00182"></a>00182 
<a name="l00183"></a>00183   <span class="keywordflow">if</span> (flags &amp; <a class="code" href="group__DBusConnection.html#gga0556779e61aeb19eb9cf6b6466bd1b98a178bd7a88e9bfbb8505db76eb7e0ccc4" title="As in POLLIN.">DBUS_WATCH_READABLE</a>)
<a name="l00184"></a>00184     {
<a name="l00185"></a>00185       <span class="keywordtype">int</span> client_fd;
<a name="l00186"></a>00186       <span class="keywordtype">int</span> listen_fd;
<a name="l00187"></a>00187 
<a name="l00188"></a>00188       listen_fd = <a class="code" href="group__DBusWatch.html#ga91308f393d41b31babda17c83833517f" title="Returns a socket to be watched, on UNIX this will return -1 if our transport is not socket-based so d...">dbus_watch_get_socket</a> (watch);
<a name="l00189"></a>00189 
<a name="l00190"></a>00190       <span class="keywordflow">if</span> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a6ea3eebf42eba2469bf64eb0f91e1f97" title="Nonce file used to authenticate clients.">noncefile</a>)
<a name="l00191"></a>00191           client_fd = _dbus_accept_with_noncefile (listen_fd, socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a6ea3eebf42eba2469bf64eb0f91e1f97" title="Nonce file used to authenticate clients.">noncefile</a>);
<a name="l00192"></a>00192       <span class="keywordflow">else</span> 
<a name="l00193"></a>00193           client_fd = <a class="code" href="group__DBusSysdeps.html#ga687f4393a365474ec16f02e40c418cce" title="Accepts a connection on a listening socket.">_dbus_accept</a> (listen_fd);
<a name="l00194"></a>00194 
<a name="l00195"></a>00195       <span class="keywordflow">if</span> (client_fd &lt; 0)
<a name="l00196"></a>00196         {
<a name="l00197"></a>00197           <span class="comment">/* EINTR handled for us */</span>
<a name="l00198"></a>00198 
<a name="l00199"></a>00199           <span class="keywordflow">if</span> (<a class="code" href="group__DBusSysdeps.html#gaa03e5d4d95ef46a70d25fe315e674e24" title="See if errno is EAGAIN or EWOULDBLOCK (this has to be done differently for Winsock so is abstracted)...">_dbus_get_is_errno_eagain_or_ewouldblock</a> ())
<a name="l00200"></a>00200             _dbus_verbose (<span class="stringliteral">&quot;No client available to accept after all\n&quot;</span>);
<a name="l00201"></a>00201           <span class="keywordflow">else</span>
<a name="l00202"></a>00202             _dbus_verbose (<span class="stringliteral">&quot;Failed to accept a client connection: %s\n&quot;</span>,
<a name="l00203"></a>00203                            <a class="code" href="group__DBusInternalsUtils.html#ga56de84795d6df4162ad79b3be7af7588" title="Get error message from errno.">_dbus_strerror_from_errno</a> ());
<a name="l00204"></a>00204 
<a name="l00205"></a>00205           SERVER_UNLOCK (server);
<a name="l00206"></a>00206         }
<a name="l00207"></a>00207       <span class="keywordflow">else</span>
<a name="l00208"></a>00208         {
<a name="l00209"></a>00209           <span class="keywordflow">if</span> (!handle_new_client_fd_and_unlock (server, client_fd))
<a name="l00210"></a>00210             _dbus_verbose (<span class="stringliteral">&quot;Rejected client connection due to lack of memory\n&quot;</span>);
<a name="l00211"></a>00211         }
<a name="l00212"></a>00212     }
<a name="l00213"></a>00213 
<a name="l00214"></a>00214   <span class="keywordflow">if</span> (flags &amp; <a class="code" href="group__DBusConnection.html#gga0556779e61aeb19eb9cf6b6466bd1b98ab1474e26aa5be3d2876dd86bbe452156" title="As in POLLERR (can&#39;t watch for this, but can be present in current state passed to dbus_watch_handle(...">DBUS_WATCH_ERROR</a>)
<a name="l00215"></a>00215     _dbus_verbose (<span class="stringliteral">&quot;Error on server listening socket\n&quot;</span>);
<a name="l00216"></a>00216 
<a name="l00217"></a>00217   <span class="keywordflow">if</span> (flags &amp; <a class="code" href="group__DBusConnection.html#gga0556779e61aeb19eb9cf6b6466bd1b98a7a361a1a03f463c3c9e57f7368a0bfe4" title="As in POLLHUP (can&#39;t watch for it, but can be present in current state passed to dbus_watch_handle())...">DBUS_WATCH_HANGUP</a>)
<a name="l00218"></a>00218     _dbus_verbose (<span class="stringliteral">&quot;Hangup on server listening socket\n&quot;</span>);
<a name="l00219"></a>00219 
<a name="l00220"></a>00220   <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00221"></a>00221 }
<a name="l00222"></a>00222 
<a name="l00223"></a>00223 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00224"></a>00224 socket_disconnect (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server)
<a name="l00225"></a>00225 {
<a name="l00226"></a>00226   <a class="code" href="structDBusServerSocket.html" title="Implementation details of DBusServerSocket.">DBusServerSocket</a> *socket_server = (<a class="code" href="structDBusServerSocket.html" title="Implementation details of DBusServerSocket.">DBusServerSocket</a>*) server;
<a name="l00227"></a>00227   <span class="keywordtype">int</span> i;
<a name="l00228"></a>00228 
<a name="l00229"></a>00229   HAVE_LOCK_CHECK (server);
<a name="l00230"></a>00230 
<a name="l00231"></a>00231   <span class="keywordflow">for</span> (i = 0 ; i &lt; socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a0585f7f6633ec428ab4a0863cbf4ffb1" title="Number of active file handles.">n_fds</a> ; i++)
<a name="l00232"></a>00232     {
<a name="l00233"></a>00233       <span class="keywordflow">if</span> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>[i])
<a name="l00234"></a>00234         {
<a name="l00235"></a>00235           <a class="code" href="group__DBusServerInternals.html#ga61cfdbfcc9316d4bae55f83b069f248c" title="Removes a watch previously added with _dbus_server_remove_watch().">_dbus_server_remove_watch</a> (server,
<a name="l00236"></a>00236                                      socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>[i]);
<a name="l00237"></a>00237           <a class="code" href="group__DBusWatchInternals.html#gad8521d64123c1d1ae9a094bac8addd31" title="Clears the file descriptor from a now-invalid watch object so that no one tries to use it...">_dbus_watch_invalidate</a> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>[i]);
<a name="l00238"></a>00238           <a class="code" href="group__DBusWatchInternals.html#ga7d27dfc13a3ccfbaa99ceab331bb46f0" title="Decrements the reference count of a DBusWatch object and finalizes the object if the count reaches ze...">_dbus_watch_unref</a> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>[i]);
<a name="l00239"></a>00239           socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>[i] = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00240"></a>00240         }
<a name="l00241"></a>00241 
<a name="l00242"></a>00242       <a class="code" href="group__DBusSysdeps.html#ga701f9b3087c196404f66ff95b4ace0b8" title="Closes a socket.">_dbus_close_socket</a> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#ab78b3c3d95035fa0428d89ce4acf375e" title="File descriptor or -1 if disconnected.">fds</a>[i], <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       socket_server-&gt;<a class="code" href="structDBusServerSocket.html#ab78b3c3d95035fa0428d89ce4acf375e" title="File descriptor or -1 if disconnected.">fds</a>[i] = -1;
<a name="l00244"></a>00244     }
<a name="l00245"></a>00245 
<a name="l00246"></a>00246   <span class="keywordflow">if</span> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#ad9467f2872fbf623e72642650af7feb0" title="Name of domain socket, to unlink if appropriate.">socket_name</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00247"></a>00247     {
<a name="l00248"></a>00248       <a class="code" href="structDBusString.html">DBusString</a> tmp;
<a name="l00249"></a>00249       <a class="code" href="group__DBusString.html#ga374640ddfa2f0b27a8356e2379ba8043" title="Initializes a constant string.">_dbus_string_init_const</a> (&amp;tmp, socket_server-&gt;<a class="code" href="structDBusServerSocket.html#ad9467f2872fbf623e72642650af7feb0" title="Name of domain socket, to unlink if appropriate.">socket_name</a>);
<a name="l00250"></a>00250       <a class="code" href="group__DBusFile.html#ga4d4936493cddac47b6e7e4ab3f390627" title="Deletes the given file.">_dbus_delete_file</a> (&amp;tmp, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00251"></a>00251     }
<a name="l00252"></a>00252 
<a name="l00253"></a>00253   <span class="keywordflow">if</span> (server-&gt;<a class="code" href="structDBusServer.html#a01a6dbb2573ce35f639873cd4dd85b4d" title="flag which indicates that server has published its bus address.">published_address</a>)
<a name="l00254"></a>00254       _dbus_daemon_unpublish_session_bus_address();
<a name="l00255"></a>00255 
<a name="l00256"></a>00256   HAVE_LOCK_CHECK (server);
<a name="l00257"></a>00257 }
<a name="l00258"></a>00258 
<a name="l00259"></a>00259 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="structDBusServerVTable.html" title="Virtual table to be implemented by all server &quot;subclasses&quot;.">DBusServerVTable</a> socket_vtable = {
<a name="l00260"></a>00260   socket_finalize,
<a name="l00261"></a>00261   socket_disconnect
<a name="l00262"></a>00262 };
<a name="l00263"></a>00263 
<a name="l00279"></a>00279 <a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a>*
<a name="l00280"></a><a class="code" href="group__DBusServerSocket.html#ga93d00891e32dbc05a33d3c69ca2ffef6">00280</a> <a class="code" href="group__DBusServerSocket.html#ga93d00891e32dbc05a33d3c69ca2ffef6" title="Creates a new server listening on the given file descriptor.">_dbus_server_new_for_socket</a> (<span class="keywordtype">int</span>              *fds,
<a name="l00281"></a>00281                              <span class="keywordtype">int</span>               n_fds,
<a name="l00282"></a>00282                              <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *address,
<a name="l00283"></a>00283                              <a class="code" href="structDBusNonceFile.html">DBusNonceFile</a>    *noncefile)
<a name="l00284"></a>00284 {
<a name="l00285"></a>00285   <a class="code" href="structDBusServerSocket.html" title="Implementation details of DBusServerSocket.">DBusServerSocket</a> *socket_server;
<a name="l00286"></a>00286   <a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server;
<a name="l00287"></a>00287   <span class="keywordtype">int</span> i;
<a name="l00288"></a>00288 
<a name="l00289"></a>00289   socket_server = <a class="code" href="group__DBusMemory.html#gaba9d823abda7f4cadbaf5177d3b8b793" title="Safe macro for using dbus_malloc0().">dbus_new0</a> (<a class="code" href="structDBusServerSocket.html" title="Implementation details of DBusServerSocket.">DBusServerSocket</a>, 1);
<a name="l00290"></a>00290   <span class="keywordflow">if</span> (socket_server == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00291"></a>00291     <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="l00292"></a>00292 
<a name="l00293"></a>00293   socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a6ea3eebf42eba2469bf64eb0f91e1f97" title="Nonce file used to authenticate clients.">noncefile</a> = noncefile;
<a name="l00294"></a>00294 
<a name="l00295"></a>00295   socket_server-&gt;<a class="code" href="structDBusServerSocket.html#ab78b3c3d95035fa0428d89ce4acf375e" title="File descriptor or -1 if disconnected.">fds</a> = <a class="code" href="group__DBusMemory.html#ga54ccb556e7964112a825a7f46c156ca0" title="Safe macro for using dbus_malloc().">dbus_new</a> (<span class="keywordtype">int</span>, n_fds);
<a name="l00296"></a>00296   <span class="keywordflow">if</span> (!socket_server-&gt;<a class="code" href="structDBusServerSocket.html#ab78b3c3d95035fa0428d89ce4acf375e" title="File descriptor or -1 if disconnected.">fds</a>)
<a name="l00297"></a>00297     <span class="keywordflow">goto</span> failed_0;
<a name="l00298"></a>00298 
<a name="l00299"></a>00299   socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a> = <a class="code" href="group__DBusMemory.html#gaba9d823abda7f4cadbaf5177d3b8b793" title="Safe macro for using dbus_malloc0().">dbus_new0</a> (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *, n_fds);
<a name="l00300"></a>00300   <span class="keywordflow">if</span> (!socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>)
<a name="l00301"></a>00301     <span class="keywordflow">goto</span> failed_1;
<a name="l00302"></a>00302 
<a name="l00303"></a>00303   <span class="keywordflow">for</span> (i = 0 ; i &lt; n_fds ; i++)
<a name="l00304"></a>00304     {
<a name="l00305"></a>00305       <a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch;
<a name="l00306"></a>00306 
<a name="l00307"></a>00307       watch = <a class="code" href="group__DBusWatchInternals.html#ga1f940e505b20e6429ae858a7b70b0541" title="Creates a new DBusWatch.">_dbus_watch_new</a> (fds[i],
<a name="l00308"></a>00308                                DBUS_WATCH_READABLE,
<a name="l00309"></a>00309                                <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>,
<a name="l00310"></a>00310                                socket_handle_watch, socket_server,
<a name="l00311"></a>00311                                <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00312"></a>00312       <span class="keywordflow">if</span> (watch == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00313"></a>00313         <span class="keywordflow">goto</span> failed_2;
<a name="l00314"></a>00314 
<a name="l00315"></a>00315       socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a0585f7f6633ec428ab4a0863cbf4ffb1" title="Number of active file handles.">n_fds</a>++;
<a name="l00316"></a>00316       socket_server-&gt;<a class="code" href="structDBusServerSocket.html#ab78b3c3d95035fa0428d89ce4acf375e" title="File descriptor or -1 if disconnected.">fds</a>[i] = fds[i];
<a name="l00317"></a>00317       socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>[i] = watch;
<a name="l00318"></a>00318     }
<a name="l00319"></a>00319 
<a name="l00320"></a>00320   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusServerInternals.html#gaacfb3d29553f205b362c850cfda02fd9" title="Initializes the members of the DBusServer base class.">_dbus_server_init_base</a> (&amp;socket_server-&gt;<a class="code" href="structDBusServerSocket.html#ad811bada4239e72eaf91efdb2de9b5e9" title="Parent class members.">base</a>,
<a name="l00321"></a>00321                                &amp;socket_vtable, address))
<a name="l00322"></a>00322     <span class="keywordflow">goto</span> failed_2;
<a name="l00323"></a>00323 
<a name="l00324"></a>00324   server = (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a>*)socket_server;
<a name="l00325"></a>00325 
<a name="l00326"></a>00326   SERVER_LOCK (server);
<a name="l00327"></a>00327 
<a name="l00328"></a>00328   <span class="keywordflow">for</span> (i = 0 ; i &lt; n_fds ; i++)
<a name="l00329"></a>00329     {
<a name="l00330"></a>00330       <span class="keywordflow">if</span> (!<a class="code" href="group__DBusServerInternals.html#ga0866e5b205b8a570c77c8ad787b665fd" title="Adds a watch for this server, chaining out to application-provided watch handlers.">_dbus_server_add_watch</a> (&amp;socket_server-&gt;<a class="code" href="structDBusServerSocket.html#ad811bada4239e72eaf91efdb2de9b5e9" title="Parent class members.">base</a>,
<a name="l00331"></a>00331                                    socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>[i]))
<a name="l00332"></a>00332         {
<a name="l00333"></a>00333           <span class="keywordtype">int</span> j;
<a name="l00334"></a>00334           <span class="keywordflow">for</span> (j = 0 ; j &lt; i ; j++)
<a name="l00335"></a>00335             <a class="code" href="group__DBusServerInternals.html#ga61cfdbfcc9316d4bae55f83b069f248c" title="Removes a watch previously added with _dbus_server_remove_watch().">_dbus_server_remove_watch</a> (server,
<a name="l00336"></a>00336                                        socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>[j]);
<a name="l00337"></a>00337 
<a name="l00338"></a>00338           SERVER_UNLOCK (server);
<a name="l00339"></a>00339           <a class="code" href="group__DBusServerInternals.html#ga93b5bca90e69122d5acbbeef2b4ca03e" title="Finalizes the members of the DBusServer base class.">_dbus_server_finalize_base</a> (&amp;socket_server-&gt;<a class="code" href="structDBusServerSocket.html#ad811bada4239e72eaf91efdb2de9b5e9" title="Parent class members.">base</a>);
<a name="l00340"></a>00340           <span class="keywordflow">goto</span> failed_2;
<a name="l00341"></a>00341         }
<a name="l00342"></a>00342     }
<a name="l00343"></a>00343 
<a name="l00344"></a>00344   SERVER_UNLOCK (server);
<a name="l00345"></a>00345 
<a name="l00346"></a>00346   _dbus_server_trace_ref (&amp;socket_server-&gt;<a class="code" href="structDBusServerSocket.html#ad811bada4239e72eaf91efdb2de9b5e9" title="Parent class members.">base</a>, 0, 1, <span class="stringliteral">&quot;new_for_socket&quot;</span>);
<a name="l00347"></a>00347   <span class="keywordflow">return</span> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a>*) socket_server;
<a name="l00348"></a>00348 
<a name="l00349"></a>00349  failed_2:
<a name="l00350"></a>00350   <span class="keywordflow">for</span> (i = 0 ; i &lt; n_fds ; i++)
<a name="l00351"></a>00351     {
<a name="l00352"></a>00352       <span class="keywordflow">if</span> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>[i] != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00353"></a>00353         {
<a name="l00354"></a>00354           <a class="code" href="group__DBusWatchInternals.html#ga7d27dfc13a3ccfbaa99ceab331bb46f0" title="Decrements the reference count of a DBusWatch object and finalizes the object if the count reaches ze...">_dbus_watch_unref</a> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>[i]);
<a name="l00355"></a>00355           socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>[i] = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00356"></a>00356         }
<a name="l00357"></a>00357     }
<a name="l00358"></a>00358   <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> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#a9b0b7c50962dc70abf9f712369761522" title="File descriptor watch.">watch</a>);
<a name="l00359"></a>00359 
<a name="l00360"></a>00360  failed_1:
<a name="l00361"></a>00361   <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> (socket_server-&gt;<a class="code" href="structDBusServerSocket.html#ab78b3c3d95035fa0428d89ce4acf375e" title="File descriptor or -1 if disconnected.">fds</a>);
<a name="l00362"></a>00362 
<a name="l00363"></a>00363  failed_0:
<a name="l00364"></a>00364   <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> (socket_server);
<a name="l00365"></a>00365   <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="l00366"></a>00366 }
<a name="l00367"></a>00367 
<a name="l00387"></a>00387 <a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a>*
<a name="l00388"></a><a class="code" href="group__DBusServerSocket.html#ga047d05c427e9a1fc5823fdfdcec5c5f6">00388</a> <a class="code" href="group__DBusServerSocket.html#ga047d05c427e9a1fc5823fdfdcec5c5f6" title="Creates a new server listening on TCP.">_dbus_server_new_for_tcp_socket</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>     *host,
<a name="l00389"></a>00389                                  <span class="keyword">const</span> <span class="keywordtype">char</span>     *bind,
<a name="l00390"></a>00390                                  <span class="keyword">const</span> <span class="keywordtype">char</span>     *port,
<a name="l00391"></a>00391                                  <span class="keyword">const</span> <span class="keywordtype">char</span>     *family,
<a name="l00392"></a>00392                                  <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a>      *error,
<a name="l00393"></a>00393                                  <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>    use_nonce)
<a name="l00394"></a>00394 {
<a name="l00395"></a>00395   <a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server;
<a name="l00396"></a>00396   <span class="keywordtype">int</span> *listen_fds = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00397"></a>00397   <span class="keywordtype">int</span> nlisten_fds = 0, i;
<a name="l00398"></a>00398   <a class="code" href="structDBusString.html">DBusString</a> address;
<a name="l00399"></a>00399   <a class="code" href="structDBusString.html">DBusString</a> host_str;
<a name="l00400"></a>00400   <a class="code" href="structDBusString.html">DBusString</a> port_str;
<a name="l00401"></a>00401   <a class="code" href="structDBusNonceFile.html">DBusNonceFile</a> *noncefile;
<a name="l00402"></a>00402   
<a name="l00403"></a>00403   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
<a name="l00404"></a>00404 
<a name="l00405"></a>00405   noncefile = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00406"></a>00406 
<a name="l00407"></a>00407   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&amp;address))
<a name="l00408"></a>00408     {
<a name="l00409"></a>00409       <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="l00410"></a>00410       <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="l00411"></a>00411     }
<a name="l00412"></a>00412 
<a name="l00413"></a>00413   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&amp;port_str))
<a name="l00414"></a>00414     {
<a name="l00415"></a>00415       <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="l00416"></a>00416       <span class="keywordflow">goto</span> failed_0;
<a name="l00417"></a>00417     }
<a name="l00418"></a>00418 
<a name="l00419"></a>00419   <span class="keywordflow">if</span> (host == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00420"></a>00420     host = <span class="stringliteral">&quot;localhost&quot;</span>;
<a name="l00421"></a>00421 
<a name="l00422"></a>00422   <span class="keywordflow">if</span> (port == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00423"></a>00423     port = <span class="stringliteral">&quot;0&quot;</span>;
<a name="l00424"></a>00424 
<a name="l00425"></a>00425   <span class="keywordflow">if</span> (bind == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00426"></a>00426     bind = host;
<a name="l00427"></a>00427   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strcmp (bind, <span class="stringliteral">&quot;*&quot;</span>) == 0)
<a name="l00428"></a>00428     bind = <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 
<a name="l00430"></a>00430   nlisten_fds =<a class="code" href="group__DBusSysdeps.html#gafdae31b3b61299dbaaccfcb1205a6f30" title="Creates a socket and binds it to the given path, then listens on the socket.">_dbus_listen_tcp_socket</a> (bind, port, family,
<a name="l00431"></a>00431                                         &amp;port_str,
<a name="l00432"></a>00432                                         &amp;listen_fds, error);
<a name="l00433"></a>00433   <span class="keywordflow">if</span> (nlisten_fds &lt;= 0)
<a name="l00434"></a>00434     {
<a name="l00435"></a>00435       _DBUS_ASSERT_ERROR_IS_SET(error);
<a name="l00436"></a>00436       <span class="keywordflow">goto</span> failed_1;
<a name="l00437"></a>00437     }
<a name="l00438"></a>00438 
<a name="l00439"></a>00439   <a class="code" href="group__DBusString.html#ga374640ddfa2f0b27a8356e2379ba8043" title="Initializes a constant string.">_dbus_string_init_const</a> (&amp;host_str, host);
<a name="l00440"></a>00440   <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> (&amp;address, use_nonce ? <span class="stringliteral">&quot;nonce-tcp:host=&quot;</span> : <span class="stringliteral">&quot;tcp:host=&quot;</span>) ||
<a name="l00441"></a>00441       !<a class="code" href="group__DBusAddressInternals.html#ga1ecc2f460303cd70c34e7667e8b12b37" title="Appends an escaped version of one string to another string, using the D-Bus address escaping mechanis...">_dbus_address_append_escaped</a> (&amp;address, &amp;host_str) ||
<a name="l00442"></a>00442       !<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&amp;address, <span class="stringliteral">&quot;,port=&quot;</span>) ||
<a name="l00443"></a>00443       !<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&amp;address, <a class="code" href="group__DBusString.html#ga33e20241ae7d784624f97d89b1a0539e" title="Gets the raw character buffer from a const string.">_dbus_string_get_const_data</a>(&amp;port_str)))
<a name="l00444"></a>00444     {
<a name="l00445"></a>00445       <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="l00446"></a>00446       <span class="keywordflow">goto</span> failed_2;
<a name="l00447"></a>00447     }
<a name="l00448"></a>00448   <span class="keywordflow">if</span> (family &amp;&amp;
<a name="l00449"></a>00449       (!<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&amp;address, <span class="stringliteral">&quot;,family=&quot;</span>) ||
<a name="l00450"></a>00450        !<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&amp;address, family)))
<a name="l00451"></a>00451     {
<a name="l00452"></a>00452       <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="l00453"></a>00453       <span class="keywordflow">goto</span> failed_2;
<a name="l00454"></a>00454     }
<a name="l00455"></a>00455 
<a name="l00456"></a>00456   <span class="keywordflow">if</span> (use_nonce)
<a name="l00457"></a>00457     {
<a name="l00458"></a>00458       noncefile = <a class="code" href="group__DBusMemory.html#gaba9d823abda7f4cadbaf5177d3b8b793" title="Safe macro for using dbus_malloc0().">dbus_new0</a> (<a class="code" href="structDBusNonceFile.html">DBusNonceFile</a>, 1);
<a name="l00459"></a>00459       <span class="keywordflow">if</span> (noncefile == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00460"></a>00460         {
<a name="l00461"></a>00461           <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="l00462"></a>00462           <span class="keywordflow">goto</span> failed_2;
<a name="l00463"></a>00463         }
<a name="l00464"></a>00464 
<a name="l00465"></a>00465       <span class="keywordflow">if</span> (!_dbus_noncefile_create (noncefile, error))
<a name="l00466"></a>00466           <span class="keywordflow">goto</span> failed_3;
<a name="l00467"></a>00467 
<a name="l00468"></a>00468       <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> (&amp;address, <span class="stringliteral">&quot;,noncefile=&quot;</span>) ||
<a name="l00469"></a>00469           !<a class="code" href="group__DBusAddressInternals.html#ga1ecc2f460303cd70c34e7667e8b12b37" title="Appends an escaped version of one string to another string, using the D-Bus address escaping mechanis...">_dbus_address_append_escaped</a> (&amp;address, _dbus_noncefile_get_path (noncefile)))
<a name="l00470"></a>00470         {
<a name="l00471"></a>00471           <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="l00472"></a>00472           <span class="keywordflow">goto</span> failed_4;
<a name="l00473"></a>00473         }
<a name="l00474"></a>00474 
<a name="l00475"></a>00475     }
<a name="l00476"></a>00476 
<a name="l00477"></a>00477   server = <a class="code" href="group__DBusServerSocket.html#ga93d00891e32dbc05a33d3c69ca2ffef6" title="Creates a new server listening on the given file descriptor.">_dbus_server_new_for_socket</a> (listen_fds, nlisten_fds, &amp;address, noncefile);
<a name="l00478"></a>00478   <span class="keywordflow">if</span> (server == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00479"></a>00479     {
<a name="l00480"></a>00480       <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="l00481"></a>00481       <span class="keywordflow">if</span> (noncefile != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00482"></a>00482         <span class="keywordflow">goto</span> failed_4;
<a name="l00483"></a>00483       <span class="keywordflow">else</span>
<a name="l00484"></a>00484         <span class="keywordflow">goto</span> failed_2;
<a name="l00485"></a>00485     }
<a name="l00486"></a>00486 
<a name="l00487"></a>00487   <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&amp;port_str);
<a name="l00488"></a>00488   <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&amp;address);
<a name="l00489"></a>00489   <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>(listen_fds);
<a name="l00490"></a>00490 
<a name="l00491"></a>00491   <span class="keywordflow">return</span> server;
<a name="l00492"></a>00492 
<a name="l00493"></a>00493  failed_4:
<a name="l00494"></a>00494   _dbus_noncefile_delete (noncefile, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00495"></a>00495 
<a name="l00496"></a>00496  failed_3:
<a name="l00497"></a>00497   <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> (noncefile);
<a name="l00498"></a>00498 
<a name="l00499"></a>00499  failed_2:
<a name="l00500"></a>00500   <span class="keywordflow">for</span> (i = 0 ; i &lt; nlisten_fds ; i++)
<a name="l00501"></a>00501     <a class="code" href="group__DBusSysdeps.html#ga701f9b3087c196404f66ff95b4ace0b8" title="Closes a socket.">_dbus_close_socket</a> (listen_fds[i], <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00502"></a>00502   <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>(listen_fds);
<a name="l00503"></a>00503 
<a name="l00504"></a>00504  failed_1:
<a name="l00505"></a>00505   <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&amp;port_str);
<a name="l00506"></a>00506 
<a name="l00507"></a>00507  failed_0:
<a name="l00508"></a>00508   <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&amp;address);
<a name="l00509"></a>00509 
<a name="l00510"></a>00510   <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="l00511"></a>00511 }
<a name="l00512"></a>00512 
<a name="l00525"></a>00525 DBusServerListenResult
<a name="l00526"></a><a class="code" href="group__DBusServerSocket.html#ga90a89943c15760592e5ddce31bf0e021">00526</a> <a class="code" href="group__DBusServerSocket.html#ga90a89943c15760592e5ddce31bf0e021" title="Tries to interpret the address entry for various socket-related addresses (well, currently only tcp a...">_dbus_server_listen_socket</a> (<a class="code" href="structDBusAddressEntry.html" title="Internals of DBusAddressEntry.">DBusAddressEntry</a> *entry,
<a name="l00527"></a>00527                             <a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a>      **server_p,
<a name="l00528"></a>00528                             <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a>        *error)
<a name="l00529"></a>00529 {
<a name="l00530"></a>00530   <span class="keyword">const</span> <span class="keywordtype">char</span> *method;
<a name="l00531"></a>00531 
<a name="l00532"></a>00532   *server_p = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00533"></a>00533 
<a name="l00534"></a>00534   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="l00535"></a>00535 
<a name="l00536"></a>00536   <span class="keywordflow">if</span> (strcmp (method, <span class="stringliteral">&quot;tcp&quot;</span>) == 0 || strcmp (method, <span class="stringliteral">&quot;nonce-tcp&quot;</span>) == 0)
<a name="l00537"></a>00537     {
<a name="l00538"></a>00538       <span class="keyword">const</span> <span class="keywordtype">char</span> *host;
<a name="l00539"></a>00539       <span class="keyword">const</span> <span class="keywordtype">char</span> *port;
<a name="l00540"></a>00540       <span class="keyword">const</span> <span class="keywordtype">char</span> *bind;
<a name="l00541"></a>00541       <span class="keyword">const</span> <span class="keywordtype">char</span> *family;
<a name="l00542"></a>00542 
<a name="l00543"></a>00543       host = <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">&quot;host&quot;</span>);
<a name="l00544"></a>00544       bind = <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">&quot;bind&quot;</span>);
<a name="l00545"></a>00545       port = <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">&quot;port&quot;</span>);
<a name="l00546"></a>00546       family = <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">&quot;family&quot;</span>);
<a name="l00547"></a>00547 
<a name="l00548"></a>00548       *server_p = <a class="code" href="group__DBusServerSocket.html#ga047d05c427e9a1fc5823fdfdcec5c5f6" title="Creates a new server listening on TCP.">_dbus_server_new_for_tcp_socket</a> (host, bind, port,
<a name="l00549"></a>00549                                                    family, error, strcmp (method, <span class="stringliteral">&quot;nonce-tcp&quot;</span>) == 0 ? <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a> : <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>);
<a name="l00550"></a>00550 
<a name="l00551"></a>00551       <span class="keywordflow">if</span> (*server_p)
<a name="l00552"></a>00552         {
<a name="l00553"></a>00553           _DBUS_ASSERT_ERROR_IS_CLEAR(error);
<a name="l00554"></a>00554           <span class="keywordflow">return</span> DBUS_SERVER_LISTEN_OK;
<a name="l00555"></a>00555         }
<a name="l00556"></a>00556       <span class="keywordflow">else</span>
<a name="l00557"></a>00557         {
<a name="l00558"></a>00558           _DBUS_ASSERT_ERROR_IS_SET(error);
<a name="l00559"></a>00559           <span class="keywordflow">return</span> DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
<a name="l00560"></a>00560         }
<a name="l00561"></a>00561     }
<a name="l00562"></a>00562   <span class="keywordflow">else</span>
<a name="l00563"></a>00563     {
<a name="l00564"></a>00564       _DBUS_ASSERT_ERROR_IS_CLEAR(error);
<a name="l00565"></a>00565       <span class="keywordflow">return</span> DBUS_SERVER_LISTEN_NOT_HANDLED;
<a name="l00566"></a>00566     }
<a name="l00567"></a>00567 }
<a name="l00568"></a>00568 
<a name="l00578"></a>00578 <span class="keywordtype">void</span>
<a name="l00579"></a><a class="code" href="group__DBusServerSocket.html#gaa9518c980672f1b8dba8f5a981b93fd9">00579</a> <a class="code" href="group__DBusServerSocket.html#gaa9518c980672f1b8dba8f5a981b93fd9" title="This is a bad hack since it&#39;s really unix domain socket specific.">_dbus_server_socket_own_filename</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l00580"></a>00580                                   <span class="keywordtype">char</span>       *filename)
<a name="l00581"></a>00581 {
<a name="l00582"></a>00582   <a class="code" href="structDBusServerSocket.html" title="Implementation details of DBusServerSocket.">DBusServerSocket</a> *socket_server = (<a class="code" href="structDBusServerSocket.html" title="Implementation details of DBusServerSocket.">DBusServerSocket</a>*) server;
<a name="l00583"></a>00583 
<a name="l00584"></a>00584   socket_server-&gt;<a class="code" href="structDBusServerSocket.html#ad9467f2872fbf623e72642650af7feb0" title="Name of domain socket, to unlink if appropriate.">socket_name</a> = filename;
<a name="l00585"></a>00585 }
<a name="l00586"></a>00586 
<a name="l00587"></a>00587 
</pre></div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated on Thu Mar 3 2016 17:50:31 for D-Bus by &#160;<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>