00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __WAA_H__
00010 #define __WAA_H__
00011
00012 #include <ctype.h>
00013 #include <fcntl.h>
00014
00015 #include "global.h"
00016 #include "actions.h"
00017
00018
00025 #define max(a,b) \
00026 ({ typeof (a) _a = (a); \
00027 typeof (b) _b = (b); \
00028 _a > _b ? _a : _b; })
00029
00030
00038 struct waa__entry_blocks_t {
00040 struct estat *first;
00042 struct waa__entry_blocks_t *next, *prev;
00045 int count;
00046 };
00047
00048
00050 extern struct waa__entry_blocks_t waa__entry_block;
00051
00052
00053
00111 #define WAA__DIR_EXT "dir"
00112
00117 #define WAA__IGNORE_EXT "Ign"
00118
00121 #define WAA__URLLIST_EXT "urls"
00122
00126 #define WAA__COPYFROM_EXT "Copy"
00127
00146 #define WAA__FILE_MD5s_EXT "md5s"
00147
00149 #define WAA__PROP_EXT "prop"
00150
00152 #define WAA__CONFLICT_EXT "cflct"
00153
00160 #define WAA__FILE_INODE_EXT "fino"
00161
00162 #define WAA__DIR_INODE_EXT "dino"
00163
00170 #define WAA__FILE_NAME_EXT "fname"
00171
00172 #define WAA__DIR_NAME_EXT "dname"
00173
00177 #define WAA__WRITE (O_WRONLY | O_CREAT | O_TRUNC)
00178 #define WAA__READ (O_RDONLY)
00179 #define WAA__APPEND (O_APPEND | O_CREAT)
00180
00184
00185
00186 #define WAA__MAX_EXT_LENGTH max( \
00187 max( \
00188 max(strlen(WAA__CONFLICT_EXT), \
00189 strlen(WAA__COPYFROM_EXT)), \
00190 strlen(WAA__IGNORE_EXT) ), \
00191 max( \
00192 max(max(strlen(WAA__DIR_EXT), \
00193 strlen(WAA__FILE_MD5s_EXT)), \
00194 max(strlen(WAA__PROP_EXT), \
00195 strlen(WAA__CONFLICT_EXT)) ), \
00196 max( \
00197 max(strlen(WAA__FILE_INODE_EXT), \
00198 strlen(WAA__DIR_INODE_EXT)), \
00199 max(strlen(WAA__FILE_NAME_EXT), \
00200 strlen(WAA__DIR_NAME_EXT)) ) ) )
00201
00203 int waa__save_cwd(char **where, int *len, int additional);
00205 int waa__init(void);
00206
00208 int waa__mkdir_mask(char *dir, int including_last, int mask);
00210 int waa__mkdir(char *dir, int including_last);
00211
00212
00213
00214 int waa__open(char *path,
00215 const char *extension,
00216 int mode,
00217 int *filehandle);
00220 int waa__close(int filehandle, int has_failed);
00223 int waa__open_dir(char *directory,
00224 int write,
00225 int *fh);
00227 int waa__build_tree(struct estat *root);
00229 int waa__output_tree(struct estat *root);
00231 int waa__input_tree(struct estat *root,
00232 struct waa__entry_blocks_t **blocks,
00233 action_t *callback);
00235 int waa__open_byext(char *directory,
00236 char *extension,
00237 int write,
00238 int *fh);
00240 int waa__load_repos_urls(char *dir, int reserve_space);
00243 int waa__load_repos_urls_silent(char *dir, int reserve_space);
00245 int waa__given_or_current_wd(char *directory, char **erg);
00247 int waa__make_info_link(char *directory, char *name, char *dest);
00250 int waa__delete_byext(char *path,
00251 char *extension,
00252 int ignore_not_exist);
00254 int waa__read_or_build_tree(struct estat *root,
00255 int argc, char *normalized[], char *orig[],
00256 action_t *callback,
00257 int return_ENOENT);
00258
00259
00260 #define FCB__PUT_DOTSLASH (1)
00261 #define FCB__NO_REALPATH (2)
00262
00264 int waa__find_common_base2(int argc, char *args[],
00265 char ***normalized_paths,
00266 int flags);
00268 static inline int waa__find_common_base(int argc, char *args[],
00269 char **normalized[])
00270 {
00271 return waa__find_common_base2(argc, args, normalized, 0);
00272 }
00275 int waa__find_base(struct estat *root, int *argc, char ***args);
00276
00278 int waa__create_working_copy(const char const *wc_dir);
00281 int waa__set_working_copy(const char const *wc_dir);
00282
00283
00287 #define GWD_WAA (1)
00288
00289 #define GWD_CONF (2)
00290
00291 #define GWD_MKDIR (4)
00292
00294 int waa__get_waa_directory(char *path,
00295 char **erg, char **eos, char **start_of_spec,
00296 int flags);
00299 static inline int waa__get_gwd_flag(const char *const extension)
00300 { return !extension || (isupper(extension[0])) ? GWD_CONF : GWD_WAA; }
00305 int waa__update_tree(struct estat *root,
00306 struct waa__entry_blocks_t *blocks);
00314 int waa__new_entry_block(struct estat *entry, int count,
00315 struct waa__entry_blocks_t *previous);
00317 static inline int waa__insert_entry_block(struct estat *entry, int count)
00318 { return waa__new_entry_block(entry, count, &waa__entry_block); }
00319
00322 int waa__partial_update(struct estat *root,
00323 int argc, char *normalized[], char *orig[],
00324 struct waa__entry_blocks_t *blocks);
00325
00329 int waa__do_sorted_tree(struct estat *root, action_t handler);
00330
00333 int waa__dir_enum(struct estat *this,
00334 int est_count,
00335 int by_name);
00336
00338 int waa__copy_entries(struct estat *src, struct estat *dest);
00339
00341 #define HEADER_LEN (64)
00342
00343 #define WAA_VERSION (6)
00344
00352 #define SET_REVNUM (-12)
00353
00354
00356 int waa__get_tmp_name(const char *base_dir,
00357 char **output, apr_file_t **handle,
00358 apr_pool_t *pool);
00359
00360
00362 extern char *wc_path;
00364 extern int wc_path_len;
00366 extern int waa_tmp_path_len;
00367
00370 extern char *waa_tmp_path, *waa_tmp_fn,
00371 *conf_tmp_path, *conf_tmp_fn;
00375 #endif
00376