Sophie

Sophie

distrib > CentOS > 5 > x86_64 > by-pkgid > 67e32647b06c0323bf90c6b54a6438d1 > files > 88

rpm-apidocs-4.4.2.3-34.el5.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>rpm: rpmdb/fprint.c Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.7 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="modules.html"><span>Modules</span></a></li>
    <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
    <li id="current"><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  </ul></div>
<div class="tabs">
  <ul>
    <li><a href="files.html"><span>File&nbsp;List</span></a></li>
    <li><a href="globals.html"><span>Globals</span></a></li>
  </ul></div>
<h1>rpmdb/fprint.c</h1><a href="fprint_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00005"></a>00005 <span class="preprocessor">#include "<a class="code" href="system_8h.html">system.h</a>"</span>
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="preprocessor">#include &lt;<a class="code" href="rpmdb_8h.html">rpmdb.h</a>&gt;</span>
<a name="l00008"></a>00008 <span class="preprocessor">#include &lt;<a class="code" href="rpmmacro_8h.html">rpmmacro.h</a>&gt;</span>   <span class="comment">/* XXX for rpmCleanPath */</span>
<a name="l00009"></a>00009 
<a name="l00010"></a>00010 <span class="preprocessor">#include "<a class="code" href="fprint_8h.html">fprint.h</a>"</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include "<a class="code" href="debug_8h.html">debug.h</a>"</span>
<a name="l00012"></a>00012 
<a name="l00013"></a><a class="code" href="fprint_8h.html#597157f058d0c4032fdaeab4f4395f49">00013</a> <a class="code" href="structfprintCache__s.html">fingerPrintCache</a> <a class="code" href="fprint_8c.html#597157f058d0c4032fdaeab4f4395f49">fpCacheCreate</a>(<span class="keywordtype">int</span> sizeHint)
<a name="l00014"></a>00014 {
<a name="l00015"></a>00015     <a class="code" href="structfprintCache__s.html">fingerPrintCache</a> fpc;
<a name="l00016"></a>00016 
<a name="l00017"></a>00017     fpc = <a class="code" href="system_8h.html#42ccfa6fc49cc4ce90cc44cd05052490">xmalloc</a>(<span class="keyword">sizeof</span>(*fpc));
<a name="l00018"></a>00018     fpc-&gt;ht = <a class="code" href="rpmhash_8c.html#1776ef0679837cb0e5c6815d29abf26e">htCreate</a>(sizeHint * 2, 0, 1, <a class="code" href="rpmhash_8c.html#e1f745ee5183294bfabc03f35bd663a6">hashFunctionString</a>,
<a name="l00019"></a>00019                        <a class="code" href="rpmhash_8c.html#10293f8871cec48e563d4335612a3b45">hashEqualityString</a>);
<a name="l00020"></a>00020     <span class="keywordflow">return</span> fpc;
<a name="l00021"></a>00021 }
<a name="l00022"></a>00022 
<a name="l00023"></a><a class="code" href="fprint_8h.html#146a285f55fcec93a084cae770561e86">00023</a> <a class="code" href="structfprintCache__s.html">fingerPrintCache</a> <a class="code" href="fprint_8c.html#146a285f55fcec93a084cae770561e86">fpCacheFree</a>(<a class="code" href="structfprintCache__s.html">fingerPrintCache</a> cache)
<a name="l00024"></a>00024 {
<a name="l00025"></a>00025     cache-&gt;<a class="code" href="structfprintCache__s.html#0e562885bef094ec9c938cf5d7aaa878">ht</a> = <a class="code" href="rpmhash_8c.html#869ac660d64cddffc7ce6e8da49f7520">htFree</a>(cache-&gt;<a class="code" href="structfprintCache__s.html#0e562885bef094ec9c938cf5d7aaa878">ht</a>);
<a name="l00026"></a>00026     free(cache);
<a name="l00027"></a>00027     <span class="keywordflow">return</span> NULL;
<a name="l00028"></a>00028 }
<a name="l00029"></a>00029 
<a name="l00036"></a><a class="code" href="fprint_8c.html#e15956664a4d6e42fb8a12ba5c68467a">00036</a> <span class="keyword">static</span> <span class="comment">/*@null@*/</span> <span class="keyword">const</span> <span class="keyword">struct </span><a class="code" href="structfprintCacheEntry__s.html">fprintCacheEntry_s</a> * <a class="code" href="fprint_8c.html#e15956664a4d6e42fb8a12ba5c68467a">cacheContainsDirectory</a>(
<a name="l00037"></a>00037                             <a class="code" href="structfprintCache__s.html">fingerPrintCache</a> cache,
<a name="l00038"></a>00038                             <span class="keyword">const</span> <span class="keywordtype">char</span> * <a class="code" href="parsePrep_8c.html#a0069b107e0710dd83fa1d7ba20fe612">dirName</a>)
<a name="l00039"></a>00039         <span class="comment">/*@*/</span>
<a name="l00040"></a>00040 {
<a name="l00041"></a>00041     <span class="keyword">const</span> <span class="keywordtype">void</span> ** data;
<a name="l00042"></a>00042 
<a name="l00043"></a>00043     <span class="keywordflow">if</span> (<a class="code" href="rpmhash_8c.html#0cc55112a78d83d18806bb8111aa3060">htGetEntry</a>(cache-&gt;<a class="code" href="structfprintCache__s.html#0e562885bef094ec9c938cf5d7aaa878">ht</a>, dirName, &amp;data, NULL, NULL))
<a name="l00044"></a>00044         <span class="keywordflow">return</span> NULL;
<a name="l00045"></a>00045 <span class="comment">/*@-boundsread@*/</span>
<a name="l00046"></a>00046     <span class="keywordflow">return</span> data[0];
<a name="l00047"></a>00047 <span class="comment">/*@=boundsread@*/</span>
<a name="l00048"></a>00048 }
<a name="l00049"></a>00049 
<a name="l00058"></a>00058 <span class="comment">/*@-bounds@*/</span> <span class="comment">/* LCL: segfault */</span>
<a name="l00059"></a><a class="code" href="fprint_8c.html#762324632f7a7df20e57d9d2b2386eec">00059</a> <span class="keyword">static</span> <a class="code" href="structfingerPrint__s.html">fingerPrint</a> <a class="code" href="fprint_8c.html#762324632f7a7df20e57d9d2b2386eec">doLookup</a>(<a class="code" href="structfprintCache__s.html">fingerPrintCache</a> cache,
<a name="l00060"></a>00060                 <span class="keyword">const</span> <span class="keywordtype">char</span> * <a class="code" href="parsePrep_8c.html#a0069b107e0710dd83fa1d7ba20fe612">dirName</a>, <span class="keyword">const</span> <span class="keywordtype">char</span> * baseName, <span class="keywordtype">int</span> scareMemory)
<a name="l00061"></a>00061         <span class="comment">/*@modifies cache @*/</span>
<a name="l00062"></a>00062 {
<a name="l00063"></a>00063     <span class="keywordtype">char</span> dir[<a class="code" href="query_8c.html#e688d728e1acdfe5988c7db45d6f0166">PATH_MAX</a>];
<a name="l00064"></a>00064     <span class="keyword">const</span> <span class="keywordtype">char</span> * cleanDirName;
<a name="l00065"></a>00065     size_t cdnl;
<a name="l00066"></a>00066     <span class="keywordtype">char</span> * end;             <span class="comment">/* points to the '\0' at the end of "buf" */</span>
<a name="l00067"></a>00067     <a class="code" href="structfingerPrint__s.html">fingerPrint</a> fp;
<a name="l00068"></a>00068     <span class="keyword">struct </span>stat sb;
<a name="l00069"></a>00069     <span class="keywordtype">char</span> * buf;
<a name="l00070"></a>00070     <span class="keyword">const</span> <span class="keyword">struct </span><a class="code" href="structfprintCacheEntry__s.html">fprintCacheEntry_s</a> * cacheHit;
<a name="l00071"></a>00071 
<a name="l00072"></a>00072     <span class="comment">/* assert(*dirName == '/' || !scareMemory); */</span>
<a name="l00073"></a>00073 
<a name="l00074"></a>00074     <span class="comment">/* XXX WATCHOUT: fp.subDir is set below from relocated dirName arg */</span>
<a name="l00075"></a>00075     cleanDirName = dirName;
<a name="l00076"></a>00076     cdnl = strlen(cleanDirName);
<a name="l00077"></a>00077 
<a name="l00078"></a>00078     <span class="keywordflow">if</span> (*cleanDirName == <span class="charliteral">'/'</span>) {
<a name="l00079"></a>00079         <span class="comment">/*@-branchstate@*/</span>
<a name="l00080"></a>00080         <span class="keywordflow">if</span> (!scareMemory)
<a name="l00081"></a>00081             cleanDirName =
<a name="l00082"></a>00082                 <a class="code" href="macro_8c.html#23bc9da080ad3340bbba93a0bf45dd07">rpmCleanPath</a>(strcpy(<a class="code" href="system_8h.html#eb1df3e83fb069eaa2eb66ace3a0ea52">alloca</a>(cdnl+1), dirName));
<a name="l00083"></a>00083         <span class="comment">/*@=branchstate@*/</span>
<a name="l00084"></a>00084     } <span class="keywordflow">else</span> {
<a name="l00085"></a>00085         scareMemory = 0;        <span class="comment">/* XXX causes memory leak */</span>
<a name="l00086"></a>00086 
<a name="l00087"></a>00087         <span class="comment">/* Using realpath on the arg isn't correct if the arg is a symlink,</span>
<a name="l00088"></a>00088 <span class="comment">         * especially if the symlink is a dangling link.  What we </span>
<a name="l00089"></a>00089 <span class="comment">         * do instead is use realpath() on `.' and then append arg to</span>
<a name="l00090"></a>00090 <span class="comment">         * the result.</span>
<a name="l00091"></a>00091 <span class="comment">         */</span>
<a name="l00092"></a>00092 
<a name="l00093"></a>00093         <span class="comment">/* if the current directory doesn't exist, we might fail. </span>
<a name="l00094"></a>00094 <span class="comment">           oh well. likewise if it's too long.  */</span>
<a name="l00095"></a>00095         dir[0] = <span class="charliteral">'\0'</span>;
<a name="l00096"></a>00096         <span class="comment">/*@-branchstate@*/</span>
<a name="l00097"></a>00097         <span class="keywordflow">if</span> (<a class="code" href="system_8h.html#485596c323cc1b587b1fa5849f64bf25">realpath</a>(<span class="stringliteral">"."</span>, dir) != NULL) {
<a name="l00098"></a>00098             end = dir + strlen(dir);
<a name="l00099"></a>00099             <span class="keywordflow">if</span> (end[-1] != <span class="charliteral">'/'</span>) *end++ = <span class="charliteral">'/'</span>;
<a name="l00100"></a>00100             end = <a class="code" href="system_8h.html#217a70a69e2fc7727278516b7ad2fc26">stpncpy</a>(end, cleanDirName, <span class="keyword">sizeof</span>(dir) - (end - dir));
<a name="l00101"></a>00101             *end = <span class="charliteral">'\0'</span>;
<a name="l00102"></a>00102             (void)<a class="code" href="macro_8c.html#23bc9da080ad3340bbba93a0bf45dd07">rpmCleanPath</a>(dir); <span class="comment">/* XXX possible /../ from concatenation */</span>
<a name="l00103"></a>00103             end = dir + strlen(dir);
<a name="l00104"></a>00104             <span class="keywordflow">if</span> (end[-1] != <span class="charliteral">'/'</span>) *end++ = <span class="charliteral">'/'</span>;
<a name="l00105"></a>00105             *end = <span class="charliteral">'\0'</span>;
<a name="l00106"></a>00106             cleanDirName = dir;
<a name="l00107"></a>00107             cdnl = end - dir;
<a name="l00108"></a>00108         }
<a name="l00109"></a>00109         <span class="comment">/*@=branchstate@*/</span>
<a name="l00110"></a>00110     }
<a name="l00111"></a>00111     fp.<a class="code" href="structfingerPrint__s.html#0d73dd8062a9259fe1549592ec430bb2">entry</a> = NULL;
<a name="l00112"></a>00112     fp.<a class="code" href="structfingerPrint__s.html#667808e35073ae3fa141b3f3ab59d000">subDir</a> = NULL;
<a name="l00113"></a>00113     fp.<a class="code" href="structfingerPrint__s.html#17c474c078937ada24b6957550c427d8">baseName</a> = NULL;
<a name="l00114"></a>00114     <span class="comment">/*@-nullret@*/</span>
<a name="l00115"></a>00115     <span class="keywordflow">if</span> (cleanDirName == NULL) <span class="keywordflow">return</span> fp;        <span class="comment">/* XXX can't happen */</span>
<a name="l00116"></a>00116     <span class="comment">/*@=nullret@*/</span>
<a name="l00117"></a>00117 
<a name="l00118"></a>00118     buf = strcpy(<a class="code" href="system_8h.html#eb1df3e83fb069eaa2eb66ace3a0ea52">alloca</a>(cdnl + 1), cleanDirName);
<a name="l00119"></a>00119     end = buf + cdnl;
<a name="l00120"></a>00120 
<a name="l00121"></a>00121     <span class="comment">/* no need to pay attention to that extra little / at the end of dirName */</span>
<a name="l00122"></a>00122     <span class="keywordflow">if</span> (buf[1] &amp;&amp; end[-1] == <span class="charliteral">'/'</span>) {
<a name="l00123"></a>00123         end--;
<a name="l00124"></a>00124         *end = <span class="charliteral">'\0'</span>;
<a name="l00125"></a>00125     }
<a name="l00126"></a>00126 
<a name="l00127"></a>00127     <span class="keywordflow">while</span> (1) {
<a name="l00128"></a>00128 
<a name="l00129"></a>00129         <span class="comment">/* as we're stating paths here, we want to follow symlinks */</span>
<a name="l00130"></a>00130 
<a name="l00131"></a>00131         cacheHit = <a class="code" href="fprint_8c.html#e15956664a4d6e42fb8a12ba5c68467a">cacheContainsDirectory</a>(cache, (*buf != <span class="charliteral">'\0'</span> ? buf : <span class="stringliteral">"/"</span>));
<a name="l00132"></a>00132         <span class="keywordflow">if</span> (cacheHit != NULL) {
<a name="l00133"></a>00133             fp.<a class="code" href="structfingerPrint__s.html#0d73dd8062a9259fe1549592ec430bb2">entry</a> = cacheHit;
<a name="l00134"></a>00134         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!stat((*buf != <span class="charliteral">'\0'</span> ? buf : <span class="stringliteral">"/"</span>), &amp;sb)) {
<a name="l00135"></a>00135             size_t nb = <span class="keyword">sizeof</span>(*fp.<a class="code" href="structfingerPrint__s.html#0d73dd8062a9259fe1549592ec430bb2">entry</a>) + (*buf != <span class="charliteral">'\0'</span> ? (end-buf) : 1) + 1;
<a name="l00136"></a>00136             <span class="keywordtype">char</span> * dn = <a class="code" href="system_8h.html#42ccfa6fc49cc4ce90cc44cd05052490">xmalloc</a>(nb);
<a name="l00137"></a>00137             <span class="keyword">struct </span><a class="code" href="structfprintCacheEntry__s.html">fprintCacheEntry_s</a> * newEntry = (<span class="keywordtype">void</span> *)dn;
<a name="l00138"></a>00138 
<a name="l00139"></a>00139             <span class="comment">/*@-usereleased@*/</span>  <span class="comment">/* LCL: contiguous malloc confusion */</span>
<a name="l00140"></a>00140             dn += <span class="keyword">sizeof</span>(*newEntry);
<a name="l00141"></a>00141             strcpy(dn, (*buf != <span class="charliteral">'\0'</span> ? buf : <span class="stringliteral">"/"</span>));
<a name="l00142"></a>00142             newEntry-&gt;<a class="code" href="structfprintCacheEntry__s.html#ac2b6141864736c6a9370ea0ceba83d5">ino</a> = sb.st_ino;
<a name="l00143"></a>00143             newEntry-&gt;<a class="code" href="structfprintCacheEntry__s.html#a3f1d40e8ad5860f83b37a4149ec346f">dev</a> = sb.st_dev;
<a name="l00144"></a>00144             newEntry-&gt;<a class="code" href="structfprintCacheEntry__s.html#478448d6491acf3d78e8202920a7c528">dirName</a> = dn;
<a name="l00145"></a>00145             fp.<a class="code" href="structfingerPrint__s.html#0d73dd8062a9259fe1549592ec430bb2">entry</a> = newEntry;
<a name="l00146"></a>00146 
<a name="l00147"></a>00147             <span class="comment">/*@-kepttrans -dependenttrans @*/</span>
<a name="l00148"></a>00148             <a class="code" href="rpmhash_8c.html#9556907bacac9ff2ce06bb341f496ada">htAddEntry</a>(cache-&gt;<a class="code" href="structfprintCache__s.html#0e562885bef094ec9c938cf5d7aaa878">ht</a>, dn, fp.<a class="code" href="structfingerPrint__s.html#0d73dd8062a9259fe1549592ec430bb2">entry</a>);
<a name="l00149"></a>00149             <span class="comment">/*@=kepttrans =dependenttrans @*/</span>
<a name="l00150"></a>00150             <span class="comment">/*@=usereleased@*/</span>
<a name="l00151"></a>00151         }
<a name="l00152"></a>00152 
<a name="l00153"></a>00153         <span class="keywordflow">if</span> (fp.<a class="code" href="structfingerPrint__s.html#0d73dd8062a9259fe1549592ec430bb2">entry</a>) {
<a name="l00154"></a>00154             fp.<a class="code" href="structfingerPrint__s.html#667808e35073ae3fa141b3f3ab59d000">subDir</a> = cleanDirName + (end - buf);
<a name="l00155"></a>00155             <span class="keywordflow">if</span> (fp.<a class="code" href="structfingerPrint__s.html#667808e35073ae3fa141b3f3ab59d000">subDir</a>[0] == <span class="charliteral">'/'</span> &amp;&amp; fp.<a class="code" href="structfingerPrint__s.html#667808e35073ae3fa141b3f3ab59d000">subDir</a>[1] != <span class="charliteral">'\0'</span>)
<a name="l00156"></a>00156                 fp.<a class="code" href="structfingerPrint__s.html#667808e35073ae3fa141b3f3ab59d000">subDir</a>++;
<a name="l00157"></a>00157             <span class="keywordflow">if</span> (fp.<a class="code" href="structfingerPrint__s.html#667808e35073ae3fa141b3f3ab59d000">subDir</a>[0] == <span class="charliteral">'\0'</span> ||
<a name="l00158"></a>00158             <span class="comment">/* XXX don't bother saving '/' as subdir */</span>
<a name="l00159"></a>00159                (fp.<a class="code" href="structfingerPrint__s.html#667808e35073ae3fa141b3f3ab59d000">subDir</a>[0] == <span class="charliteral">'/'</span> &amp;&amp; fp.<a class="code" href="structfingerPrint__s.html#667808e35073ae3fa141b3f3ab59d000">subDir</a>[1] == <span class="charliteral">'\0'</span>))
<a name="l00160"></a>00160                 fp.<a class="code" href="structfingerPrint__s.html#667808e35073ae3fa141b3f3ab59d000">subDir</a> = NULL;
<a name="l00161"></a>00161             fp.<a class="code" href="structfingerPrint__s.html#17c474c078937ada24b6957550c427d8">baseName</a> = baseName;
<a name="l00162"></a>00162             <span class="keywordflow">if</span> (!scareMemory &amp;&amp; fp.<a class="code" href="structfingerPrint__s.html#667808e35073ae3fa141b3f3ab59d000">subDir</a> != NULL)
<a name="l00163"></a>00163                 fp.<a class="code" href="structfingerPrint__s.html#667808e35073ae3fa141b3f3ab59d000">subDir</a> = <a class="code" href="system_8h.html#d6142d091f00b2d4543ce7a43e5d0eba">xstrdup</a>(fp.<a class="code" href="structfingerPrint__s.html#667808e35073ae3fa141b3f3ab59d000">subDir</a>);
<a name="l00164"></a>00164         <span class="comment">/*@-compdef@*/</span> <span class="comment">/* FIX: fp.entry.{dirName,dev,ino} undef @*/</span>
<a name="l00165"></a>00165             <span class="keywordflow">return</span> fp;
<a name="l00166"></a>00166         <span class="comment">/*@=compdef@*/</span>
<a name="l00167"></a>00167         }
<a name="l00168"></a>00168 
<a name="l00169"></a>00169         <span class="comment">/* stat of '/' just failed! */</span>
<a name="l00170"></a>00170         <span class="keywordflow">if</span> (end == buf + 1)
<a name="l00171"></a>00171             abort();
<a name="l00172"></a>00172 
<a name="l00173"></a>00173         end--;
<a name="l00174"></a>00174         <span class="keywordflow">while</span> ((end &gt; buf) &amp;&amp; *end != <span class="charliteral">'/'</span>) end--;
<a name="l00175"></a>00175         <span class="keywordflow">if</span> (end == buf)     <span class="comment">/* back to stat'ing just '/' */</span>
<a name="l00176"></a>00176             end++;
<a name="l00177"></a>00177 
<a name="l00178"></a>00178         *end = <span class="charliteral">'\0'</span>;
<a name="l00179"></a>00179     }
<a name="l00180"></a>00180 
<a name="l00181"></a>00181     <span class="comment">/*@notreached@*/</span>
<a name="l00182"></a>00182 
<a name="l00183"></a>00183     <span class="comment">/*@-compdef@*/</span> <span class="comment">/* FIX: fp.entry.{dirName,dev,ino} undef @*/</span>
<a name="l00184"></a>00184     <span class="comment">/*@-nullret@*/</span> <span class="keywordflow">return</span> fp; <span class="comment">/*@=nullret@*/</span>    <span class="comment">/* LCL: can't happen. */</span>
<a name="l00185"></a>00185     <span class="comment">/*@=compdef@*/</span>
<a name="l00186"></a>00186 }
<a name="l00187"></a>00187 <span class="comment">/*@=bounds@*/</span>
<a name="l00188"></a>00188 
<a name="l00189"></a><a class="code" href="fprint_8h.html#caeac43cffa5433483f2e89cee895a54">00189</a> <a class="code" href="structfingerPrint__s.html">fingerPrint</a> <a class="code" href="fprint_8c.html#caeac43cffa5433483f2e89cee895a54">fpLookup</a>(<a class="code" href="structfprintCache__s.html">fingerPrintCache</a> cache, <span class="keyword">const</span> <span class="keywordtype">char</span> * <a class="code" href="parsePrep_8c.html#a0069b107e0710dd83fa1d7ba20fe612">dirName</a>, 
<a name="l00190"></a>00190                         <span class="keyword">const</span> <span class="keywordtype">char</span> * baseName, <span class="keywordtype">int</span> scareMemory)
<a name="l00191"></a>00191 {
<a name="l00192"></a>00192     <span class="keywordflow">return</span> <a class="code" href="fprint_8c.html#762324632f7a7df20e57d9d2b2386eec">doLookup</a>(cache, dirName, baseName, scareMemory);
<a name="l00193"></a>00193 }
<a name="l00194"></a>00194 
<a name="l00195"></a><a class="code" href="fprint_8h.html#33ef67556acaf1c7ee9d4c4e51b8b29d">00195</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="fprint_8c.html#33ef67556acaf1c7ee9d4c4e51b8b29d">fpHashFunction</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> * key)
<a name="l00196"></a>00196 {
<a name="l00197"></a>00197     <span class="keyword">const</span> <a class="code" href="structfingerPrint__s.html">fingerPrint</a> * fp = key;
<a name="l00198"></a>00198     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> hash = 0;
<a name="l00199"></a>00199     <span class="keywordtype">int</span> j;
<a name="l00200"></a>00200     
<a name="l00201"></a>00201     hash = <a class="code" href="rpmhash_8c.html#e1f745ee5183294bfabc03f35bd663a6">hashFunctionString</a>(fp-&gt;<a class="code" href="structfingerPrint__s.html#17c474c078937ada24b6957550c427d8">baseName</a>);
<a name="l00202"></a>00202     <span class="keywordflow">if</span> (fp-&gt;<a class="code" href="structfingerPrint__s.html#667808e35073ae3fa141b3f3ab59d000">subDir</a>) hash ^= <a class="code" href="rpmhash_8c.html#e1f745ee5183294bfabc03f35bd663a6">hashFunctionString</a>(fp-&gt;<a class="code" href="structfingerPrint__s.html#667808e35073ae3fa141b3f3ab59d000">subDir</a>);
<a name="l00203"></a>00203 
<a name="l00204"></a>00204     hash ^= ((unsigned)fp-&gt;<a class="code" href="structfingerPrint__s.html#0d73dd8062a9259fe1549592ec430bb2">entry</a>-&gt;<a class="code" href="structfprintCacheEntry__s.html#a3f1d40e8ad5860f83b37a4149ec346f">dev</a>);
<a name="l00205"></a>00205     <span class="keywordflow">for</span> (j=0; j&lt;4; j++) hash ^= ((fp-&gt;<a class="code" href="structfingerPrint__s.html#0d73dd8062a9259fe1549592ec430bb2">entry</a>-&gt;<a class="code" href="structfprintCacheEntry__s.html#ac2b6141864736c6a9370ea0ceba83d5">ino</a> &gt;&gt; (8*j)) &amp; 0xFF) &lt;&lt; ((3-j)*8);
<a name="l00206"></a>00206 
<a name="l00207"></a>00207     <span class="keywordflow">return</span> hash;
<a name="l00208"></a>00208 }
<a name="l00209"></a>00209 
<a name="l00210"></a>00210 <span class="comment">/*@-boundsread@*/</span>
<a name="l00211"></a><a class="code" href="fprint_8h.html#d2174b727800d727a0fe273f3d490762">00211</a> <span class="keywordtype">int</span> <a class="code" href="fprint_8c.html#d2174b727800d727a0fe273f3d490762">fpEqual</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> * key1, <span class="keyword">const</span> <span class="keywordtype">void</span> * key2)
<a name="l00212"></a>00212 {
<a name="l00213"></a>00213     <span class="keyword">const</span> <a class="code" href="structfingerPrint__s.html">fingerPrint</a> *k1 = key1;
<a name="l00214"></a>00214     <span class="keyword">const</span> <a class="code" href="structfingerPrint__s.html">fingerPrint</a> *k2 = key2;
<a name="l00215"></a>00215 
<a name="l00216"></a>00216     <span class="comment">/* If the addresses are the same, so are the values. */</span>
<a name="l00217"></a>00217     <span class="keywordflow">if</span> (k1 == k2)
<a name="l00218"></a>00218         <span class="keywordflow">return</span> 0;
<a name="l00219"></a>00219 
<a name="l00220"></a>00220     <span class="comment">/* Otherwise, compare fingerprints by value. */</span>
<a name="l00221"></a>00221     <span class="comment">/*@-nullpass@*/</span>     <span class="comment">/* LCL: whines about (*k2).subdir */</span>
<a name="l00222"></a>00222     <span class="keywordflow">if</span> (<a class="code" href="fprint_8h.html#2a1897732648edd93c15bd0c0050b20e">FP_EQUAL</a>(*k1, *k2))
<a name="l00223"></a>00223         <span class="keywordflow">return</span> 0;
<a name="l00224"></a>00224     <span class="comment">/*@=nullpass@*/</span>
<a name="l00225"></a>00225     <span class="keywordflow">return</span> 1;
<a name="l00226"></a>00226 
<a name="l00227"></a>00227 }
<a name="l00228"></a>00228 <span class="comment">/*@=boundsread@*/</span>
<a name="l00229"></a>00229 
<a name="l00230"></a>00230 <span class="comment">/*@-bounds@*/</span>
<a name="l00231"></a><a class="code" href="fprint_8h.html#6427b3bda261755cca556f16d2564f5c">00231</a> <span class="keywordtype">void</span> <a class="code" href="fprint_8c.html#6427b3bda261755cca556f16d2564f5c">fpLookupList</a>(<a class="code" href="structfprintCache__s.html">fingerPrintCache</a> cache, <span class="keyword">const</span> <span class="keywordtype">char</span> ** dirNames, 
<a name="l00232"></a>00232                   <span class="keyword">const</span> <span class="keywordtype">char</span> ** baseNames, <span class="keyword">const</span> <span class="keywordtype">int</span> * dirIndexes, 
<a name="l00233"></a>00233                   <span class="keywordtype">int</span> fileCount, <a class="code" href="structfingerPrint__s.html">fingerPrint</a> * fpList)
<a name="l00234"></a>00234 {
<a name="l00235"></a>00235     <span class="keywordtype">int</span> i;
<a name="l00236"></a>00236 
<a name="l00237"></a>00237     <span class="keywordflow">for</span> (i = 0; i &lt; fileCount; i++) {
<a name="l00238"></a>00238         <span class="comment">/* If this is in the same directory as the last file, don't bother</span>
<a name="l00239"></a>00239 <span class="comment">           redoing all of this work */</span>
<a name="l00240"></a>00240         <span class="keywordflow">if</span> (i &gt; 0 &amp;&amp; dirIndexes[i - 1] == dirIndexes[i]) {
<a name="l00241"></a>00241             fpList[i].entry = fpList[i - 1].entry;
<a name="l00242"></a>00242             fpList[i].<a class="code" href="structfingerPrint__s.html#667808e35073ae3fa141b3f3ab59d000">subDir</a> = fpList[i - 1].<a class="code" href="structfingerPrint__s.html#667808e35073ae3fa141b3f3ab59d000">subDir</a>;
<a name="l00243"></a>00243             fpList[i].<a class="code" href="structfingerPrint__s.html#17c474c078937ada24b6957550c427d8">baseName</a> = baseNames[i];
<a name="l00244"></a>00244         } <span class="keywordflow">else</span> {
<a name="l00245"></a>00245             fpList[i] = <a class="code" href="fprint_8c.html#762324632f7a7df20e57d9d2b2386eec">doLookup</a>(cache, dirNames[dirIndexes[i]], baseNames[i],
<a name="l00246"></a>00246                                  1);
<a name="l00247"></a>00247         }
<a name="l00248"></a>00248     }
<a name="l00249"></a>00249 }
<a name="l00250"></a>00250 <span class="comment">/*@=bounds@*/</span>
<a name="l00251"></a>00251 
<a name="l00252"></a>00252 <span class="preprocessor">#ifdef  UNUSED</span>
<a name="l00253"></a>00253 <span class="preprocessor"></span>
<a name="l00260"></a>00260 <span class="keyword">static</span>
<a name="l00261"></a>00261 <span class="keywordtype">void</span> fpLookupHeader(<a class="code" href="structfprintCache__s.html">fingerPrintCache</a> cache, <a class="code" href="structheaderToken__s.html">Header</a> h, <a class="code" href="structfingerPrint__s.html">fingerPrint</a> * fpList)
<a name="l00262"></a>00262         <span class="comment">/*@modifies h, cache, *fpList @*/</span>;
<a name="l00263"></a>00263 {
<a name="l00264"></a>00264     <a class="code" href="rpmlib_8h.html#3597d5fe0ce8483347e69b67712661f8">HGE_t</a> hge = (<a class="code" href="rpmlib_8h.html#3597d5fe0ce8483347e69b67712661f8">HGE_t</a>)<a class="code" href="group__header.html#gd560995b7a9431b2eacb4caa22796840">headerGetEntryMinMemory</a>;
<a name="l00265"></a>00265     <a class="code" href="rpmlib_8h.html#0a7d6730794fa9c039746b53d216bda6">HFD_t</a> hfd = <a class="code" href="group__header.html#ge7835c5c4504bf89e169fb7d34c6b521">headerFreeData</a>;
<a name="l00266"></a>00266     <span class="keyword">const</span> <span class="keywordtype">char</span> ** baseNames, ** dirNames;
<a name="l00267"></a>00267     <a class="code" href="group__header.html#ge3bf8d35e51bc1fbaa1a2a5acdceb79e">rpmTagType</a> bnt, dnt;
<a name="l00268"></a>00268     <a class="code" href="header_8h.html#e5c5e6fe946fcce0d2156db86ffffa8a">int_32</a> * dirIndexes;
<a name="l00269"></a>00269     <span class="keywordtype">int</span> fileCount;
<a name="l00270"></a>00270     <span class="keywordtype">int</span> xx;
<a name="l00271"></a>00271 
<a name="l00272"></a>00272     <span class="keywordflow">if</span> (!hge(h, <a class="code" href="rpmlib_8h.html#342756dddb61d125ae851a8b1ab0507bea94338039b3e67d9ece3f8c8875c7fc">RPMTAG_BASENAMES</a>, &amp;bnt, (<span class="keywordtype">void</span> **) &amp;baseNames, &amp;fileCount))
<a name="l00273"></a>00273         <span class="keywordflow">return</span>;
<a name="l00274"></a>00274 
<a name="l00275"></a>00275     xx = hge(h, <a class="code" href="rpmlib_8h.html#342756dddb61d125ae851a8b1ab0507b47b4b31d1ce56b765da33fec906ff1b3">RPMTAG_DIRNAMES</a>, &amp;dnt, (<span class="keywordtype">void</span> **) &amp;dirNames, NULL);
<a name="l00276"></a>00276     xx = hge(h, <a class="code" href="rpmlib_8h.html#342756dddb61d125ae851a8b1ab0507bdf05982a3989eded5d019fd313bed509">RPMTAG_DIRINDEXES</a>, NULL, (<span class="keywordtype">void</span> **) &amp;dirIndexes, NULL);
<a name="l00277"></a>00277     <a class="code" href="fprint_8c.html#6427b3bda261755cca556f16d2564f5c">fpLookupList</a>(cache, dirNames, baseNames, dirIndexes, fileCount, fpList);
<a name="l00278"></a>00278     dirNames = hfd(dirNames, dnt);
<a name="l00279"></a>00279     baseNames = hfd(baseNames, bnt);
<a name="l00280"></a>00280 }
<a name="l00281"></a>00281 <span class="preprocessor">#endif</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on 1 Oct 2013 for rpm by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
</body>
</html>