Sophie

Sophie

distrib > Mandriva > 2007.0 > x86_64 > media > main-release > by-pkgid > 926d2d1e3111287cee1b0a4fad4fb4f6 > files > 113

lib64dbus-1_3-devel-0.92-6mdv2007.0.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>dbus-resources.c Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="modules.html">Modules</a> &nbsp; <a class="qindex" href="annotated.html">Data Structures</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Data Fields</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; </center>
<hr><h1>dbus-resources.c</h1><div class="fragment"><pre>00001 <font class="comment">/* -*- mode: C; c-file-style: "gnu" -*- */</font>
00002 <font class="comment">/* dbus-resources.c Resource tracking/limits</font>
00003 <font class="comment"> *</font>
00004 <font class="comment"> * Copyright (C) 2003  Red Hat Inc.</font>
00005 <font class="comment"> *</font>
00006 <font class="comment"> * Licensed under the Academic Free License version 2.0</font>
00007 <font class="comment"> * </font>
00008 <font class="comment"> * This program is free software; you can redistribute it and/or modify</font>
00009 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00010 <font class="comment"> * the Free Software Foundation; either version 2 of the License, or</font>
00011 <font class="comment"> * (at your option) any later version.</font>
00012 <font class="comment"> *</font>
00013 <font class="comment"> * This program is distributed in the hope that it will be useful,</font>
00014 <font class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00015 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</font>
00016 <font class="comment"> * GNU General Public License for more details.</font>
00017 <font class="comment"> * </font>
00018 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00019 <font class="comment"> * along with this program; if not, write to the Free Software</font>
00020 <font class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA</font>
00021 <font class="comment"> *</font>
00022 <font class="comment"> */</font>
00023 <font class="preprocessor">#include &lt;dbus/dbus-resources.h&gt;</font>
00024 <font class="preprocessor">#include &lt;dbus/dbus-internals.h&gt;</font>
00025 
<a name="l00052"></a><a class="code" href="structDBusCounter.html">00052</a> <font class="keyword">struct </font><a class="code" href="structDBusCounter.html">DBusCounter</a>
00053 {
<a name="l00054"></a><a class="code" href="structDBusCounter.html#m0">00054</a>   <font class="keywordtype">int</font> <a class="code" href="structDBusCounter.html#m0">refcount</a>;  
<a name="l00056"></a><a class="code" href="structDBusCounter.html#m1">00056</a>   <font class="keywordtype">long</font> <a class="code" href="structDBusCounter.html#m1">value</a>;    
<a name="l00058"></a><a class="code" href="structDBusCounter.html#m2">00058</a>   <font class="keywordtype">long</font> <a class="code" href="structDBusCounter.html#m2">notify_guard_value</a>; 
<a name="l00059"></a><a class="code" href="structDBusCounter.html#m3">00059</a>   DBusCounterNotifyFunction <a class="code" href="structDBusCounter.html#m3">notify_function</a>; 
<a name="l00060"></a><a class="code" href="structDBusCounter.html#m4">00060</a>   <font class="keywordtype">void</font> *<a class="code" href="structDBusCounter.html#m4">notify_data</a>; 
00061 };
00062   <font class="comment">/* end of resource limits internals docs */</font>
00064 
00076 <a class="code" href="structDBusCounter.html">DBusCounter</a>*
<a name="l00077"></a><a class="code" href="group__DBusResources.html#a0">00077</a> _dbus_counter_new (<font class="keywordtype">void</font>)
00078 {
00079   <a class="code" href="structDBusCounter.html">DBusCounter</a> *counter;
00080 
00081   counter = dbus_new (<a class="code" href="structDBusCounter.html">DBusCounter</a>, 1);
00082   <font class="keywordflow">if</font> (counter == NULL)
00083     <font class="keywordflow">return</font> NULL;
00084   
00085   counter-&gt;<a class="code" href="structDBusCounter.html#m0">refcount</a> = 1;
00086   counter-&gt;<a class="code" href="structDBusCounter.html#m1">value</a> = 0;
00087 
00088   counter-&gt;<a class="code" href="structDBusCounter.html#m2">notify_guard_value</a> = 0;
00089   counter-&gt;<a class="code" href="structDBusCounter.html#m3">notify_function</a> = NULL;
00090   counter-&gt;<a class="code" href="structDBusCounter.html#m4">notify_data</a> = NULL;
00091   
00092   <font class="keywordflow">return</font> counter;
00093 }
00094 
00101 <a class="code" href="structDBusCounter.html">DBusCounter</a> *
<a name="l00102"></a><a class="code" href="group__DBusResources.html#a1">00102</a> _dbus_counter_ref (<a class="code" href="structDBusCounter.html">DBusCounter</a> *counter)
00103 {
00104   _dbus_assert (counter-&gt;<a class="code" href="structDBusCounter.html#m0">refcount</a> &gt; 0);
00105   
00106   counter-&gt;<a class="code" href="structDBusCounter.html#m0">refcount</a> += 1;
00107 
00108   <font class="keywordflow">return</font> counter;
00109 }
00110 
00117 <font class="keywordtype">void</font>
<a name="l00118"></a><a class="code" href="group__DBusResources.html#a2">00118</a> _dbus_counter_unref (<a class="code" href="structDBusCounter.html">DBusCounter</a> *counter)
00119 {
00120   _dbus_assert (counter-&gt;<a class="code" href="structDBusCounter.html#m0">refcount</a> &gt; 0);
00121 
00122   counter-&gt;<a class="code" href="structDBusCounter.html#m0">refcount</a> -= 1;
00123 
00124   <font class="keywordflow">if</font> (counter-&gt;<a class="code" href="structDBusCounter.html#m0">refcount</a> == 0)
00125     {
00126       
00127       dbus_free (counter);
00128     }
00129 }
00130 
00140 <font class="keywordtype">void</font>
<a name="l00141"></a><a class="code" href="group__DBusResources.html#a3">00141</a> _dbus_counter_adjust (<a class="code" href="structDBusCounter.html">DBusCounter</a> *counter,
00142                       <font class="keywordtype">long</font>         delta)
00143 {
00144   <font class="keywordtype">long</font> old = counter-&gt;<a class="code" href="structDBusCounter.html#m1">value</a>;
00145   
00146   counter-&gt;<a class="code" href="structDBusCounter.html#m1">value</a> += delta;
00147 
00148 <font class="preprocessor">#if 0</font>
00149 <font class="preprocessor"></font>  _dbus_verbose (<font class="stringliteral">"Adjusting counter %ld by %ld = %ld\n"</font>,
00150                  old, delta, counter-&gt;<a class="code" href="structDBusCounter.html#m1">value</a>);
00151 <font class="preprocessor">#endif</font>
00152 <font class="preprocessor"></font>  
00153   <font class="keywordflow">if</font> (counter-&gt;<a class="code" href="structDBusCounter.html#m3">notify_function</a> != NULL &amp;&amp;
00154       ((old &lt; counter-&gt;<a class="code" href="structDBusCounter.html#m2">notify_guard_value</a> &amp;&amp;
00155         counter-&gt;<a class="code" href="structDBusCounter.html#m1">value</a> &gt;= counter-&gt;<a class="code" href="structDBusCounter.html#m2">notify_guard_value</a>) ||
00156        (old &gt;= counter-&gt;<a class="code" href="structDBusCounter.html#m2">notify_guard_value</a> &amp;&amp;
00157         counter-&gt;<a class="code" href="structDBusCounter.html#m1">value</a> &lt; counter-&gt;<a class="code" href="structDBusCounter.html#m2">notify_guard_value</a>)))
00158     (* counter-&gt;<a class="code" href="structDBusCounter.html#m3">notify_function</a>) (counter, counter-&gt;<a class="code" href="structDBusCounter.html#m4">notify_data</a>);
00159 }
00160 
00167 <font class="keywordtype">long</font>
<a name="l00168"></a><a class="code" href="group__DBusResources.html#a4">00168</a> _dbus_counter_get_value (<a class="code" href="structDBusCounter.html">DBusCounter</a> *counter)
00169 {
00170   <font class="keywordflow">return</font> counter-&gt;<a class="code" href="structDBusCounter.html#m1">value</a>;
00171 }
00172 
00183 <font class="keywordtype">void</font>
<a name="l00184"></a><a class="code" href="group__DBusResources.html#a5">00184</a> _dbus_counter_set_notify (<a class="code" href="structDBusCounter.html">DBusCounter</a>               *counter,
00185                           <font class="keywordtype">long</font>                       guard_value,
00186                           DBusCounterNotifyFunction  function,
00187                           <font class="keywordtype">void</font>                      *user_data)
00188 {
00189   counter-&gt;<a class="code" href="structDBusCounter.html#m2">notify_guard_value</a> = guard_value;
00190   counter-&gt;<a class="code" href="structDBusCounter.html#m3">notify_function</a> = function;
00191   counter-&gt;<a class="code" href="structDBusCounter.html#m4">notify_data</a> = user_data;
00192 }
00193   <font class="comment">/* end of resource limits exported API */</font>
</pre></div><hr><address align="right"><small>Generated on Wed Jun 9 05:01:26 2004 for D-BUS by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.15 </small></address>
</body>
</html>