<!-- This comment will put IE 6, 7 and 8 in quirks mode --> <!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"/> <title>path_utils: path_utils.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javaScript" src="search/search.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body onload='searchBox.OnSelectItem(0);'> <!-- Generated by Doxygen 1.6.1 --> <script type="text/javascript"><!-- var searchBox = new SearchBox("searchBox", "search",false,'Search'); --></script> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li> <div id="MSearchBox" class="MSearchBoxInactive"> <img id="MSearchSelect" src="search/search.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </div> </li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> </ul> </div> <h1>path_utils.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> Authors:</span> <a name="l00003"></a>00003 <span class="comment"> John Dennis <jdennis.redhat.com></span> <a name="l00004"></a>00004 <span class="comment"></span> <a name="l00005"></a>00005 <span class="comment"> Copyright (C) 2009 Red Hat</span> <a name="l00006"></a>00006 <span class="comment"></span> <a name="l00007"></a>00007 <span class="comment"> This program is free software; you can redistribute it and/or modify</span> <a name="l00008"></a>00008 <span class="comment"> it under the terms of the GNU Lesser General Public License as published by</span> <a name="l00009"></a>00009 <span class="comment"> the Free Software Foundation; either version 3 of the License, or</span> <a name="l00010"></a>00010 <span class="comment"> (at your option) any later version.</span> <a name="l00011"></a>00011 <span class="comment"></span> <a name="l00012"></a>00012 <span class="comment"> This program is distributed in the hope that it will be useful,</span> <a name="l00013"></a>00013 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00014"></a>00014 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> <a name="l00015"></a>00015 <span class="comment"> GNU Lesser General Public License for more details.</span> <a name="l00016"></a>00016 <span class="comment"></span> <a name="l00017"></a>00017 <span class="comment"> You should have received a copy of the GNU Lesser General Public License</span> <a name="l00018"></a>00018 <span class="comment"> along with this program. If not, see <http://www.gnu.org/licenses/>.</span> <a name="l00019"></a>00019 <span class="comment">*/</span> <a name="l00020"></a>00020 <a name="l00021"></a>00021 <span class="preprocessor">#ifndef PATH_UTILS_H</span> <a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor">#define PATH_UTILS_H</span> <a name="l00023"></a>00023 <span class="preprocessor"></span> <a name="l00024"></a>00024 <span class="comment">/*****************************************************************************/</span> <a name="l00025"></a>00025 <span class="comment">/******************************** Documentation ******************************/</span> <a name="l00026"></a>00026 <span class="comment">/*****************************************************************************/</span> <a name="l00027"></a>00027 <a name="l00035"></a>00035 <span class="comment">/*****************************************************************************/</span> <a name="l00036"></a>00036 <span class="comment">/******************************* Include Files *******************************/</span> <a name="l00037"></a>00037 <span class="comment">/*****************************************************************************/</span> <a name="l00038"></a>00038 <a name="l00039"></a>00039 <span class="preprocessor">#include <stdbool.h></span> <a name="l00040"></a>00040 <span class="preprocessor">#include <libintl.h></span> <a name="l00041"></a>00041 <span class="preprocessor">#include <sys/param.h></span> <a name="l00042"></a>00042 <span class="preprocessor">#include <sys/stat.h></span> <a name="l00043"></a>00043 <a name="l00044"></a>00044 <span class="comment">/*****************************************************************************/</span> <a name="l00045"></a>00045 <span class="comment">/*********************************** Defines *********************************/</span> <a name="l00046"></a>00046 <span class="comment">/*****************************************************************************/</span> <a name="l00047"></a>00047 <a name="l00053"></a>00053 <span class="preprocessor">#ifndef _</span> <a name="l00054"></a>00054 <span class="preprocessor"></span><span class="preprocessor">#define _(String) gettext(String)</span> <a name="l00055"></a>00055 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00056"></a>00056 <span class="preprocessor"></span> <a name="l00061"></a>00061 <span class="preprocessor">#ifndef SUCCESS</span> <a name="l00062"></a><a class="code" href="group__constants.html#gaa90cac659d18e8ef6294c7ae337f6b58">00062</a> <span class="preprocessor"></span><span class="preprocessor">#define SUCCESS 0</span> <a name="l00063"></a>00063 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00064"></a>00064 <span class="preprocessor"></span> <a name="l00074"></a>00074 <span class="preprocessor">#define PATH_UTILS_ERROR_BASE -3000</span> <a name="l00075"></a>00075 <span class="preprocessor"></span><span class="preprocessor">#define PATH_UTILS_ERROR_LIMIT (PATH_UTILS_ERROR_BASE+20)</span> <a name="l00076"></a>00076 <span class="preprocessor"></span> <a name="l00081"></a><a class="code" href="group__errors.html#ga773951111b941d35ee911568867408ed">00081</a> <span class="preprocessor">#define IS_PATH_UTILS_ERROR(error) (((error) >= PATH_UTILS_ERROR_BASE) && ((error) < PATH_UTILS_ERROR_LIMIT))</span> <a name="l00082"></a>00082 <span class="preprocessor"></span> <a name="l00088"></a><a class="code" href="group__errors.html#gad52209c21da202201ec59dbf0101962c">00088</a> <span class="preprocessor">#define PATH_UTILS_ERROR_NOT_FULLY_NORMALIZED (PATH_UTILS_ERROR_BASE + 1)</span> <a name="l00089"></a>00089 <span class="preprocessor"></span> <a name="l00094"></a>00094 <span class="comment">/*****************************************************************************/</span> <a name="l00095"></a>00095 <span class="comment">/******************************* Type Definitions ****************************/</span> <a name="l00096"></a>00096 <span class="comment">/*****************************************************************************/</span> <a name="l00097"></a>00097 <a name="l00098"></a>00098 <span class="comment">/*****************************************************************************/</span> <a name="l00099"></a>00099 <span class="comment">/************************* External Global Variables ***********************/</span> <a name="l00100"></a>00100 <span class="comment">/*****************************************************************************/</span> <a name="l00101"></a>00101 <a name="l00102"></a>00102 <span class="comment">/*****************************************************************************/</span> <a name="l00103"></a>00103 <span class="comment">/**************************** Exported Functions ***************************/</span> <a name="l00104"></a>00104 <span class="comment">/*****************************************************************************/</span> <a name="l00105"></a>00105 <a name="l00117"></a>00117 <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="group__functions.html#gac9d1ec5ec150dd6c687cb6b21edd591f" title="Given an error code return the string description.">path_utils_error_string</a>(<span class="keywordtype">int</span> error); <a name="l00118"></a>00118 <a name="l00135"></a>00135 <span class="keywordtype">int</span> <a class="code" href="group__functions.html#gaefce8147704cda31ae8b89df31b70a98" title="Get the basename component of a path.">get_basename</a>(<span class="keywordtype">char</span> *base_name, <span class="keywordtype">size_t</span> base_name_size, <span class="keyword">const</span> <span class="keywordtype">char</span> *path); <a name="l00136"></a>00136 <a name="l00156"></a>00156 <span class="keywordtype">int</span> <a class="code" href="group__functions.html#gae3c805c301cd4e45081ccdb8339b56b7" title="Copy the directory components of a path.">get_dirname</a>(<span class="keywordtype">char</span> *dir_path, <span class="keywordtype">size_t</span> dir_path_size, <span class="keyword">const</span> <span class="keywordtype">char</span> *path); <a name="l00157"></a>00157 <a name="l00178"></a>00178 <span class="keywordtype">int</span> <a class="code" href="group__functions.html#ga3f9fcf87422c3f8add8c9b1a9c6bce1b" title="Get the basaname and directory components of a path.">get_directory_and_base_name</a>(<span class="keywordtype">char</span> *dir_path, <span class="keywordtype">size_t</span> dir_path_size, <a name="l00179"></a>00179 <span class="keywordtype">char</span> *base_name, <span class="keywordtype">size_t</span> base_name_size, <a name="l00180"></a>00180 <span class="keyword">const</span> <span class="keywordtype">char</span> *path); <a name="l00181"></a>00181 <a name="l00188"></a>00188 <span class="keywordtype">bool</span> <a class="code" href="group__functions.html#gaeb140216dea879a8ef07e2c2042ee835" title="Tell if path is absolute or relative.">is_absolute_path</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path); <a name="l00189"></a>00189 <a name="l00203"></a>00203 <span class="keywordtype">int</span> <a class="code" href="group__functions.html#ga291c51b6e47b1792b7d7573e0eb8914c" title="Concatenate two components of a path.">path_concat</a>(<span class="keywordtype">char</span> *path, <span class="keywordtype">size_t</span> path_size, <span class="keyword">const</span> <span class="keywordtype">char</span> *head, <span class="keyword">const</span> <span class="keywordtype">char</span> *tail); <a name="l00204"></a>00204 <a name="l00217"></a>00217 <span class="keywordtype">int</span> <a class="code" href="group__functions.html#ga6c4f9829d7ce496f32221491ff0cfdec" title="Convert a path into absolute.">make_path_absolute</a>(<span class="keywordtype">char</span> *absolute_path, <span class="keywordtype">size_t</span> absolute_path_size, <span class="keyword">const</span> <span class="keywordtype">char</span> *path); <a name="l00218"></a>00218 <a name="l00267"></a>00267 <span class="keywordtype">char</span> **<a class="code" href="group__functions.html#gabfd0ed1e7fb0db3c1df00106fe759e5c" title="Split a file system path into individual components.">split_path</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keywordtype">int</span> *count); <a name="l00268"></a>00268 <a name="l00309"></a>00309 <span class="keywordtype">int</span> <a class="code" href="group__functions.html#gaf76509b5eaf5102f1eacf567fcc77918" title="Normalizes a path.">normalize_path</a>(<span class="keywordtype">char</span> *normalized_path, <span class="keywordtype">size_t</span> normalized_path_size, <span class="keyword">const</span> <span class="keywordtype">char</span> *path); <a name="l00310"></a>00310 <a name="l00329"></a>00329 <span class="keywordtype">int</span> <a class="code" href="group__functions.html#gad575fe80157c6bf2335cfc628e35fd90" title="Find the common prefix between two paths.">common_path_prefix</a>(<span class="keywordtype">char</span> *common_path, <a name="l00330"></a>00330 <span class="keywordtype">size_t</span> common_path_size, <a name="l00331"></a>00331 <span class="keywordtype">int</span> *common_count, <a name="l00332"></a>00332 <span class="keyword">const</span> <span class="keywordtype">char</span> *path1, <span class="keyword">const</span> <span class="keywordtype">char</span> *path2); <a name="l00333"></a>00333 <a name="l00334"></a>00334 <a name="l00341"></a>00341 <span class="keywordtype">int</span> <a class="code" href="group__functions.html#ga075b94d58520a9a6564370d18c9525c3" title="Make the input path absolute if it&#39;s not already, then normalize it.">make_normalized_absolute_path</a>(<span class="keywordtype">char</span> *result_path, <span class="keywordtype">size_t</span> result_path_size, <span class="keyword">const</span> <span class="keywordtype">char</span> *path); <a name="l00342"></a>00342 <a name="l00358"></a>00358 <span class="keywordtype">int</span> <a class="code" href="group__functions.html#gac6700e3cc03118457584eef2a5b7a014">find_existing_directory_ancestor</a>(<span class="keywordtype">char</span> *ancestor, <span class="keywordtype">size_t</span> ancestor_size, <span class="keyword">const</span> <span class="keywordtype">char</span> *path); <a name="l00359"></a>00359 <a name="l00374"></a><a class="code" href="group__functions.html#ga49cbf176c7075ddc62cc04b672c8d5fd">00374</a> <span class="keyword">typedef</span> bool (*<a class="code" href="group__functions.html#ga49cbf176c7075ddc62cc04b672c8d5fd" title="callback for the directory_list() function">directory_list_callback_t</a>)(<span class="keyword">const</span> <span class="keywordtype">char</span> *directory, <span class="keyword">const</span> <span class="keywordtype">char</span> *base_name, <a name="l00375"></a>00375 <span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keyword">struct </span>stat *info, <a name="l00376"></a>00376 <span class="keywordtype">void</span> *user_data); <a name="l00397"></a>00397 <span class="keywordtype">int</span> <a class="code" href="group__functions.html#gab5e79eb6143081c1e703a49aed644275" title="Walk a directory.">directory_list</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path, <span class="keywordtype">bool</span> recursive, <a name="l00398"></a>00398 <a class="code" href="group__functions.html#ga49cbf176c7075ddc62cc04b672c8d5fd" title="callback for the directory_list() function">directory_list_callback_t</a> callback, <span class="keywordtype">void</span> *user_data); <a name="l00399"></a>00399 <a name="l00423"></a>00423 <span class="keywordtype">bool</span> <a class="code" href="group__functions.html#gaab307c1e13be03bb6f60be0064d5a641" title="Tell if one path is ancestor of another.">is_ancestor_path</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *ancestor, <span class="keyword">const</span> <span class="keywordtype">char</span> *path); <a name="l00424"></a>00424 <a name="l00429"></a>00429 <span class="preprocessor">#endif </span><span class="comment">/* PATH_UTILS_H */</span> </pre></div></div> <!--- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> </div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <hr size="1"/><address style="text-align: right;"><small>Generated on 25 Jun 2011 for path_utils by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> </body> </html>