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__URL_REVS "revs"
00127
00131 #define WAA__COPYFROM_EXT "Copy"
00132
00151 #define WAA__FILE_MD5s_EXT "md5s"
00152
00154 #define WAA__PROP_EXT "prop"
00155
00157 #define WAA__CONFLICT_EXT "cflct"
00158
00165 #define WAA__FILE_INODE_EXT "fino"
00166
00167 #define WAA__DIR_INODE_EXT "dino"
00168
00175 #define WAA__FILE_NAME_EXT "fname"
00176
00177 #define WAA__DIR_NAME_EXT "dname"
00178
00182 #define WAA__WRITE (O_WRONLY | O_CREAT | O_TRUNC)
00183 #define WAA__READ (O_RDONLY)
00184 #define WAA__APPEND (O_APPEND | O_CREAT)
00185
00189
00190
00191 #define WAA__MAX_EXT_LENGTH max( \
00192 max( \
00193 max(strlen(WAA__CONFLICT_EXT), \
00194 strlen(WAA__COPYFROM_EXT)), \
00195 strlen(WAA__IGNORE_EXT) ), \
00196 max( \
00197 max(max(strlen(WAA__DIR_EXT), \
00198 strlen(WAA__FILE_MD5s_EXT)), \
00199 max(strlen(WAA__PROP_EXT), \
00200 strlen(WAA__CONFLICT_EXT)) ), \
00201 max( \
00202 max(strlen(WAA__FILE_INODE_EXT), \
00203 strlen(WAA__DIR_INODE_EXT)), \
00204 max(strlen(WAA__FILE_NAME_EXT), \
00205 strlen(WAA__DIR_NAME_EXT)) ) ) )
00206
00208 int waa__save_cwd(char **where, int *len, int additional);
00210 int waa__init(void);
00211
00213 int waa__mkdir_mask(char *dir, int including_last, int mask);
00215 int waa__mkdir(char *dir, int including_last);
00216
00217
00218
00219 int waa__open(char *path,
00220 const char *extension,
00221 int mode,
00222 int *filehandle);
00225 int waa__close(int filehandle, int has_failed);
00228 int waa__open_dir(char *directory,
00229 int write,
00230 int *fh);
00232 int waa__build_tree(struct estat *root);
00234 int waa__output_tree(struct estat *root);
00236 int waa__input_tree(struct estat *root,
00237 struct waa__entry_blocks_t **blocks,
00238 action_t *callback);
00240 int waa__open_byext(char *directory,
00241 char *extension,
00242 int write,
00243 int *fh);
00245 int waa__load_repos_urls(char *dir, int reserve_space);
00248 int waa__load_repos_urls_silent(char *dir, int reserve_space);
00250 int waa__given_or_current_wd(char *directory, char **erg);
00252 int waa__make_info_link(char *directory, char *name, char *dest);
00255 int waa__delete_byext(char *path,
00256 char *extension,
00257 int ignore_not_exist);
00259 int waa__read_or_build_tree(struct estat *root,
00260 int argc, char *normalized[], char *orig[],
00261 action_t *callback,
00262 int return_ENOENT);
00263
00264
00265 #define FCB__PUT_DOTSLASH (1)
00266 #define FCB__NO_REALPATH (2)
00267
00269 int waa__find_common_base2(int argc, char *args[],
00270 char ***normalized_paths,
00271 int flags);
00273 static inline int waa__find_common_base(int argc, char *args[],
00274 char **normalized[])
00275 {
00276 return waa__find_common_base2(argc, args, normalized, 0);
00277 }
00280 int waa__find_base(struct estat *root, int *argc, char ***args);
00281
00283 int waa__create_working_copy(const char const *wc_dir);
00286 int waa__set_working_copy(const char const *wc_dir);
00287
00288
00292 #define GWD_WAA (1)
00293
00294 #define GWD_CONF (2)
00295
00296 #define GWD_MKDIR (4)
00297
00299 int waa__get_waa_directory(char *path,
00300 char **erg, char **eos, char **start_of_spec,
00301 int flags);
00304 static inline int waa__get_gwd_flag(const char *const extension)
00305 { return !extension || (isupper(extension[0])) ? GWD_CONF : GWD_WAA; }
00310 int waa__update_tree(struct estat *root,
00311 struct waa__entry_blocks_t *blocks);
00319 int waa__new_entry_block(struct estat *entry, int count,
00320 struct waa__entry_blocks_t *previous);
00322 static inline int waa__insert_entry_block(struct estat *entry, int count)
00323 { return waa__new_entry_block(entry, count, &waa__entry_block); }
00324
00327 int waa__partial_update(struct estat *root,
00328 int argc, char *normalized[], char *orig[],
00329 struct waa__entry_blocks_t *blocks);
00330
00334 int waa__do_sorted_tree(struct estat *root, action_t handler);
00335
00338 int waa__dir_enum(struct estat *this,
00339 int est_count,
00340 int by_name);
00341
00343 int waa__copy_entries(struct estat *src, struct estat *dest);
00344
00346 #define HEADER_LEN (64)
00347
00348 #define WAA_VERSION (6)
00349
00357 #define SET_REVNUM (-12)
00358
00359
00361 int waa__get_tmp_name(const char *base_dir,
00362 char **output, apr_file_t **handle,
00363 apr_pool_t *pool);
00364
00365
00367 extern char *wc_path;
00369 extern int wc_path_len;
00371 extern int waa_tmp_path_len;
00372
00375 extern char *waa_tmp_path, *waa_tmp_fn,
00376 *conf_tmp_path, *conf_tmp_fn;
00380 #endif
00381