Current File : //usr/share/doc/dbus/api/dbus-internals_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-internals.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-internals.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-internals.c  random utility stuff (internal to D-Bus implementation)</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2002, 2003  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-protocol.h&quot;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &quot;dbus-marshal-basic.h&quot;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include &quot;dbus-test.h&quot;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &quot;dbus-valgrind-internal.h&quot;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;stdarg.h&gt;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#ifdef DBUS_USE_OUTPUT_DEBUG_STRING</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span><span class="preprocessor">#include &lt;windows.h&gt;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;mbstring.h&gt;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#endif</span>
<a name="l00038"></a>00038 <span class="preprocessor"></span>
<a name="l00184"></a><a class="code" href="group__DBusInternalsUtils.html#gadb458811a027c9bbae57216a4c33a5f7">00184</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="group__DBusInternalsUtils.html#gadb458811a027c9bbae57216a4c33a5f7" title="Fixed &quot;out of memory&quot; error message, just to avoid making up a different string every time and wastin...">_dbus_no_memory_message</a> = <span class="stringliteral">&quot;Not enough memory&quot;</span>;
<a name="l00185"></a>00185 
<a name="l00186"></a>00186 <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> warn_initted = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00187"></a>00187 <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> fatal_warnings = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00188"></a>00188 <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> fatal_warnings_on_check_failed = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00189"></a>00189 
<a name="l00190"></a>00190 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00191"></a>00191 init_warnings(<span class="keywordtype">void</span>)
<a name="l00192"></a>00192 {
<a name="l00193"></a>00193   <span class="keywordflow">if</span> (!warn_initted)
<a name="l00194"></a>00194     {
<a name="l00195"></a>00195       <span class="keyword">const</span> <span class="keywordtype">char</span> *s;
<a name="l00196"></a>00196       s = <a class="code" href="group__DBusSysdeps.html#gab846071a4de54cb7e518654f9375313a" title="Wrapper for getenv().">_dbus_getenv</a> (<span class="stringliteral">&quot;DBUS_FATAL_WARNINGS&quot;</span>);
<a name="l00197"></a>00197       <span class="keywordflow">if</span> (s &amp;&amp; *s)
<a name="l00198"></a>00198         {
<a name="l00199"></a>00199           <span class="keywordflow">if</span> (*s == <span class="charliteral">&#39;0&#39;</span>)
<a name="l00200"></a>00200             {
<a name="l00201"></a>00201               fatal_warnings = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00202"></a>00202               fatal_warnings_on_check_failed = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00203"></a>00203             }
<a name="l00204"></a>00204           <span class="keywordflow">else</span> <span class="keywordflow">if</span> (*s == <span class="charliteral">&#39;1&#39;</span>)
<a name="l00205"></a>00205             {
<a name="l00206"></a>00206               fatal_warnings = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00207"></a>00207               fatal_warnings_on_check_failed = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00208"></a>00208             }
<a name="l00209"></a>00209           <span class="keywordflow">else</span>
<a name="l00210"></a>00210             {
<a name="l00211"></a>00211               fprintf(stderr, <span class="stringliteral">&quot;DBUS_FATAL_WARNINGS should be set to 0 or 1 if set, not &#39;%s&#39;&quot;</span>,
<a name="l00212"></a>00212                       s);
<a name="l00213"></a>00213             }
<a name="l00214"></a>00214         }
<a name="l00215"></a>00215 
<a name="l00216"></a>00216       warn_initted = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00217"></a>00217     }
<a name="l00218"></a>00218 }
<a name="l00219"></a>00219 
<a name="l00229"></a>00229 <span class="keywordtype">void</span>
<a name="l00230"></a><a class="code" href="group__DBusInternalsUtils.html#gabea2c16d6d3fe7c4eb5b9496fc877f84">00230</a> <a class="code" href="group__DBusInternalsUtils.html#gabea2c16d6d3fe7c4eb5b9496fc877f84" title="Prints a warning message to stderr.">_dbus_warn</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> *format,
<a name="l00231"></a>00231             ...)
<a name="l00232"></a>00232 {
<a name="l00233"></a>00233   va_list args;
<a name="l00234"></a>00234 
<a name="l00235"></a>00235   <span class="keywordflow">if</span> (!warn_initted)
<a name="l00236"></a>00236     init_warnings ();
<a name="l00237"></a>00237   
<a name="l00238"></a>00238   va_start (args, format);
<a name="l00239"></a>00239   vfprintf (stderr, format, args);
<a name="l00240"></a>00240   va_end (args);
<a name="l00241"></a>00241 
<a name="l00242"></a>00242   <span class="keywordflow">if</span> (fatal_warnings)
<a name="l00243"></a>00243     {
<a name="l00244"></a>00244       fflush (stderr);
<a name="l00245"></a>00245       <a class="code" href="group__DBusSysdeps.html#ga83c51771d3c4e612522bd5ad72e6ad7a" title="Aborts the program with SIGABRT (dumping core).">_dbus_abort</a> ();
<a name="l00246"></a>00246     }
<a name="l00247"></a>00247 }
<a name="l00248"></a>00248 
<a name="l00257"></a>00257 <span class="keywordtype">void</span>
<a name="l00258"></a><a class="code" href="group__DBusInternalsUtils.html#ga63f2f8a068454b781f214ba596e313b4">00258</a> <a class="code" href="group__DBusInternalsUtils.html#ga63f2f8a068454b781f214ba596e313b4" title="Prints a &quot;critical&quot; warning to stderr when an assertion fails; differs from _dbus_warn primarily in t...">_dbus_warn_check_failed</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *format,
<a name="l00259"></a>00259                         ...)
<a name="l00260"></a>00260 {
<a name="l00261"></a>00261   va_list args;
<a name="l00262"></a>00262   
<a name="l00263"></a>00263   <span class="keywordflow">if</span> (!warn_initted)
<a name="l00264"></a>00264     init_warnings ();
<a name="l00265"></a>00265 
<a name="l00266"></a>00266   fprintf (stderr, <span class="stringliteral">&quot;process %lu: &quot;</span>, <a class="code" href="group__DBusSysdeps.html#ga1b30aa55e8758ed6e1b62e0f86866543" title="The only reason this is separate from _dbus_getpid() is to allow it on Windows for logging but not fo...">_dbus_pid_for_log</a> ());
<a name="l00267"></a>00267   
<a name="l00268"></a>00268   va_start (args, format);
<a name="l00269"></a>00269   vfprintf (stderr, format, args);
<a name="l00270"></a>00270   va_end (args);
<a name="l00271"></a>00271 
<a name="l00272"></a>00272   <span class="keywordflow">if</span> (fatal_warnings_on_check_failed)
<a name="l00273"></a>00273     {
<a name="l00274"></a>00274       fflush (stderr);
<a name="l00275"></a>00275       <a class="code" href="group__DBusSysdeps.html#ga83c51771d3c4e612522bd5ad72e6ad7a" title="Aborts the program with SIGABRT (dumping core).">_dbus_abort</a> ();
<a name="l00276"></a>00276     }
<a name="l00277"></a>00277 }
<a name="l00278"></a>00278 
<a name="l00279"></a>00279 <span class="preprocessor">#ifdef DBUS_ENABLE_VERBOSE_MODE</span>
<a name="l00280"></a>00280 <span class="preprocessor"></span>
<a name="l00281"></a>00281 <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> verbose_initted = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00282"></a>00282 <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> verbose = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00283"></a>00283 
<a name="l00285"></a>00285 <span class="preprocessor">#define PTHREAD_IN_VERBOSE 0</span>
<a name="l00286"></a>00286 <span class="preprocessor"></span><span class="preprocessor">#if PTHREAD_IN_VERBOSE</span>
<a name="l00287"></a>00287 <span class="preprocessor"></span><span class="preprocessor">#include &lt;pthread.h&gt;</span>
<a name="l00288"></a>00288 <span class="preprocessor">#endif</span>
<a name="l00289"></a>00289 <span class="preprocessor"></span>
<a name="l00290"></a>00290 <span class="preprocessor">#ifdef DBUS_USE_OUTPUT_DEBUG_STRING</span>
<a name="l00291"></a>00291 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">char</span> module_name[1024];
<a name="l00292"></a>00292 <span class="preprocessor">#endif</span>
<a name="l00293"></a>00293 <span class="preprocessor"></span>
<a name="l00294"></a>00294 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span>
<a name="l00295"></a>00295 _dbus_verbose_init (<span class="keywordtype">void</span>)
<a name="l00296"></a>00296 {
<a name="l00297"></a>00297   <span class="keywordflow">if</span> (!verbose_initted)
<a name="l00298"></a>00298     {
<a name="l00299"></a>00299       <span class="keyword">const</span> <span class="keywordtype">char</span> *p = <a class="code" href="group__DBusSysdeps.html#gab846071a4de54cb7e518654f9375313a" title="Wrapper for getenv().">_dbus_getenv</a> (<span class="stringliteral">&quot;DBUS_VERBOSE&quot;</span>);
<a name="l00300"></a>00300       verbose = p != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a> &amp;&amp; *p == <span class="charliteral">&#39;1&#39;</span>;
<a name="l00301"></a>00301       verbose_initted = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00302"></a>00302 <span class="preprocessor">#ifdef DBUS_USE_OUTPUT_DEBUG_STRING</span>
<a name="l00303"></a>00303 <span class="preprocessor"></span>      {
<a name="l00304"></a>00304         <span class="keywordtype">char</span> *last_period, *last_slash;
<a name="l00305"></a>00305         GetModuleFileName(0,module_name,<span class="keyword">sizeof</span>(module_name)-1);
<a name="l00306"></a>00306         last_period = _mbsrchr(module_name,<span class="charliteral">&#39;.&#39;</span>);
<a name="l00307"></a>00307         <span class="keywordflow">if</span> (last_period)
<a name="l00308"></a>00308           *last_period =<span class="charliteral">&#39;\0&#39;</span>;
<a name="l00309"></a>00309         last_slash = _mbsrchr(module_name,<span class="charliteral">&#39;\\&#39;</span>);
<a name="l00310"></a>00310         <span class="keywordflow">if</span> (last_slash)
<a name="l00311"></a>00311           strcpy(module_name,last_slash+1);
<a name="l00312"></a>00312         strcat(module_name,<span class="stringliteral">&quot;: &quot;</span>);
<a name="l00313"></a>00313       }
<a name="l00314"></a>00314 <span class="preprocessor">#endif</span>
<a name="l00315"></a>00315 <span class="preprocessor"></span>    }
<a name="l00316"></a>00316 }
<a name="l00317"></a>00317 
<a name="l00323"></a>00323 <span class="preprocessor">#ifdef DBUS_WIN </span>
<a name="l00324"></a>00324 <span class="preprocessor"></span><span class="preprocessor">#define DBUS_IS_DIR_SEPARATOR(c) (c == &#39;\\&#39; || c == &#39;/&#39;)</span>
<a name="l00325"></a>00325 <span class="preprocessor"></span><span class="preprocessor">#else</span>
<a name="l00326"></a>00326 <span class="preprocessor"></span><span class="preprocessor">#define DBUS_IS_DIR_SEPARATOR(c) (c == &#39;/&#39;)</span>
<a name="l00327"></a>00327 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00328"></a>00328 <span class="preprocessor"></span>
<a name="l00333"></a>00333 <span class="keyword">static</span> <span class="keywordtype">char</span> *_dbus_file_path_extract_elements_from_tail(<span class="keyword">const</span> <span class="keywordtype">char</span> *file,<span class="keywordtype">int</span> level)
<a name="l00334"></a>00334 {
<a name="l00335"></a>00335   <span class="keywordtype">int</span> prefix = 0;
<a name="l00336"></a>00336   <span class="keywordtype">char</span> *p = (<span class="keywordtype">char</span> *)file + strlen(file);
<a name="l00337"></a>00337   <span class="keywordtype">int</span> i = 0;
<a name="l00338"></a>00338 
<a name="l00339"></a>00339   <span class="keywordflow">for</span> (;p &gt;= file;p--)
<a name="l00340"></a>00340     {
<a name="l00341"></a>00341       <span class="keywordflow">if</span> (DBUS_IS_DIR_SEPARATOR(*p))
<a name="l00342"></a>00342         {
<a name="l00343"></a>00343           <span class="keywordflow">if</span> (++i &gt;= level)
<a name="l00344"></a>00344             {
<a name="l00345"></a>00345               prefix = p-file+1;
<a name="l00346"></a>00346               <span class="keywordflow">break</span>;
<a name="l00347"></a>00347             }
<a name="l00348"></a>00348        }
<a name="l00349"></a>00349     }
<a name="l00350"></a>00350 
<a name="l00351"></a>00351   <span class="keywordflow">return</span> (<span class="keywordtype">char</span> *)file+prefix;
<a name="l00352"></a>00352 }
<a name="l00353"></a>00353 
<a name="l00359"></a>00359 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00360"></a>00360 _dbus_is_verbose_real (<span class="keywordtype">void</span>)
<a name="l00361"></a>00361 {
<a name="l00362"></a>00362   _dbus_verbose_init ();
<a name="l00363"></a>00363   <span class="keywordflow">return</span> verbose;
<a name="l00364"></a>00364 }
<a name="l00365"></a>00365 
<a name="l00374"></a>00374 <span class="keywordtype">void</span>
<a name="l00375"></a>00375 _dbus_verbose_real (
<a name="l00376"></a>00376 #ifdef DBUS_CPP_SUPPORTS_VARIABLE_MACRO_ARGUMENTS
<a name="l00377"></a>00377                     <span class="keyword">const</span> <span class="keywordtype">char</span> *file,
<a name="l00378"></a>00378                     <span class="keyword">const</span> <span class="keywordtype">int</span> line, 
<a name="l00379"></a>00379                     <span class="keyword">const</span> <span class="keywordtype">char</span> *<span class="keyword">function</span>, 
<a name="l00380"></a>00380 #endif
<a name="l00381"></a>00381                     <span class="keyword">const</span> <span class="keywordtype">char</span> *format,
<a name="l00382"></a>00382                     ...)
<a name="l00383"></a>00383 {
<a name="l00384"></a>00384   va_list args;
<a name="l00385"></a>00385   <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> need_pid = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00386"></a>00386   <span class="keywordtype">int</span> len;
<a name="l00387"></a>00387   
<a name="l00388"></a>00388   <span class="comment">/* things are written a bit oddly here so that</span>
<a name="l00389"></a>00389 <span class="comment">   * in the non-verbose case we just have the one</span>
<a name="l00390"></a>00390 <span class="comment">   * conditional and return immediately.</span>
<a name="l00391"></a>00391 <span class="comment">   */</span>
<a name="l00392"></a>00392   <span class="keywordflow">if</span> (!_dbus_is_verbose_real())
<a name="l00393"></a>00393     <span class="keywordflow">return</span>;
<a name="l00394"></a>00394 
<a name="l00395"></a>00395 <span class="preprocessor">#ifndef DBUS_USE_OUTPUT_DEBUG_STRING</span>
<a name="l00396"></a>00396 <span class="preprocessor"></span>  <span class="comment">/* Print out pid before the line */</span>
<a name="l00397"></a>00397   <span class="keywordflow">if</span> (need_pid)
<a name="l00398"></a>00398     {
<a name="l00399"></a>00399 <span class="preprocessor">#if PTHREAD_IN_VERBOSE</span>
<a name="l00400"></a>00400 <span class="preprocessor"></span>      fprintf (stderr, <span class="stringliteral">&quot;%lu: 0x%lx: &quot;</span>, <a class="code" href="group__DBusSysdeps.html#ga1b30aa55e8758ed6e1b62e0f86866543" title="The only reason this is separate from _dbus_getpid() is to allow it on Windows for logging but not fo...">_dbus_pid_for_log</a> (), pthread_self ());
<a name="l00401"></a>00401 <span class="preprocessor">#else</span>
<a name="l00402"></a>00402 <span class="preprocessor"></span>      fprintf (stderr, <span class="stringliteral">&quot;%lu: &quot;</span>, <a class="code" href="group__DBusSysdeps.html#ga1b30aa55e8758ed6e1b62e0f86866543" title="The only reason this is separate from _dbus_getpid() is to allow it on Windows for logging but not fo...">_dbus_pid_for_log</a> ());
<a name="l00403"></a>00403 <span class="preprocessor">#endif</span>
<a name="l00404"></a>00404 <span class="preprocessor"></span>    }
<a name="l00405"></a>00405 <span class="preprocessor">#endif</span>
<a name="l00406"></a>00406 <span class="preprocessor"></span>
<a name="l00407"></a>00407   <span class="comment">/* Only print pid again if the next line is a new line */</span>
<a name="l00408"></a>00408   len = strlen (format);
<a name="l00409"></a>00409   <span class="keywordflow">if</span> (format[len-1] == <span class="charliteral">&#39;\n&#39;</span>)
<a name="l00410"></a>00410     need_pid = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00411"></a>00411   <span class="keywordflow">else</span>
<a name="l00412"></a>00412     need_pid = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00413"></a>00413 
<a name="l00414"></a>00414   va_start (args, format);
<a name="l00415"></a>00415 <span class="preprocessor">#ifdef DBUS_USE_OUTPUT_DEBUG_STRING</span>
<a name="l00416"></a>00416 <span class="preprocessor"></span>  {
<a name="l00417"></a>00417   <span class="keywordtype">char</span> buf[1024];
<a name="l00418"></a>00418   strcpy(buf,module_name);
<a name="l00419"></a>00419 <span class="preprocessor">#ifdef DBUS_CPP_SUPPORTS_VARIABLE_MACRO_ARGUMENTS</span>
<a name="l00420"></a>00420 <span class="preprocessor"></span>  sprintf (buf+strlen(buf), <span class="stringliteral">&quot;[%s(%d):%s] &quot;</span>,_dbus_file_path_extract_elements_from_tail(file,2),line,<span class="keyword">function</span>);
<a name="l00421"></a>00421 <span class="preprocessor">#endif</span>
<a name="l00422"></a>00422 <span class="preprocessor"></span>  vsprintf (buf+strlen(buf),format, args);
<a name="l00423"></a>00423   va_end (args);
<a name="l00424"></a>00424   OutputDebugStringA(buf);
<a name="l00425"></a>00425   }
<a name="l00426"></a>00426 <span class="preprocessor">#else</span>
<a name="l00427"></a>00427 <span class="preprocessor"></span><span class="preprocessor">#ifdef DBUS_CPP_SUPPORTS_VARIABLE_MACRO_ARGUMENTS</span>
<a name="l00428"></a>00428 <span class="preprocessor"></span>  fprintf (stderr, <span class="stringliteral">&quot;[%s(%d):%s] &quot;</span>,_dbus_file_path_extract_elements_from_tail(file,2),line,<span class="keyword">function</span>);
<a name="l00429"></a>00429 <span class="preprocessor">#endif</span>
<a name="l00430"></a>00430 <span class="preprocessor"></span>
<a name="l00431"></a>00431   vfprintf (stderr, format, args);
<a name="l00432"></a>00432   va_end (args);
<a name="l00433"></a>00433 
<a name="l00434"></a>00434   fflush (stderr);
<a name="l00435"></a>00435 <span class="preprocessor">#endif</span>
<a name="l00436"></a>00436 <span class="preprocessor"></span>}
<a name="l00437"></a>00437 
<a name="l00444"></a>00444 <span class="keywordtype">void</span>
<a name="l00445"></a>00445 _dbus_verbose_reset_real (<span class="keywordtype">void</span>)
<a name="l00446"></a>00446 {
<a name="l00447"></a>00447   verbose_initted = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00448"></a>00448 }
<a name="l00449"></a>00449 
<a name="l00450"></a>00450 <span class="keywordtype">void</span>
<a name="l00451"></a>00451 _dbus_trace_ref (<span class="keyword">const</span> <span class="keywordtype">char</span> *obj_name,
<a name="l00452"></a>00452                  <span class="keywordtype">void</span>       *obj,
<a name="l00453"></a>00453                  <span class="keywordtype">int</span>         old_refcount,
<a name="l00454"></a>00454                  <span class="keywordtype">int</span>         new_refcount,
<a name="l00455"></a>00455                  <span class="keyword">const</span> <span class="keywordtype">char</span> *why,
<a name="l00456"></a>00456                  <span class="keyword">const</span> <span class="keywordtype">char</span> *env_var,
<a name="l00457"></a>00457                  <span class="keywordtype">int</span>        *enabled)
<a name="l00458"></a>00458 {
<a name="l00459"></a>00459   _dbus_assert (obj_name != <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   _dbus_assert (obj != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00461"></a>00461   _dbus_assert (old_refcount &gt;= -1);
<a name="l00462"></a>00462   _dbus_assert (new_refcount &gt;= -1);
<a name="l00463"></a>00463 
<a name="l00464"></a>00464   <span class="keywordflow">if</span> (old_refcount == -1)
<a name="l00465"></a>00465     {
<a name="l00466"></a>00466       _dbus_assert (new_refcount == -1);
<a name="l00467"></a>00467     }
<a name="l00468"></a>00468   <span class="keywordflow">else</span>
<a name="l00469"></a>00469     {
<a name="l00470"></a>00470       _dbus_assert (new_refcount &gt;= 0);
<a name="l00471"></a>00471       _dbus_assert (old_refcount &gt;= 0);
<a name="l00472"></a>00472       _dbus_assert (old_refcount &gt; 0 || new_refcount &gt; 0);
<a name="l00473"></a>00473     }
<a name="l00474"></a>00474 
<a name="l00475"></a>00475   _dbus_assert (why != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00476"></a>00476   _dbus_assert (env_var != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00477"></a>00477   _dbus_assert (enabled != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00478"></a>00478 
<a name="l00479"></a>00479   <span class="keywordflow">if</span> (*enabled &lt; 0)
<a name="l00480"></a>00480     {
<a name="l00481"></a>00481       <span class="keyword">const</span> <span class="keywordtype">char</span> *s = <a class="code" href="group__DBusSysdeps.html#gab846071a4de54cb7e518654f9375313a" title="Wrapper for getenv().">_dbus_getenv</a> (env_var);
<a name="l00482"></a>00482 
<a name="l00483"></a>00483       *enabled = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00484"></a>00484 
<a name="l00485"></a>00485       <span class="keywordflow">if</span> (s &amp;&amp; *s)
<a name="l00486"></a>00486         {
<a name="l00487"></a>00487           <span class="keywordflow">if</span> (*s == <span class="charliteral">&#39;0&#39;</span>)
<a name="l00488"></a>00488             *enabled = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00489"></a>00489           <span class="keywordflow">else</span> <span class="keywordflow">if</span> (*s == <span class="charliteral">&#39;1&#39;</span>)
<a name="l00490"></a>00490             *enabled = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00491"></a>00491           <span class="keywordflow">else</span>
<a name="l00492"></a>00492             <a class="code" href="group__DBusInternalsUtils.html#gabea2c16d6d3fe7c4eb5b9496fc877f84" title="Prints a warning message to stderr.">_dbus_warn</a> (<span class="stringliteral">&quot;%s should be 0 or 1 if set, not &#39;%s&#39;&quot;</span>, env_var, s);
<a name="l00493"></a>00493         }
<a name="l00494"></a>00494     }
<a name="l00495"></a>00495 
<a name="l00496"></a>00496   <span class="keywordflow">if</span> (*enabled)
<a name="l00497"></a>00497     {
<a name="l00498"></a>00498       <span class="keywordflow">if</span> (old_refcount == -1)
<a name="l00499"></a>00499         {
<a name="l00500"></a>00500           VALGRIND_PRINTF_BACKTRACE (<span class="stringliteral">&quot;%s %p ref stolen (%s)&quot;</span>,
<a name="l00501"></a>00501                                      obj_name, obj, why);
<a name="l00502"></a>00502           _dbus_verbose (<span class="stringliteral">&quot;%s %p ref stolen (%s)\n&quot;</span>,
<a name="l00503"></a>00503                          obj_name, obj, why);
<a name="l00504"></a>00504         }
<a name="l00505"></a>00505       <span class="keywordflow">else</span>
<a name="l00506"></a>00506         {
<a name="l00507"></a>00507           VALGRIND_PRINTF_BACKTRACE (<span class="stringliteral">&quot;%s %p %d -&gt; %d refs (%s)&quot;</span>,
<a name="l00508"></a>00508                                      obj_name, obj,
<a name="l00509"></a>00509                                      old_refcount, new_refcount, why);
<a name="l00510"></a>00510           _dbus_verbose (<span class="stringliteral">&quot;%s %p %d -&gt; %d refs (%s)\n&quot;</span>,
<a name="l00511"></a>00511                          obj_name, obj, old_refcount, new_refcount, why);
<a name="l00512"></a>00512         }
<a name="l00513"></a>00513     }
<a name="l00514"></a>00514 }
<a name="l00515"></a>00515 
<a name="l00516"></a>00516 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_ENABLE_VERBOSE_MODE */</span>
<a name="l00517"></a>00517 
<a name="l00526"></a>00526 <span class="keywordtype">char</span>*
<a name="l00527"></a><a class="code" href="group__DBusInternalsUtils.html#ga9d00d77f6595b9d7ac1baf59d44bf58c">00527</a> <a class="code" href="group__DBusInternalsUtils.html#ga9d00d77f6595b9d7ac1baf59d44bf58c" title="Duplicates a string.">_dbus_strdup</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> *str)
<a name="l00528"></a>00528 {
<a name="l00529"></a>00529   <span class="keywordtype">size_t</span> len;
<a name="l00530"></a>00530   <span class="keywordtype">char</span> *copy;
<a name="l00531"></a>00531   
<a name="l00532"></a>00532   <span class="keywordflow">if</span> (str == <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     <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="l00534"></a>00534   
<a name="l00535"></a>00535   len = strlen (str);
<a name="l00536"></a>00536 
<a name="l00537"></a>00537   copy = <a class="code" href="group__DBusMemory.html#gaf6e588659067a854c3cca7ebe8ae5084" title="Allocates the given number of bytes, as with standard malloc().">dbus_malloc</a> (len + 1);
<a name="l00538"></a>00538   <span class="keywordflow">if</span> (copy == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00539"></a>00539     <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="l00540"></a>00540 
<a name="l00541"></a>00541   memcpy (copy, str, len + 1);
<a name="l00542"></a>00542   
<a name="l00543"></a>00543   <span class="keywordflow">return</span> copy;
<a name="l00544"></a>00544 }
<a name="l00545"></a>00545 
<a name="l00554"></a>00554 <span class="keywordtype">void</span>*
<a name="l00555"></a><a class="code" href="group__DBusInternalsUtils.html#gaad95864dca5140b730bc143cb2d1b024">00555</a> <a class="code" href="group__DBusInternalsUtils.html#gaad95864dca5140b730bc143cb2d1b024" title="Duplicates a block of memory.">_dbus_memdup</a> (<span class="keyword">const</span> <span class="keywordtype">void</span>  *mem,
<a name="l00556"></a>00556               <span class="keywordtype">size_t</span>       n_bytes)
<a name="l00557"></a>00557 {
<a name="l00558"></a>00558   <span class="keywordtype">void</span> *copy;
<a name="l00559"></a>00559 
<a name="l00560"></a>00560   copy = <a class="code" href="group__DBusMemory.html#gaf6e588659067a854c3cca7ebe8ae5084" title="Allocates the given number of bytes, as with standard malloc().">dbus_malloc</a> (n_bytes);
<a name="l00561"></a>00561   <span class="keywordflow">if</span> (copy == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00562"></a>00562     <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="l00563"></a>00563 
<a name="l00564"></a>00564   memcpy (copy, mem, n_bytes);
<a name="l00565"></a>00565   
<a name="l00566"></a>00566   <span class="keywordflow">return</span> copy;
<a name="l00567"></a>00567 }
<a name="l00568"></a>00568 
<a name="l00577"></a>00577 <span class="keywordtype">char</span>**
<a name="l00578"></a><a class="code" href="group__DBusInternalsUtils.html#ga53bbcbbd0b564c14c599813dde535443">00578</a> <a class="code" href="group__DBusInternalsUtils.html#ga53bbcbbd0b564c14c599813dde535443" title="Duplicates a string array.">_dbus_dup_string_array</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> **array)
<a name="l00579"></a>00579 {
<a name="l00580"></a>00580   <span class="keywordtype">int</span> len;
<a name="l00581"></a>00581   <span class="keywordtype">int</span> i;
<a name="l00582"></a>00582   <span class="keywordtype">char</span> **copy;
<a name="l00583"></a>00583   
<a name="l00584"></a>00584   <span class="keywordflow">if</span> (array == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00585"></a>00585     <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="l00586"></a>00586 
<a name="l00587"></a>00587   <span class="keywordflow">for</span> (len = 0; array[len] != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>; ++len)
<a name="l00588"></a>00588     ;
<a name="l00589"></a>00589 
<a name="l00590"></a>00590   copy = <a class="code" href="group__DBusMemory.html#gaba9d823abda7f4cadbaf5177d3b8b793" title="Safe macro for using dbus_malloc0().">dbus_new0</a> (<span class="keywordtype">char</span>*, len + 1);
<a name="l00591"></a>00591   <span class="keywordflow">if</span> (copy == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00592"></a>00592     <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="l00593"></a>00593 
<a name="l00594"></a>00594   i = 0;
<a name="l00595"></a>00595   <span class="keywordflow">while</span> (i &lt; len)
<a name="l00596"></a>00596     {
<a name="l00597"></a>00597       copy[i] = <a class="code" href="group__DBusInternalsUtils.html#ga9d00d77f6595b9d7ac1baf59d44bf58c" title="Duplicates a string.">_dbus_strdup</a> (array[i]);
<a name="l00598"></a>00598       <span class="keywordflow">if</span> (copy[i] == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00599"></a>00599         {
<a name="l00600"></a>00600           <a class="code" href="group__DBusMemory.html#gac200b2dbc8b3f6ecac4d42426fb97b40" title="Frees a NULL-terminated array of strings.">dbus_free_string_array</a> (copy);
<a name="l00601"></a>00601           <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="l00602"></a>00602         }
<a name="l00603"></a>00603 
<a name="l00604"></a>00604       ++i;
<a name="l00605"></a>00605     }
<a name="l00606"></a>00606 
<a name="l00607"></a>00607   <span class="keywordflow">return</span> copy;
<a name="l00608"></a>00608 }
<a name="l00609"></a>00609 
<a name="l00617"></a>00617 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00618"></a><a class="code" href="group__DBusInternalsUtils.html#ga751119e7273225a7e59787445b71fcd6">00618</a> <a class="code" href="group__DBusInternalsUtils.html#ga751119e7273225a7e59787445b71fcd6" title="Checks whether a string array contains the given string.">_dbus_string_array_contains</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> **array,
<a name="l00619"></a>00619                              <span class="keyword">const</span> <span class="keywordtype">char</span>  *str)
<a name="l00620"></a>00620 {
<a name="l00621"></a>00621   <span class="keywordtype">int</span> i;
<a name="l00622"></a>00622 
<a name="l00623"></a>00623   i = 0;
<a name="l00624"></a>00624   <span class="keywordflow">while</span> (array[i] != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00625"></a>00625     {
<a name="l00626"></a>00626       <span class="keywordflow">if</span> (strcmp (array[i], str) == 0)
<a name="l00627"></a>00627         <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00628"></a>00628       ++i;
<a name="l00629"></a>00629     }
<a name="l00630"></a>00630 
<a name="l00631"></a>00631   <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00632"></a>00632 }
<a name="l00633"></a>00633 
<a name="l00640"></a>00640 <span class="keywordtype">void</span>
<a name="l00641"></a><a class="code" href="group__DBusInternalsUtils.html#ga08c2922335845e5c857e88399436b9ba">00641</a> <a class="code" href="group__DBusInternalsUtils.html#ga08c2922335845e5c857e88399436b9ba" title="Generates a new UUID.">_dbus_generate_uuid</a> (<a class="code" href="group__DBusSysdeps.html#ga24015a2f75b94c1307360755ce97f869" title="Type representing a universally unique ID.">DBusGUID</a> *uuid)
<a name="l00642"></a>00642 {
<a name="l00643"></a>00643   <span class="keywordtype">long</span> now;
<a name="l00644"></a>00644 
<a name="l00645"></a>00645   <span class="comment">/* don&#39;t use monotonic time because the UUID may be saved to disk, e.g.</span>
<a name="l00646"></a>00646 <span class="comment">   * it may persist across reboots</span>
<a name="l00647"></a>00647 <span class="comment">   */</span>
<a name="l00648"></a>00648   <a class="code" href="group__DBusSysdeps.html#gae10ee21ab353beadbe2493728065f600" title="Get current time, as in gettimeofday().">_dbus_get_real_time</a> (&amp;now, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00649"></a>00649 
<a name="l00650"></a>00650   uuid-&gt;as_uint32s[DBUS_UUID_LENGTH_WORDS - 1] = DBUS_UINT32_TO_BE (now);
<a name="l00651"></a>00651   
<a name="l00652"></a>00652   <a class="code" href="group__DBusInternalsUtils.html#gaa32f87746e9264b2425736043d02fad4" title="Fills n_bytes of the given buffer with random bytes.">_dbus_generate_random_bytes_buffer</a> (uuid-&gt;as_bytes, DBUS_UUID_LENGTH_BYTES - 4);
<a name="l00653"></a>00653 }
<a name="l00654"></a>00654 
<a name="l00662"></a>00662 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00663"></a><a class="code" href="group__DBusInternalsUtils.html#gaf08364813376bd2d8f455d435d85323e">00663</a> <a class="code" href="group__DBusInternalsUtils.html#gaf08364813376bd2d8f455d435d85323e" title="Hex-encode a UUID.">_dbus_uuid_encode</a> (<span class="keyword">const</span> <a class="code" href="group__DBusSysdeps.html#ga24015a2f75b94c1307360755ce97f869" title="Type representing a universally unique ID.">DBusGUID</a> *uuid,
<a name="l00664"></a>00664                    <a class="code" href="structDBusString.html">DBusString</a>     *encoded)
<a name="l00665"></a>00665 {
<a name="l00666"></a>00666   <a class="code" href="structDBusString.html">DBusString</a> binary;
<a name="l00667"></a>00667   <a class="code" href="group__DBusString.html#ga6792a5c1725faa9d635d95f7a3b5bfae" title="Initializes a constant string with a length.">_dbus_string_init_const_len</a> (&amp;binary, uuid-&gt;as_bytes, DBUS_UUID_LENGTH_BYTES);
<a name="l00668"></a>00668   <span class="keywordflow">return</span> <a class="code" href="group__DBusString.html#gaabb4873f436e015944a33cd1e3815cc9" title="Encodes a string in hex, the way MD5 and SHA-1 are usually encoded.">_dbus_string_hex_encode</a> (&amp;binary, 0, encoded, <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (encoded));
<a name="l00669"></a>00669 }
<a name="l00670"></a>00670 
<a name="l00671"></a>00671 <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="l00672"></a>00672 _dbus_read_uuid_file_without_creating (<span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *filename,
<a name="l00673"></a>00673                                        <a class="code" href="group__DBusSysdeps.html#ga24015a2f75b94c1307360755ce97f869" title="Type representing a universally unique ID.">DBusGUID</a>         *uuid,
<a name="l00674"></a>00674                                        <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a>        *error)
<a name="l00675"></a>00675 {
<a name="l00676"></a>00676   <a class="code" href="structDBusString.html">DBusString</a> contents;
<a name="l00677"></a>00677   <a class="code" href="structDBusString.html">DBusString</a> decoded;
<a name="l00678"></a>00678   <span class="keywordtype">int</span> end;
<a name="l00679"></a>00679   
<a name="l00680"></a>00680   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&amp;contents))
<a name="l00681"></a>00681     {
<a name="l00682"></a>00682       _DBUS_SET_OOM (error);
<a name="l00683"></a>00683       <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00684"></a>00684     }
<a name="l00685"></a>00685 
<a name="l00686"></a>00686   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&amp;decoded))
<a name="l00687"></a>00687     {
<a name="l00688"></a>00688       <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&amp;contents);
<a name="l00689"></a>00689       _DBUS_SET_OOM (error);
<a name="l00690"></a>00690       <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00691"></a>00691     }
<a name="l00692"></a>00692   
<a name="l00693"></a>00693   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusFile.html#gad22d468e789139c87f7f4bb97cadf448" title="Appends the contents of the given file to the string, returning error code.">_dbus_file_get_contents</a> (&amp;contents, filename, error))
<a name="l00694"></a>00694     <span class="keywordflow">goto</span> error;
<a name="l00695"></a>00695 
<a name="l00696"></a>00696   <a class="code" href="group__DBusString.html#gaa92c6ab2c5e24cbefef0a3f3fc76f98b" title="Deletes leading and trailing whitespace.">_dbus_string_chop_white</a> (&amp;contents);
<a name="l00697"></a>00697 
<a name="l00698"></a>00698   <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&amp;contents) != DBUS_UUID_LENGTH_HEX)
<a name="l00699"></a>00699     {
<a name="l00700"></a>00700       <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#ga6a4e92aa48ed4486eaf48c40c72490c4" title="A file contains invalid syntax or is otherwise broken.">DBUS_ERROR_INVALID_FILE_CONTENT</a>,
<a name="l00701"></a>00701                       <span class="stringliteral">&quot;UUID file &#39;%s&#39; should contain a hex string of length %d, not length %d, with no other text&quot;</span>,
<a name="l00702"></a>00702                       <a class="code" href="group__DBusString.html#ga33e20241ae7d784624f97d89b1a0539e" title="Gets the raw character buffer from a const string.">_dbus_string_get_const_data</a> (filename),
<a name="l00703"></a>00703                       DBUS_UUID_LENGTH_HEX,
<a name="l00704"></a>00704                       <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&amp;contents));
<a name="l00705"></a>00705       <span class="keywordflow">goto</span> error;
<a name="l00706"></a>00706     }
<a name="l00707"></a>00707 
<a name="l00708"></a>00708   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga0a8c20d855f9ddc05718b9e2ac0e33d8" title="Decodes a string from hex encoding.">_dbus_string_hex_decode</a> (&amp;contents, 0, &amp;end, &amp;decoded, 0))
<a name="l00709"></a>00709     {
<a name="l00710"></a>00710       _DBUS_SET_OOM (error);
<a name="l00711"></a>00711       <span class="keywordflow">goto</span> error;
<a name="l00712"></a>00712     }
<a name="l00713"></a>00713 
<a name="l00714"></a>00714   <span class="keywordflow">if</span> (end == 0)
<a name="l00715"></a>00715     {
<a name="l00716"></a>00716       <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#ga6a4e92aa48ed4486eaf48c40c72490c4" title="A file contains invalid syntax or is otherwise broken.">DBUS_ERROR_INVALID_FILE_CONTENT</a>,
<a name="l00717"></a>00717                       <span class="stringliteral">&quot;UUID file &#39;%s&#39; contains invalid hex data&quot;</span>,
<a name="l00718"></a>00718                       <a class="code" href="group__DBusString.html#ga33e20241ae7d784624f97d89b1a0539e" title="Gets the raw character buffer from a const string.">_dbus_string_get_const_data</a> (filename));
<a name="l00719"></a>00719       <span class="keywordflow">goto</span> error;
<a name="l00720"></a>00720     }
<a name="l00721"></a>00721 
<a name="l00722"></a>00722   <span class="keywordflow">if</span> (<a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&amp;decoded) != DBUS_UUID_LENGTH_BYTES)
<a name="l00723"></a>00723     {
<a name="l00724"></a>00724       <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#ga6a4e92aa48ed4486eaf48c40c72490c4" title="A file contains invalid syntax or is otherwise broken.">DBUS_ERROR_INVALID_FILE_CONTENT</a>,
<a name="l00725"></a>00725                       <span class="stringliteral">&quot;UUID file &#39;%s&#39; contains %d bytes of hex-encoded data instead of %d&quot;</span>,
<a name="l00726"></a>00726                       <a class="code" href="group__DBusString.html#ga33e20241ae7d784624f97d89b1a0539e" title="Gets the raw character buffer from a const string.">_dbus_string_get_const_data</a> (filename),
<a name="l00727"></a>00727                       <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&amp;decoded),
<a name="l00728"></a>00728                       DBUS_UUID_LENGTH_BYTES);
<a name="l00729"></a>00729       <span class="keywordflow">goto</span> error;
<a name="l00730"></a>00730     }
<a name="l00731"></a>00731 
<a name="l00732"></a>00732   <a class="code" href="group__DBusString.html#gaf97b18e419678dbf967d9b9ad1112ca6" title="Copies the contents of a DBusString into a different buffer.">_dbus_string_copy_to_buffer</a> (&amp;decoded, uuid-&gt;as_bytes, DBUS_UUID_LENGTH_BYTES);
<a name="l00733"></a>00733 
<a name="l00734"></a>00734   <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&amp;decoded);
<a name="l00735"></a>00735   <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&amp;contents);
<a name="l00736"></a>00736 
<a name="l00737"></a>00737   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
<a name="l00738"></a>00738 
<a name="l00739"></a>00739   <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00740"></a>00740   
<a name="l00741"></a>00741  error:
<a name="l00742"></a>00742   _DBUS_ASSERT_ERROR_IS_SET (error);
<a name="l00743"></a>00743   <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&amp;contents);
<a name="l00744"></a>00744   <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&amp;decoded);
<a name="l00745"></a>00745   <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00746"></a>00746 }
<a name="l00747"></a>00747 
<a name="l00756"></a>00756 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00757"></a><a class="code" href="group__DBusInternalsUtils.html#gaa16de06b33c56323fa33dd96eaab3829">00757</a> <a class="code" href="group__DBusInternalsUtils.html#gaa16de06b33c56323fa33dd96eaab3829" title="Write the give UUID to a file.">_dbus_write_uuid_file</a> (<span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *filename,
<a name="l00758"></a>00758                        <span class="keyword">const</span> <a class="code" href="group__DBusSysdeps.html#ga24015a2f75b94c1307360755ce97f869" title="Type representing a universally unique ID.">DBusGUID</a>   *uuid,
<a name="l00759"></a>00759                        <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a>        *error)
<a name="l00760"></a>00760 {
<a name="l00761"></a>00761   <a class="code" href="structDBusString.html">DBusString</a> encoded;
<a name="l00762"></a>00762 
<a name="l00763"></a>00763   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&amp;encoded))
<a name="l00764"></a>00764     {
<a name="l00765"></a>00765       _DBUS_SET_OOM (error);
<a name="l00766"></a>00766       <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00767"></a>00767     }
<a name="l00768"></a>00768   
<a name="l00769"></a>00769   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusInternalsUtils.html#gaf08364813376bd2d8f455d435d85323e" title="Hex-encode a UUID.">_dbus_uuid_encode</a> (uuid, &amp;encoded))
<a name="l00770"></a>00770     {
<a name="l00771"></a>00771       _DBUS_SET_OOM (error);
<a name="l00772"></a>00772       <span class="keywordflow">goto</span> error;
<a name="l00773"></a>00773     }
<a name="l00774"></a>00774   
<a name="l00775"></a>00775   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#gaa6ecf36e70263659f921a4ef0335db12" title="Appends a single byte to the string, returning FALSE if not enough memory.">_dbus_string_append_byte</a> (&amp;encoded, <span class="charliteral">&#39;\n&#39;</span>))
<a name="l00776"></a>00776     {
<a name="l00777"></a>00777       _DBUS_SET_OOM (error);
<a name="l00778"></a>00778       <span class="keywordflow">goto</span> error;
<a name="l00779"></a>00779     }
<a name="l00780"></a>00780   
<a name="l00781"></a>00781   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusFile.html#ga2adba123fde18c9d1d9eaf1347980d57" title="Writes a string out to a file.">_dbus_string_save_to_file</a> (&amp;encoded, filename, <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>, error))
<a name="l00782"></a>00782     <span class="keywordflow">goto</span> error;
<a name="l00783"></a>00783 
<a name="l00784"></a>00784   <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&amp;encoded);
<a name="l00785"></a>00785 
<a name="l00786"></a>00786   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
<a name="l00787"></a>00787   <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00788"></a>00788   
<a name="l00789"></a>00789  error:
<a name="l00790"></a>00790   _DBUS_ASSERT_ERROR_IS_SET (error);
<a name="l00791"></a>00791   <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&amp;encoded);
<a name="l00792"></a>00792   <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;        
<a name="l00793"></a>00793 }
<a name="l00794"></a>00794 
<a name="l00805"></a>00805 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00806"></a><a class="code" href="group__DBusInternalsUtils.html#ga709fd30e6b940a5952af38efaf24ad51">00806</a> <a class="code" href="group__DBusInternalsUtils.html#ga709fd30e6b940a5952af38efaf24ad51" title="Reads (and optionally writes) a uuid to a file.">_dbus_read_uuid_file</a> (<span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *filename,
<a name="l00807"></a>00807                       <a class="code" href="group__DBusSysdeps.html#ga24015a2f75b94c1307360755ce97f869" title="Type representing a universally unique ID.">DBusGUID</a>         *uuid,
<a name="l00808"></a>00808                       <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>       create_if_not_found,
<a name="l00809"></a>00809                       <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a>        *error)
<a name="l00810"></a>00810 {
<a name="l00811"></a>00811   <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a> read_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="l00812"></a>00812 
<a name="l00813"></a>00813   <span class="keywordflow">if</span> (_dbus_read_uuid_file_without_creating (filename, uuid, &amp;read_error))
<a name="l00814"></a>00814     <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00815"></a>00815 
<a name="l00816"></a>00816   <span class="keywordflow">if</span> (!create_if_not_found)
<a name="l00817"></a>00817     {
<a name="l00818"></a>00818       <a class="code" href="group__DBusErrors.html#ga0a27fb9f1af0c2bfd105d7e8622b93f4" title="Moves an error src into dest, freeing src and overwriting dest.">dbus_move_error</a> (&amp;read_error, error);
<a name="l00819"></a>00819       <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00820"></a>00820     }
<a name="l00821"></a>00821 
<a name="l00822"></a>00822   <span class="comment">/* If the file exists and contains junk, we want to keep that error</span>
<a name="l00823"></a>00823 <span class="comment">   * message instead of overwriting it with a &quot;file exists&quot; error</span>
<a name="l00824"></a>00824 <span class="comment">   * message when we try to write</span>
<a name="l00825"></a>00825 <span class="comment">   */</span>
<a name="l00826"></a>00826   <span class="keywordflow">if</span> (<a class="code" href="group__DBusErrors.html#ga48515c580199514026542fe053ef1887" title="Checks whether the error is set and has the given name.">dbus_error_has_name</a> (&amp;read_error, <a class="code" href="group__DBusProtocol.html#ga6a4e92aa48ed4486eaf48c40c72490c4" title="A file contains invalid syntax or is otherwise broken.">DBUS_ERROR_INVALID_FILE_CONTENT</a>))
<a name="l00827"></a>00827     {
<a name="l00828"></a>00828       <a class="code" href="group__DBusErrors.html#ga0a27fb9f1af0c2bfd105d7e8622b93f4" title="Moves an error src into dest, freeing src and overwriting dest.">dbus_move_error</a> (&amp;read_error, error);
<a name="l00829"></a>00829       <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00830"></a>00830     }
<a name="l00831"></a>00831   <span class="keywordflow">else</span>
<a name="l00832"></a>00832     {
<a name="l00833"></a>00833       <a class="code" href="group__DBusErrors.html#gaac6c14ead14829ee4e090f39de6a7568" title="Frees an error that&#39;s been set (or just initialized), then reinitializes the error as in dbus_error_i...">dbus_error_free</a> (&amp;read_error);
<a name="l00834"></a>00834       <a class="code" href="group__DBusInternalsUtils.html#ga08c2922335845e5c857e88399436b9ba" title="Generates a new UUID.">_dbus_generate_uuid</a> (uuid);
<a name="l00835"></a>00835       <span class="keywordflow">return</span> <a class="code" href="group__DBusInternalsUtils.html#gaa16de06b33c56323fa33dd96eaab3829" title="Write the give UUID to a file.">_dbus_write_uuid_file</a> (filename, uuid, error);
<a name="l00836"></a>00836     }
<a name="l00837"></a>00837 }
<a name="l00838"></a>00838 
<a name="l00839"></a>00839 <span class="comment">/* Protected by _DBUS_LOCK (machine_uuid) */</span>
<a name="l00840"></a>00840 <span class="keyword">static</span> <span class="keywordtype">int</span> machine_uuid_initialized_generation = 0;
<a name="l00841"></a>00841 <span class="keyword">static</span> <a class="code" href="group__DBusSysdeps.html#ga24015a2f75b94c1307360755ce97f869" title="Type representing a universally unique ID.">DBusGUID</a> machine_uuid;
<a name="l00842"></a>00842 
<a name="l00853"></a>00853 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00854"></a><a class="code" href="group__DBusInternalsUtils.html#ga49ba67405d677af6cde9329ed87ea91f">00854</a> <a class="code" href="group__DBusInternalsUtils.html#ga49ba67405d677af6cde9329ed87ea91f" title="Gets the hex-encoded UUID of the machine this function is executed on.">_dbus_get_local_machine_uuid_encoded</a> (<a class="code" href="structDBusString.html">DBusString</a> *uuid_str)
<a name="l00855"></a>00855 {
<a name="l00856"></a>00856   <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> ok;
<a name="l00857"></a>00857   
<a name="l00858"></a>00858   <span class="keywordflow">if</span> (!_DBUS_LOCK (machine_uuid))
<a name="l00859"></a>00859     <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00860"></a>00860 
<a name="l00861"></a>00861   <span class="keywordflow">if</span> (machine_uuid_initialized_generation != <a class="code" href="group__DBusMemoryInternals.html#ga7c224d82013e2bdc181c1d85dcb6f295" title="_dbus_current_generation is used to track each time that dbus_shutdown() is called, so we can reinit things after it&#39;s been called.">_dbus_current_generation</a>)
<a name="l00862"></a>00862     {
<a name="l00863"></a>00863       <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a> 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="l00864"></a>00864 
<a name="l00865"></a>00865       <span class="keywordflow">if</span> (!<a class="code" href="group__DBusSysdeps.html#ga3f073afc8ef8397471531baf513e1bb5" title="Reads the uuid of the machine we&#39;re running on from the dbus configuration.">_dbus_read_local_machine_uuid</a> (&amp;machine_uuid, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>,
<a name="l00866"></a>00866                                           &amp;error))
<a name="l00867"></a>00867         {          
<a name="l00868"></a>00868 <span class="preprocessor">#ifndef DBUS_ENABLE_EMBEDDED_TESTS</span>
<a name="l00869"></a>00869 <span class="preprocessor"></span>          <span class="comment">/* For the test suite, we may not be installed so just continue silently</span>
<a name="l00870"></a>00870 <span class="comment">           * here. But in a production build, we want to be nice and loud about</span>
<a name="l00871"></a>00871 <span class="comment">           * this.</span>
<a name="l00872"></a>00872 <span class="comment">           */</span>
<a name="l00873"></a>00873           <a class="code" href="group__DBusInternalsUtils.html#ga63f2f8a068454b781f214ba596e313b4" title="Prints a &quot;critical&quot; warning to stderr when an assertion fails; differs from _dbus_warn primarily in t...">_dbus_warn_check_failed</a> (<span class="stringliteral">&quot;D-Bus library appears to be incorrectly set up; failed to read machine uuid: %s\n&quot;</span>
<a name="l00874"></a>00874                                    <span class="stringliteral">&quot;See the manual page for dbus-uuidgen to correct this issue.\n&quot;</span>,
<a name="l00875"></a>00875                                    error.<a class="code" href="structDBusError.html#afb559175326de5b6b340e26204e92d72" title="public error message field">message</a>);
<a name="l00876"></a>00876 <span class="preprocessor">#endif</span>
<a name="l00877"></a>00877 <span class="preprocessor"></span>          
<a name="l00878"></a>00878           <a class="code" href="group__DBusErrors.html#gaac6c14ead14829ee4e090f39de6a7568" title="Frees an error that&#39;s been set (or just initialized), then reinitializes the error as in dbus_error_i...">dbus_error_free</a> (&amp;error);
<a name="l00879"></a>00879           
<a name="l00880"></a>00880           <a class="code" href="group__DBusInternalsUtils.html#ga08c2922335845e5c857e88399436b9ba" title="Generates a new UUID.">_dbus_generate_uuid</a> (&amp;machine_uuid);
<a name="l00881"></a>00881         }
<a name="l00882"></a>00882     }
<a name="l00883"></a>00883 
<a name="l00884"></a>00884   ok = <a class="code" href="group__DBusInternalsUtils.html#gaf08364813376bd2d8f455d435d85323e" title="Hex-encode a UUID.">_dbus_uuid_encode</a> (&amp;machine_uuid, uuid_str);
<a name="l00885"></a>00885 
<a name="l00886"></a>00886   _DBUS_UNLOCK (machine_uuid);
<a name="l00887"></a>00887 
<a name="l00888"></a>00888   <span class="keywordflow">return</span> ok;
<a name="l00889"></a>00889 }
<a name="l00890"></a>00890 
<a name="l00891"></a>00891 <span class="preprocessor">#ifndef DBUS_DISABLE_CHECKS</span>
<a name="l00892"></a>00892 <span class="preprocessor"></span>
<a name="l00893"></a><a class="code" href="group__DBusInternalsUtils.html#ga748d6ccfb8090bf9f0bf338946c8f5e2">00893</a> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="group__DBusInternalsUtils.html#ga748d6ccfb8090bf9f0bf338946c8f5e2" title="String used in _dbus_return_if_fail macro.">_dbus_return_if_fail_warning_format</a> =
<a name="l00894"></a>00894 <span class="stringliteral">&quot;arguments to %s() were incorrect, assertion \&quot;%s\&quot; failed in file %s line %d.\n&quot;</span>
<a name="l00895"></a>00895 <span class="stringliteral">&quot;This is normally a bug in some application using the D-Bus library.\n&quot;</span>;
<a name="l00896"></a>00896 <span class="preprocessor">#endif</span>
<a name="l00897"></a>00897 <span class="preprocessor"></span>
<a name="l00898"></a>00898 <span class="preprocessor">#ifndef DBUS_DISABLE_ASSERT</span>
<a name="l00899"></a>00899 <span class="preprocessor"></span>
<a name="l00911"></a>00911 <span class="keywordtype">void</span>
<a name="l00912"></a><a class="code" href="group__DBusInternalsUtils.html#ga9912f2c86e49357eb9729729dd46f50d">00912</a> <a class="code" href="group__DBusInternalsUtils.html#ga9912f2c86e49357eb9729729dd46f50d" title="Internals of _dbus_assert(); it&#39;s a function rather than a macro with the inline code so that the ass...">_dbus_real_assert</a> (<a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>  condition,
<a name="l00913"></a>00913                    <span class="keyword">const</span> <span class="keywordtype">char</span>  *condition_text,
<a name="l00914"></a>00914                    <span class="keyword">const</span> <span class="keywordtype">char</span>  *file,
<a name="l00915"></a>00915                    <span class="keywordtype">int</span>          line,
<a name="l00916"></a>00916                    <span class="keyword">const</span> <span class="keywordtype">char</span>  *func)
<a name="l00917"></a>00917 {
<a name="l00918"></a>00918   <span class="keywordflow">if</span> (_DBUS_UNLIKELY (!condition))
<a name="l00919"></a>00919     {
<a name="l00920"></a>00920       <a class="code" href="group__DBusInternalsUtils.html#gabea2c16d6d3fe7c4eb5b9496fc877f84" title="Prints a warning message to stderr.">_dbus_warn</a> (<span class="stringliteral">&quot;%lu: assertion failed \&quot;%s\&quot; file \&quot;%s\&quot; line %d function %s\n&quot;</span>,
<a name="l00921"></a>00921                   <a class="code" href="group__DBusSysdeps.html#ga1b30aa55e8758ed6e1b62e0f86866543" title="The only reason this is separate from _dbus_getpid() is to allow it on Windows for logging but not fo...">_dbus_pid_for_log</a> (), condition_text, file, line, func);
<a name="l00922"></a>00922       <a class="code" href="group__DBusSysdeps.html#ga83c51771d3c4e612522bd5ad72e6ad7a" title="Aborts the program with SIGABRT (dumping core).">_dbus_abort</a> ();
<a name="l00923"></a>00923     }
<a name="l00924"></a>00924 }
<a name="l00925"></a>00925 
<a name="l00936"></a>00936 <span class="keywordtype">void</span>
<a name="l00937"></a><a class="code" href="group__DBusInternalsUtils.html#ga3de125028afc39ab16e6585add8ad181">00937</a> <a class="code" href="group__DBusInternalsUtils.html#ga3de125028afc39ab16e6585add8ad181" title="Internals of _dbus_assert_not_reached(); it&#39;s a function rather than a macro with the inline code so ...">_dbus_real_assert_not_reached</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> *explanation,
<a name="l00938"></a>00938                                <span class="keyword">const</span> <span class="keywordtype">char</span> *file,
<a name="l00939"></a>00939                                <span class="keywordtype">int</span>         line)
<a name="l00940"></a>00940 {
<a name="l00941"></a>00941   <a class="code" href="group__DBusInternalsUtils.html#gabea2c16d6d3fe7c4eb5b9496fc877f84" title="Prints a warning message to stderr.">_dbus_warn</a> (<span class="stringliteral">&quot;File \&quot;%s\&quot; line %d process %lu should not have been reached: %s\n&quot;</span>,
<a name="l00942"></a>00942               file, line, <a class="code" href="group__DBusSysdeps.html#ga1b30aa55e8758ed6e1b62e0f86866543" title="The only reason this is separate from _dbus_getpid() is to allow it on Windows for logging but not fo...">_dbus_pid_for_log</a> (), explanation);
<a name="l00943"></a>00943   <a class="code" href="group__DBusSysdeps.html#ga83c51771d3c4e612522bd5ad72e6ad7a" title="Aborts the program with SIGABRT (dumping core).">_dbus_abort</a> ();
<a name="l00944"></a>00944 }
<a name="l00945"></a>00945 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_DISABLE_ASSERT */</span>
<a name="l00946"></a>00946   
<a name="l00947"></a>00947 <span class="preprocessor">#ifdef DBUS_ENABLE_EMBEDDED_TESTS</span>
<a name="l00948"></a>00948 <span class="preprocessor"></span><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="l00949"></a>00949 run_failing_each_malloc (<span class="keywordtype">int</span>                    n_mallocs,
<a name="l00950"></a>00950                          <span class="keyword">const</span> <span class="keywordtype">char</span>            *description,
<a name="l00951"></a>00951                          DBusTestMemoryFunction func,
<a name="l00952"></a>00952                          <span class="keywordtype">void</span>                  *data)
<a name="l00953"></a>00953 {
<a name="l00954"></a>00954   n_mallocs += 10; <span class="comment">/* fudge factor to ensure reallocs etc. are covered */</span>
<a name="l00955"></a>00955   
<a name="l00956"></a>00956   <span class="keywordflow">while</span> (n_mallocs &gt;= 0)
<a name="l00957"></a>00957     {      
<a name="l00958"></a>00958       _dbus_set_fail_alloc_counter (n_mallocs);
<a name="l00959"></a>00959 
<a name="l00960"></a>00960       _dbus_verbose (<span class="stringliteral">&quot;\n===\n%s: (will fail malloc %d with %d failures)\n===\n&quot;</span>,
<a name="l00961"></a>00961                      description, n_mallocs,
<a name="l00962"></a>00962                      _dbus_get_fail_alloc_failures ());
<a name="l00963"></a>00963 
<a name="l00964"></a>00964       <span class="keywordflow">if</span> (!(* func) (data))
<a name="l00965"></a>00965         <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00966"></a>00966       
<a name="l00967"></a>00967       n_mallocs -= 1;
<a name="l00968"></a>00968     }
<a name="l00969"></a>00969 
<a name="l00970"></a>00970   _dbus_set_fail_alloc_counter (_DBUS_INT_MAX);
<a name="l00971"></a>00971 
<a name="l00972"></a>00972   <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00973"></a>00973 }                        
<a name="l00974"></a>00974 
<a name="l00988"></a>00988 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00989"></a>00989 _dbus_test_oom_handling (<span class="keyword">const</span> <span class="keywordtype">char</span>             *description,
<a name="l00990"></a>00990                          DBusTestMemoryFunction  func,
<a name="l00991"></a>00991                          <span class="keywordtype">void</span>                   *data)
<a name="l00992"></a>00992 {
<a name="l00993"></a>00993   <span class="keywordtype">int</span> approx_mallocs;
<a name="l00994"></a>00994   <span class="keyword">const</span> <span class="keywordtype">char</span> *setting;
<a name="l00995"></a>00995   <span class="keywordtype">int</span> max_failures_to_try;
<a name="l00996"></a>00996   <span class="keywordtype">int</span> i;
<a name="l00997"></a>00997 
<a name="l00998"></a>00998   <span class="comment">/* Run once to see about how many mallocs are involved */</span>
<a name="l00999"></a>00999   
<a name="l01000"></a>01000   _dbus_set_fail_alloc_counter (_DBUS_INT_MAX);
<a name="l01001"></a>01001 
<a name="l01002"></a>01002   _dbus_verbose (<span class="stringliteral">&quot;Running once to count mallocs\n&quot;</span>);
<a name="l01003"></a>01003   
<a name="l01004"></a>01004   <span class="keywordflow">if</span> (!(* func) (data))
<a name="l01005"></a>01005     <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l01006"></a>01006   
<a name="l01007"></a>01007   approx_mallocs = _DBUS_INT_MAX - _dbus_get_fail_alloc_counter ();
<a name="l01008"></a>01008 
<a name="l01009"></a>01009   _dbus_verbose (<span class="stringliteral">&quot;\n=================\n%s: about %d mallocs total\n=================\n&quot;</span>,
<a name="l01010"></a>01010                  description, approx_mallocs);
<a name="l01011"></a>01011 
<a name="l01012"></a>01012   setting = <a class="code" href="group__DBusSysdeps.html#gab846071a4de54cb7e518654f9375313a" title="Wrapper for getenv().">_dbus_getenv</a> (<span class="stringliteral">&quot;DBUS_TEST_MALLOC_FAILURES&quot;</span>);
<a name="l01013"></a>01013   <span class="keywordflow">if</span> (setting != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l01014"></a>01014     {
<a name="l01015"></a>01015       <a class="code" href="structDBusString.html">DBusString</a> str;
<a name="l01016"></a>01016       <span class="keywordtype">long</span> v;
<a name="l01017"></a>01017       <a class="code" href="group__DBusString.html#ga374640ddfa2f0b27a8356e2379ba8043" title="Initializes a constant string.">_dbus_string_init_const</a> (&amp;str, setting);
<a name="l01018"></a>01018       v = 4;
<a name="l01019"></a>01019       <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga93e22894a5e2e0d65c179c7d36a8b1c8" title="Parses an integer contained in a DBusString.">_dbus_string_parse_int</a> (&amp;str, 0, &amp;v, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>))
<a name="l01020"></a>01020         <a class="code" href="group__DBusInternalsUtils.html#gabea2c16d6d3fe7c4eb5b9496fc877f84" title="Prints a warning message to stderr.">_dbus_warn</a> (<span class="stringliteral">&quot;couldn&#39;t parse &#39;%s&#39; as integer\n&quot;</span>, setting);
<a name="l01021"></a>01021       max_failures_to_try = v;
<a name="l01022"></a>01022     }
<a name="l01023"></a>01023   <span class="keywordflow">else</span>
<a name="l01024"></a>01024     {
<a name="l01025"></a>01025       max_failures_to_try = 4;
<a name="l01026"></a>01026     }
<a name="l01027"></a>01027 
<a name="l01028"></a>01028   i = setting ? max_failures_to_try - 1 : 1;
<a name="l01029"></a>01029   <span class="keywordflow">while</span> (i &lt; max_failures_to_try)
<a name="l01030"></a>01030     {
<a name="l01031"></a>01031       _dbus_set_fail_alloc_failures (i);
<a name="l01032"></a>01032       <span class="keywordflow">if</span> (!run_failing_each_malloc (approx_mallocs, description, func, data))
<a name="l01033"></a>01033         <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l01034"></a>01034       ++i;
<a name="l01035"></a>01035     }
<a name="l01036"></a>01036   
<a name="l01037"></a>01037   _dbus_verbose (<span class="stringliteral">&quot;\n=================\n%s: all iterations passed\n=================\n&quot;</span>,
<a name="l01038"></a>01038                  description);
<a name="l01039"></a>01039 
<a name="l01040"></a>01040   <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l01041"></a>01041 }
<a name="l01042"></a>01042 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_ENABLE_EMBEDDED_TESTS */</span>
<a name="l01043"></a>01043 
</pre></div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated on Thu Mar 3 2016 17:50:30 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>