Current File : //usr/share/doc/dbus/api/dbus-syntax_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-syntax.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-syntax.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-syntax.c - utility functions for strings with special syntax</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Author: Simon McVittie &lt;simon.mcvittie@collabora.co.uk&gt;</span>
<a name="l00005"></a>00005 <span class="comment"> * Copyright © 2011 Nokia Corporation</span>
<a name="l00006"></a>00006 <span class="comment"> *</span>
<a name="l00007"></a>00007 <span class="comment"> * Licensed under the Academic Free License version 2.1</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> */</span>
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &quot;dbus-syntax.h&quot;</span>
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="preprocessor">#include &quot;dbus-internals.h&quot;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &quot;dbus-marshal-validate.h&quot;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &quot;dbus-shared.h&quot;</span>
<a name="l00031"></a>00031 
<a name="l00053"></a>00053 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00054"></a><a class="code" href="group__DBusSyntax.html#ga16a33f0ef4a9efd8f5e8f231dcf13d37">00054</a> <a class="code" href="group__DBusSyntax.html#ga16a33f0ef4a9efd8f5e8f231dcf13d37" title="Check an object path for validity.">dbus_validate_path</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>       *path,
<a name="l00055"></a>00055                     <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a>        *error)
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057   <a class="code" href="structDBusString.html">DBusString</a> str;
<a name="l00058"></a>00058   <span class="keywordtype">int</span> len;
<a name="l00059"></a>00059 
<a name="l00060"></a>00060   _dbus_return_val_if_fail (path != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>);
<a name="l00061"></a>00061 
<a name="l00062"></a>00062   <a class="code" href="group__DBusString.html#ga374640ddfa2f0b27a8356e2379ba8043" title="Initializes a constant string.">_dbus_string_init_const</a> (&amp;str, path);
<a name="l00063"></a>00063   len = <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;str);
<a name="l00064"></a>00064 
<a name="l00065"></a>00065   <span class="comment">/* In general, it ought to be valid... */</span>
<a name="l00066"></a>00066   <span class="keywordflow">if</span> (_DBUS_LIKELY (<a class="code" href="group__DBusMarshal.html#ga616ba4a0280b10222930aedadb7ea8d9" title="Checks that the given range of the string is a valid object path name in the D-Bus protocol...">_dbus_validate_path</a> (&amp;str, 0, len)))
<a name="l00067"></a>00067     <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00068"></a>00068 
<a name="l00069"></a>00069   <span class="comment">/* slow path: string is invalid, find out why */</span>
<a name="l00070"></a>00070 
<a name="l00071"></a>00071   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga65f0f04b7c9371406fc87343f691e8da" title="Checks that the given range of the string is valid UTF-8.">_dbus_string_validate_utf8</a> (&amp;str, 0, len))
<a name="l00072"></a>00072     {
<a name="l00073"></a>00073       <span class="comment">/* don&#39;t quote the actual string here, since a DBusError also needs to</span>
<a name="l00074"></a>00074 <span class="comment">       * be valid UTF-8 */</span>
<a name="l00075"></a>00075       <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#gacf5321b161193ad66d5bdf5c910a9792" title="Invalid arguments passed to a method call.">DBUS_ERROR_INVALID_ARGS</a>,
<a name="l00076"></a>00076                       <span class="stringliteral">&quot;Object path was not valid UTF-8&quot;</span>);
<a name="l00077"></a>00077       <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00078"></a>00078     }
<a name="l00079"></a>00079 
<a name="l00080"></a>00080   <span class="comment">/* FIXME: later, diagnose exactly how it was invalid */</span>
<a name="l00081"></a>00081   <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#gacf5321b161193ad66d5bdf5c910a9792" title="Invalid arguments passed to a method call.">DBUS_ERROR_INVALID_ARGS</a>,
<a name="l00082"></a>00082                   <span class="stringliteral">&quot;Object path was not valid: &#39;%s&#39;&quot;</span>, path);
<a name="l00083"></a>00083   <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00084"></a>00084 }
<a name="l00085"></a>00085 
<a name="l00100"></a>00100 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00101"></a><a class="code" href="group__DBusSyntax.html#ga1023d9c1a44eb2fe05c2b82e23622f98">00101</a> <a class="code" href="group__DBusSyntax.html#ga1023d9c1a44eb2fe05c2b82e23622f98" title="Check an interface name for validity.">dbus_validate_interface</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>       *name,
<a name="l00102"></a>00102                          <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a>        *error)
<a name="l00103"></a>00103 {
<a name="l00104"></a>00104   <a class="code" href="structDBusString.html">DBusString</a> str;
<a name="l00105"></a>00105   <span class="keywordtype">int</span> len;
<a name="l00106"></a>00106 
<a name="l00107"></a>00107   _dbus_return_val_if_fail (name != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>);
<a name="l00108"></a>00108 
<a name="l00109"></a>00109   <a class="code" href="group__DBusString.html#ga374640ddfa2f0b27a8356e2379ba8043" title="Initializes a constant string.">_dbus_string_init_const</a> (&amp;str, name);
<a name="l00110"></a>00110   len = <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;str);
<a name="l00111"></a>00111 
<a name="l00112"></a>00112   <span class="comment">/* In general, it ought to be valid... */</span>
<a name="l00113"></a>00113   <span class="keywordflow">if</span> (_DBUS_LIKELY (<a class="code" href="group__DBusMarshal.html#ga0ad919783f887a9b6f428e262beaeed9" title="Checks that the given range of the string is a valid interface name in the D-Bus protocol.">_dbus_validate_interface</a> (&amp;str, 0, len)))
<a name="l00114"></a>00114     <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00115"></a>00115 
<a name="l00116"></a>00116   <span class="comment">/* slow path: string is invalid, find out why */</span>
<a name="l00117"></a>00117 
<a name="l00118"></a>00118   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga65f0f04b7c9371406fc87343f691e8da" title="Checks that the given range of the string is valid UTF-8.">_dbus_string_validate_utf8</a> (&amp;str, 0, len))
<a name="l00119"></a>00119     {
<a name="l00120"></a>00120       <span class="comment">/* don&#39;t quote the actual string here, since a DBusError also needs to</span>
<a name="l00121"></a>00121 <span class="comment">       * be valid UTF-8 */</span>
<a name="l00122"></a>00122       <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#gacf5321b161193ad66d5bdf5c910a9792" title="Invalid arguments passed to a method call.">DBUS_ERROR_INVALID_ARGS</a>,
<a name="l00123"></a>00123                       <span class="stringliteral">&quot;Interface name was not valid UTF-8&quot;</span>);
<a name="l00124"></a>00124       <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00125"></a>00125     }
<a name="l00126"></a>00126 
<a name="l00127"></a>00127   <span class="comment">/* FIXME: later, diagnose exactly how it was invalid */</span>
<a name="l00128"></a>00128   <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#gacf5321b161193ad66d5bdf5c910a9792" title="Invalid arguments passed to a method call.">DBUS_ERROR_INVALID_ARGS</a>,
<a name="l00129"></a>00129                   <span class="stringliteral">&quot;Interface name was not valid: &#39;%s&#39;&quot;</span>, name);
<a name="l00130"></a>00130   <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00131"></a>00131 }
<a name="l00132"></a>00132 
<a name="l00147"></a>00147 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00148"></a><a class="code" href="group__DBusSyntax.html#gab8540880d62965990957f07630aba700">00148</a> <a class="code" href="group__DBusSyntax.html#gab8540880d62965990957f07630aba700" title="Check a member (method/signal) name for validity.">dbus_validate_member</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>       *name,
<a name="l00149"></a>00149                       <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a>        *error)
<a name="l00150"></a>00150 {
<a name="l00151"></a>00151   <a class="code" href="structDBusString.html">DBusString</a> str;
<a name="l00152"></a>00152   <span class="keywordtype">int</span> len;
<a name="l00153"></a>00153 
<a name="l00154"></a>00154   _dbus_return_val_if_fail (name != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>);
<a name="l00155"></a>00155 
<a name="l00156"></a>00156   <a class="code" href="group__DBusString.html#ga374640ddfa2f0b27a8356e2379ba8043" title="Initializes a constant string.">_dbus_string_init_const</a> (&amp;str, name);
<a name="l00157"></a>00157   len = <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;str);
<a name="l00158"></a>00158 
<a name="l00159"></a>00159   <span class="comment">/* In general, it ought to be valid... */</span>
<a name="l00160"></a>00160   <span class="keywordflow">if</span> (_DBUS_LIKELY (<a class="code" href="group__DBusMarshal.html#gaf647272768029cb23a4e0d3f493587da" title="Checks that the given range of the string is a valid member name in the D-Bus protocol.">_dbus_validate_member</a> (&amp;str, 0, len)))
<a name="l00161"></a>00161     <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00162"></a>00162 
<a name="l00163"></a>00163   <span class="comment">/* slow path: string is invalid, find out why */</span>
<a name="l00164"></a>00164 
<a name="l00165"></a>00165   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga65f0f04b7c9371406fc87343f691e8da" title="Checks that the given range of the string is valid UTF-8.">_dbus_string_validate_utf8</a> (&amp;str, 0, len))
<a name="l00166"></a>00166     {
<a name="l00167"></a>00167       <span class="comment">/* don&#39;t quote the actual string here, since a DBusError also needs to</span>
<a name="l00168"></a>00168 <span class="comment">       * be valid UTF-8 */</span>
<a name="l00169"></a>00169       <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#gacf5321b161193ad66d5bdf5c910a9792" title="Invalid arguments passed to a method call.">DBUS_ERROR_INVALID_ARGS</a>,
<a name="l00170"></a>00170                       <span class="stringliteral">&quot;Member name was not valid UTF-8&quot;</span>);
<a name="l00171"></a>00171       <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00172"></a>00172     }
<a name="l00173"></a>00173 
<a name="l00174"></a>00174   <span class="comment">/* FIXME: later, diagnose exactly how it was invalid */</span>
<a name="l00175"></a>00175   <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#gacf5321b161193ad66d5bdf5c910a9792" title="Invalid arguments passed to a method call.">DBUS_ERROR_INVALID_ARGS</a>,
<a name="l00176"></a>00176                   <span class="stringliteral">&quot;Member name was not valid: &#39;%s&#39;&quot;</span>, name);
<a name="l00177"></a>00177   <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00178"></a>00178 }
<a name="l00179"></a>00179 
<a name="l00194"></a>00194 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00195"></a><a class="code" href="group__DBusSyntax.html#gad1c5b9b2dbdb9f9ade7e497b23cb835f">00195</a> <a class="code" href="group__DBusSyntax.html#gad1c5b9b2dbdb9f9ade7e497b23cb835f" title="Check an error name for validity.">dbus_validate_error_name</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>       *name,
<a name="l00196"></a>00196                           <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a>        *error)
<a name="l00197"></a>00197 {
<a name="l00198"></a>00198   <a class="code" href="structDBusString.html">DBusString</a> str;
<a name="l00199"></a>00199   <span class="keywordtype">int</span> len;
<a name="l00200"></a>00200 
<a name="l00201"></a>00201   _dbus_return_val_if_fail (name != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>);
<a name="l00202"></a>00202 
<a name="l00203"></a>00203   <a class="code" href="group__DBusString.html#ga374640ddfa2f0b27a8356e2379ba8043" title="Initializes a constant string.">_dbus_string_init_const</a> (&amp;str, name);
<a name="l00204"></a>00204   len = <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;str);
<a name="l00205"></a>00205 
<a name="l00206"></a>00206   <span class="comment">/* In general, it ought to be valid... */</span>
<a name="l00207"></a>00207   <span class="keywordflow">if</span> (_DBUS_LIKELY (<a class="code" href="group__DBusMarshal.html#ga6d8075f3b60e2e71aad061aa44b120fe" title="Checks that the given range of the string is a valid error name in the D-Bus protocol.">_dbus_validate_error_name</a> (&amp;str, 0, len)))
<a name="l00208"></a>00208     <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00209"></a>00209 
<a name="l00210"></a>00210   <span class="comment">/* slow path: string is invalid, find out why */</span>
<a name="l00211"></a>00211 
<a name="l00212"></a>00212   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga65f0f04b7c9371406fc87343f691e8da" title="Checks that the given range of the string is valid UTF-8.">_dbus_string_validate_utf8</a> (&amp;str, 0, len))
<a name="l00213"></a>00213     {
<a name="l00214"></a>00214       <span class="comment">/* don&#39;t quote the actual string here, since a DBusError also needs to</span>
<a name="l00215"></a>00215 <span class="comment">       * be valid UTF-8 */</span>
<a name="l00216"></a>00216       <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#gacf5321b161193ad66d5bdf5c910a9792" title="Invalid arguments passed to a method call.">DBUS_ERROR_INVALID_ARGS</a>,
<a name="l00217"></a>00217                       <span class="stringliteral">&quot;Error name was not valid UTF-8&quot;</span>);
<a name="l00218"></a>00218       <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00219"></a>00219     }
<a name="l00220"></a>00220 
<a name="l00221"></a>00221   <span class="comment">/* FIXME: later, diagnose exactly how it was invalid */</span>
<a name="l00222"></a>00222   <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#gacf5321b161193ad66d5bdf5c910a9792" title="Invalid arguments passed to a method call.">DBUS_ERROR_INVALID_ARGS</a>,
<a name="l00223"></a>00223                   <span class="stringliteral">&quot;Error name was not valid: &#39;%s&#39;&quot;</span>, name);
<a name="l00224"></a>00224   <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00225"></a>00225 }
<a name="l00226"></a>00226 
<a name="l00241"></a>00241 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00242"></a><a class="code" href="group__DBusSyntax.html#gabedd6f4019fc30bc4bbcd144198f8444">00242</a> <a class="code" href="group__DBusSyntax.html#gabedd6f4019fc30bc4bbcd144198f8444" title="Check a bus name for validity.">dbus_validate_bus_name</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>       *name,
<a name="l00243"></a>00243                         <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a>        *error)
<a name="l00244"></a>00244 {
<a name="l00245"></a>00245   <a class="code" href="structDBusString.html">DBusString</a> str;
<a name="l00246"></a>00246   <span class="keywordtype">int</span> len;
<a name="l00247"></a>00247 
<a name="l00248"></a>00248   _dbus_return_val_if_fail (name != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>);
<a name="l00249"></a>00249 
<a name="l00250"></a>00250   <a class="code" href="group__DBusString.html#ga374640ddfa2f0b27a8356e2379ba8043" title="Initializes a constant string.">_dbus_string_init_const</a> (&amp;str, name);
<a name="l00251"></a>00251   len = <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;str);
<a name="l00252"></a>00252 
<a name="l00253"></a>00253   <span class="comment">/* In general, it ought to be valid... */</span>
<a name="l00254"></a>00254   <span class="keywordflow">if</span> (_DBUS_LIKELY (<a class="code" href="group__DBusMarshal.html#gaab91a04fa2a96b8ce8843beae7327cd0" title="Checks that the given range of the string is a valid bus name in the D-Bus protocol.">_dbus_validate_bus_name</a> (&amp;str, 0, len)))
<a name="l00255"></a>00255     <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00256"></a>00256 
<a name="l00257"></a>00257   <span class="comment">/* slow path: string is invalid, find out why */</span>
<a name="l00258"></a>00258 
<a name="l00259"></a>00259   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga65f0f04b7c9371406fc87343f691e8da" title="Checks that the given range of the string is valid UTF-8.">_dbus_string_validate_utf8</a> (&amp;str, 0, len))
<a name="l00260"></a>00260     {
<a name="l00261"></a>00261       <span class="comment">/* don&#39;t quote the actual string here, since a DBusError also needs to</span>
<a name="l00262"></a>00262 <span class="comment">       * be valid UTF-8 */</span>
<a name="l00263"></a>00263       <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#gacf5321b161193ad66d5bdf5c910a9792" title="Invalid arguments passed to a method call.">DBUS_ERROR_INVALID_ARGS</a>,
<a name="l00264"></a>00264                       <span class="stringliteral">&quot;Bus name was not valid UTF-8&quot;</span>);
<a name="l00265"></a>00265       <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00266"></a>00266     }
<a name="l00267"></a>00267 
<a name="l00268"></a>00268   <span class="comment">/* FIXME: later, diagnose exactly how it was invalid */</span>
<a name="l00269"></a>00269   <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#gacf5321b161193ad66d5bdf5c910a9792" title="Invalid arguments passed to a method call.">DBUS_ERROR_INVALID_ARGS</a>,
<a name="l00270"></a>00270                   <span class="stringliteral">&quot;Bus name was not valid: &#39;%s&#39;&quot;</span>, name);
<a name="l00271"></a>00271   <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00272"></a>00272 }
<a name="l00273"></a>00273 
<a name="l00288"></a>00288 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00289"></a><a class="code" href="group__DBusSyntax.html#ga7d98d5d9af66ff78e74d5dd1d8cd3390">00289</a> <a class="code" href="group__DBusSyntax.html#ga7d98d5d9af66ff78e74d5dd1d8cd3390" title="Check a string for validity.">dbus_validate_utf8</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>       *alleged_utf8,
<a name="l00290"></a>00290                     <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a>        *error)
<a name="l00291"></a>00291 {
<a name="l00292"></a>00292   <a class="code" href="structDBusString.html">DBusString</a> str;
<a name="l00293"></a>00293 
<a name="l00294"></a>00294   _dbus_return_val_if_fail (alleged_utf8 != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>);
<a name="l00295"></a>00295 
<a name="l00296"></a>00296   <a class="code" href="group__DBusString.html#ga374640ddfa2f0b27a8356e2379ba8043" title="Initializes a constant string.">_dbus_string_init_const</a> (&amp;str, alleged_utf8);
<a name="l00297"></a>00297 
<a name="l00298"></a>00298   <span class="keywordflow">if</span> (_DBUS_LIKELY (<a class="code" href="group__DBusString.html#ga65f0f04b7c9371406fc87343f691e8da" title="Checks that the given range of the string is valid UTF-8.">_dbus_string_validate_utf8</a> (&amp;str, 0,
<a name="l00299"></a>00299                                                 <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;str))))
<a name="l00300"></a>00300     <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00301"></a>00301 
<a name="l00302"></a>00302   <span class="comment">/* don&#39;t quote the actual string here, since a DBusError also needs to</span>
<a name="l00303"></a>00303 <span class="comment">   * be valid UTF-8 */</span>
<a name="l00304"></a>00304   <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#gacf5321b161193ad66d5bdf5c910a9792" title="Invalid arguments passed to a method call.">DBUS_ERROR_INVALID_ARGS</a>,
<a name="l00305"></a>00305                   <span class="stringliteral">&quot;String was not valid UTF-8&quot;</span>);
<a name="l00306"></a>00306   <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00307"></a>00307 }
<a name="l00308"></a>00308  <span class="comment">/* end of group */</span>
</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>