doc
|
00001 /* 00002 * libcsync -- a library to sync a directory with another 00003 * 00004 * Copyright (c) 2008 by Andreas Schneider <mail@cynapses.org> 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef _CSYNC_UPDATE_H 00022 #define _CSYNC_UPDATE_H 00023 00024 #include "csync.h" 00025 #include "vio/csync_vio_file_stat.h" 00026 00027 /** 00028 * @file csync_update.h 00029 * 00030 * @brief Update Detection 00031 * 00032 * TODO 00033 * 00034 * @defgroup csyncUpdateDetectionInternals csync update detection internals 00035 * @ingroup csyncInternalAPI 00036 * 00037 * @{ 00038 */ 00039 00040 /** 00041 * Types for files 00042 */ 00043 enum csync_ftw_flags_e { 00044 CSYNC_FTW_FLAG_FILE, /* Regular file. */ 00045 CSYNC_FTW_FLAG_DIR, /* Directory. */ 00046 CSYNC_FTW_FLAG_DNR, /* Unreadable directory. */ 00047 CSYNC_FTW_FLAG_NSTAT, /* Unstatable file. */ 00048 CSYNC_FTW_FLAG_SLINK, /* Symbolic link. */ 00049 CSYNC_FTW_FLAG_SPEC, /* Special file (fifo, ...). */ 00050 /* These flags are only passed from the `nftw' function. */ 00051 CSYNC_FTW_FLAG_DP, /* Directory, all subdirs have been visited. */ 00052 CSYNC_FTW_FLAG_SLN /* Symbolic link naming non-existing file. */ 00053 }; 00054 00055 typedef int (*csync_walker_fn) (CSYNC *ctx, const char *file, 00056 const csync_vio_file_stat_t *fs, enum csync_ftw_flags_e flag); 00057 00058 /** 00059 * @brief The walker function to use in the file tree walker. 00060 * 00061 * @param ctx The used csync context. 00062 * 00063 * @param file The file we are researching. 00064 * 00065 * @param fs The stat information we got. 00066 * 00067 * @param flag The flag describing the type of the file. 00068 * 00069 * @return 0 on success, < 0 on error. 00070 */ 00071 int csync_walker(CSYNC *ctx, const char *file, const csync_vio_file_stat_t *fs, 00072 enum csync_ftw_flags_e flag); 00073 00074 /** 00075 * @brief The file tree walker. 00076 * 00077 * This function walks through the directory tree that is located under the uri 00078 * specified. It calls a walker function which is provided as a function pointer 00079 * once for each entry in the tree. By default, directories are handled before 00080 * the files and subdirectories they contain (pre-order traversal). 00081 * 00082 * @param ctx The csync context to use. 00083 * 00084 * @param uri The uri/path to the directory tree to walk. 00085 * 00086 * @param fn The walker function to call once for each entry. 00087 * 00088 * @param depth The max depth to walk down the tree. 00089 * 00090 * @return 0 on success, < 0 on error. If fn() returns non-zero, then the tree 00091 * walk is terminated and the value returned by fn() is returned as the 00092 * result. 00093 */ 00094 int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn, 00095 unsigned int depth); 00096 00097 #endif /* _CSYNC_UPDATE_H */ 00098 00099 /* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */