• Main Page
  • Modules
  • Files
  • File List

/home/bos/sgallagh/workspace/ding-libs/path_utils/path_utils.h

00001 /*
00002     Authors:
00003         John Dennis <jdennis.redhat.com>
00004 
00005     Copyright (C) 2009 Red Hat
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU Lesser General Public License as published by
00009     the Free Software Foundation; either version 3 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public License
00018     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 #ifndef PATH_UTILS_H
00022 #define PATH_UTILS_H
00023 
00024 /*****************************************************************************/
00025 /******************************** Documentation ******************************/
00026 /*****************************************************************************/
00027 
00035 /*****************************************************************************/
00036 /******************************* Include Files *******************************/
00037 /*****************************************************************************/
00038 
00039 #include <stdbool.h>
00040 #include <libintl.h>
00041 #include <sys/param.h>
00042 #include <sys/stat.h>
00043 
00044 /*****************************************************************************/
00045 /*********************************** Defines *********************************/
00046 /*****************************************************************************/
00047 
00053 #ifndef _
00054 #define _(String) gettext(String)
00055 #endif
00056 
00061 #ifndef SUCCESS
00062 #define SUCCESS 0
00063 #endif
00064 
00074 #define PATH_UTILS_ERROR_BASE -3000
00075 #define PATH_UTILS_ERROR_LIMIT (PATH_UTILS_ERROR_BASE+20)
00076 
00081 #define IS_PATH_UTILS_ERROR(error)  (((error) >= PATH_UTILS_ERROR_BASE) && ((error) < PATH_UTILS_ERROR_LIMIT))
00082 
00088 #define PATH_UTILS_ERROR_NOT_FULLY_NORMALIZED   (PATH_UTILS_ERROR_BASE + 1)
00089 
00094 /*****************************************************************************/
00095 /******************************* Type Definitions ****************************/
00096 /*****************************************************************************/
00097 
00098 /*****************************************************************************/
00099 /*************************  External Global Variables  ***********************/
00100 /*****************************************************************************/
00101 
00102 /*****************************************************************************/
00103 /****************************  Exported Functions  ***************************/
00104 /*****************************************************************************/
00105 
00117 const char *path_utils_error_string(int error);
00118 
00135 int get_basename(char *base_name, size_t base_name_size, const char *path);
00136 
00156 int get_dirname(char *dir_path, size_t dir_path_size, const char *path);
00157 
00178 int get_directory_and_base_name(char *dir_path, size_t dir_path_size,
00179                                 char *base_name, size_t base_name_size,
00180                                 const char *path);
00181 
00188 bool is_absolute_path(const char *path);
00189 
00203 int path_concat(char *path, size_t path_size, const char *head, const char *tail);
00204 
00217 int make_path_absolute(char *absolute_path, size_t absolute_path_size, const char *path);
00218 
00267 char **split_path(const char *path, int *count);
00268 
00309 int normalize_path(char *normalized_path, size_t normalized_path_size, const char *path);
00310 
00329 int common_path_prefix(char *common_path,
00330                        size_t common_path_size,
00331                        int *common_count,
00332                        const char *path1, const char *path2);
00333 
00334 
00341 int make_normalized_absolute_path(char *result_path, size_t result_path_size, const char *path);
00342 
00358 int find_existing_directory_ancestor(char *ancestor, size_t ancestor_size, const char *path);
00359 
00374 typedef bool (*directory_list_callback_t)(const char *directory, const char *base_name,
00375                                           const char *path, struct stat *info,
00376                                           void *user_data);
00397 int directory_list(const char *path, bool recursive,
00398                    directory_list_callback_t callback, void *user_data);
00399 
00423 bool is_ancestor_path(const char *ancestor, const char *path);
00424 
00429 #endif /* PATH_UTILS_H */

Generated on Mon Sep 27 2010 for path_utils by  doxygen 1.7.1