#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <ctype.h>
#include <sys/select.h>
#include "url.h"
#include "waa.h"
#include "cache.h"
#include "helper.h"
#include "est_ops.h"
#include "checksum.h"
#include "racallback.h"
Go to the source code of this file.
Defines | |
Flags to store which attributes we already got for this URL. | |
#define | HAVE_NAME (1) |
#define | HAVE_PRIO (2) |
#define | HAVE_URL (4) |
#define | HAVE_TARGET (8) |
#define | HAVE_READONLY (16) |
Functions | |
int | url__find_by_name (const char *name, struct url_t **storage) |
-. | |
int | url__find_by_url_in_list (char *url, struct url_t **list, int count, struct url_t **storage) |
-. | |
int | url__find_by_url (char *url, struct url_t **storage) |
Wrapper for url__find_by_url_in_list(). | |
int | url__find_by_intnum (int intnum, struct url_t **storage) |
-. | |
int | url__parse (char *input, struct url_t *storage, int *def_parms) |
-. | |
int | url__insert_or_replace (char *eurl, struct url_t **storage, int *existed) |
-. | |
int | find_next_zero_bit (fd_set *fd, int from) |
Simple function to find an unused id. | |
int | url___set_internal_nums (void) |
Set the internal number of all URLs which don't already have one. | |
int | url__allocate (int reserve_space) |
-. | |
int | url__indir_sorter (const void *a, const void *b) |
-. | |
int | url__load_list (char *dir, int reserve_space) |
-. | |
int | url__load_nonempty_list (char *dir, int reserve_space) |
-. | |
int | url__output_list (void) |
-. | |
int | url__open_session (svn_ra_session_t **session, char **missing_dirs) |
-. | |
int | url__close_session (struct url_t *cur) |
-. | |
int | url__close_sessions (void) |
-. | |
int | url__current_has_precedence (struct url_t *to_compare) |
-. | |
int | url___dump (char *format) |
Dumps the URLs to STDOUT . | |
int | url__other_full_url (struct estat *sts, struct url_t *url, char **output) |
-. | |
int | url__full_url (struct estat *sts, char **url) |
-. | |
int | url__find (char *url, struct url_t **output) |
-. | |
int | url__work (struct estat *root UNUSED, int argc, char *argv[]) |
-. | |
int | url__mark_todo (void) |
-. | |
int | url__store_url_name (char *parm) |
-. | |
int | url__canonical_rev (struct url_t *url, svn_revnum_t *rev) |
-. | |
int | url__iterator2 (svn_revnum_t *target_rev, int only_if_count, char **missing) |
-. | |
Variables | |
char ** | url__parm_list = NULL |
-. | |
int | url__parm_list_len = 0 |
int | url__parm_list_used = 0 |
How many URLs were given as parameters. |
Definition in file url.c.
#define HAVE_NAME (1) |
#define HAVE_PRIO (2) |
#define HAVE_READONLY (16) |
#define HAVE_TARGET (8) |
#define HAVE_URL (4) |
int find_next_zero_bit | ( | fd_set * | fd, | |
int | from | |||
) |
Simple function to find an unused id.
Slow, but easy. I'd like to use the linux-kernel bitmap functions - but they're not exported, and not available everywhere.
Definition at line 647 of file url.c.
Referenced by url___set_internal_nums().
int url___dump | ( | char * | format | ) |
Dumps the URLs to STDOUT
.
Definition at line 1123 of file url.c.
References cs__two_ch2bin(), url_t::current_rev, hlp__rev_to_string(), url_t::internal_number, url_t::is_readonly, url_t::name, opt__is_verbose(), url_t::priority, STOPIF_CODE_EPIPE, STOPIF_CODE_ERR, url_t::target_rev, url_t::url, urllist, and urllist_count.
Referenced by url__work().
int url___set_internal_nums | ( | void | ) |
Set the internal number of all URLs which don't already have one.
I'm aware that a normal fd_set
is normally limited to a few hundred bits (eg. for use with 1024 filehandles); but the low-level ops don't know what we're doing, anyway. So we could just extend the bitmap, and it should work as before (although maybe there's be a sanity test).
Sadly find_next_zero_bit and friends are not exported from the kernel, so we have to use FD_ISSET
and similar; there might be faster/better alternatives. Tell me if you know one.
Definition at line 665 of file url.c.
References DEBUGP, find_next_zero_bit(), url_t::internal_number, INVALID_INTERNAL_NUMBER, STOPIF_CODE_ERR, url_t::url, urllist, and urllist_count.
Referenced by url__output_list().
int url__allocate | ( | int | reserve_space | ) |
-.
Allocate additional space for the given number of URLs.
Definition at line 731 of file url.c.
References hlp__calloc(), hlp__realloc(), STOPIF, urllist, and urllist_count.
Referenced by co__work(), url__load_list(), and url__work().
int url__canonical_rev | ( | struct url_t * | url, | |
svn_revnum_t * | rev | |||
) |
-.
Changes the revision number, if SVN_INVALID_REVNUM
, to the real value.
DAV (http://
and https://
) don't like getting SVN_INVALID_REVNUM
on some operations; they throw an 175007 "HTTP Path Not Found", and "REPORT request failed on '...'".
So we need the real HEAD
.
We try to be fast, and only fetch the value if we really need it.
Definition at line 1543 of file url.c.
References BUG_ON, DEBUGP, url_t::head_rev, url_t::pool, url_t::session, STOPIF_SVNERR, and url_t::url.
Referenced by df__do_diff(), df__work(), exp__do(), log__work(), url__iterator2(), and url__open_session().
int url__close_session | ( | struct url_t * | cur | ) |
-.
Closes given RA session and frees associated memory.
Definition at line 1073 of file url.c.
References BUG_ON, DEBUGP, url_t::pool, url_t::session, and url_t::url.
Referenced by url__close_sessions().
int url__close_sessions | ( | void | ) |
-.
Closes all RA sessions.
Definition at line 1093 of file url.c.
References IF_FREE, STOPIF, url__close_session(), url__parm_list, url__parm_list_len, url__parm_list_used, urllist, and urllist_count.
Referenced by main().
int url__current_has_precedence | ( | struct url_t * | to_compare | ) |
-.
Returns whether current_url has a higher priority than the URL to compare.
If an entry has no URL yet (is new), to_compare is NULL
, and the current_url has higher priority; this is common, and so done here too.
Definition at line 1115 of file url.c.
References current_url, and url_t::priority.
Referenced by cb___apply_textdelta(), cb___store_prop(), cb__add_entry(), sync___recurse(), up__change_dir_prop(), and up__change_file_prop().
int url__find | ( | char * | url, | |
struct url_t ** | output | |||
) |
-.
Looks for an URL matching url, and returns its address.
Definition at line 1298 of file url.c.
References url_t::url, url_t::urllen, urllist, and urllist_count.
Referenced by df__do_diff(), and rev__install_file().
int url__find_by_intnum | ( | int | intnum, | |
struct url_t ** | storage | |||
) |
-.
Returns a struct url_t matching the given internal number.
Definition at line 306 of file url.c.
References DEBUGP, urllist, and urllist_count.
Referenced by ops__load_1entry().
int url__find_by_name | ( | const char * | name, | |
struct url_t ** | storage | |||
) |
-.
Returns a struct url_t matching the given string.
Because this may be called below input_tree, returning ENOENT
could be interpreted as no dirlist found - which has to be allowed in some cases. So this returns EADDRNOTAVAIL
.
Definition at line 237 of file url.c.
References DEBUGP, urllist, and urllist_count.
Referenced by au__prepare_for_added(), ci__work(), log__work(), url__insert_or_replace(), and url__mark_todo().
int url__find_by_url | ( | char * | url, | |
struct url_t ** | storage | |||
) |
Wrapper for url__find_by_url_in_list().
Returns a struct url_t matching the given url.
Definition at line 299 of file url.c.
References url__find_by_url_in_list(), urllist, and urllist_count.
Referenced by url__insert_or_replace().
int url__find_by_url_in_list | ( | char * | url, | |
struct url_t ** | list, | |||
int | count, | |||
struct url_t ** | storage | |||
) |
-.
Because this may be called below input_tree, returning ENOENT
could be interpreted as no dirlist found - which has to be allowed in some cases. So this returns EADDRNOTAVAIL
.
Definition at line 272 of file url.c.
References DEBUGP.
Referenced by url__find_by_url(), and url__work().
int url__full_url | ( | struct estat * | sts, | |
char ** | url | |||
) |
-.
Returns the full URL for this entry.
Definition at line 1285 of file url.c.
References STOPIF, estat::url, and url__other_full_url().
Referenced by cm___make_copy(), df__do_diff(), st__print_entry_info(), st__print_status(), and sync___recurse().
int url__indir_sorter | ( | const void * | a, | |
const void * | b | |||
) |
-.
For use in qsort()
.
Definition at line 757 of file url.c.
References url__sorter().
Referenced by url__load_list().
int url__insert_or_replace | ( | char * | eurl, | |
struct url_t ** | storage, | |||
int * | existed | |||
) |
-.
Insert or replace URL.
This functions returns 0 for success. Error codes (eg EADDRNOTAVAIL
) are possible.
If *existed is non- NULL
, it is set to 0 for a new URL or EEXIST
if an existing URL was overwritten.
The URL is parsed into an empty space at the end of urllist , which must already exist!
If the same URL was already used, the old entry gets overwritten.
Definition at line 558 of file url.c.
References HAVE_NAME, HAVE_PRIO, HAVE_READONLY, HAVE_TARGET, HAVE_URL, url_t::is_readonly, url_t::name, url_t::priority, STOPIF, STOPIF_CODE_ERR, url_t::target_rev, url_t::url, url__find_by_name(), url__find_by_url(), url__parse(), urllist, and urllist_count.
Referenced by co__work(), url__load_list(), and url__work().
int url__iterator2 | ( | svn_revnum_t * | target_rev, | |
int | only_if_count, | |||
char ** | missing | |||
) |
-.
Simple function setting current_url
, and returning whether there's something to do.
Returns 0 as long as there's an URL to process; current_url
is set, and opened. In target_rev the target revision (as per default of this URL, or as given by the user) is returned.
If current_url
is not NULL upon entry the connection to this URL is closed, and its memory freed.
If called with target_rev NULL
, the internal index is reset, and no URL initialization is done.
At the end of the list EOF
is given.
Definition at line 1585 of file url.c.
References url_t::current_target_override, url_t::current_target_rev, current_url, DEBUGP, url_t::entry_list_count, hlp__rev_to_string(), opt_target_revision, opt_target_revisions_given, STOPIF, url_t::target_rev, url_t::url, url__canonical_rev(), url__open_session(), url__to_be_handled(), urllist, and urllist_count.
Referenced by url__iterator().
int url__load_list | ( | char * | dir, | |
int | reserve_space | |||
) |
-.
Loads the URLs for the given dir.
reserve_space says how much additional space should be allocated.
This function sets urllist_mem to the string buffer allocated, and the urllist pointers get set to the URLs. If no dir
file is found, ENOENT
is returned without an error message.
Definition at line 776 of file url.c.
References url_t::current_rev, DEBUGP, hlp__alloc(), url_t::internal_number, STOPIF, STOPIF_CODE_ERR, url__allocate(), url__indir_sorter(), url__insert_or_replace(), urllist, urllist_count, waa__open_byext(), WAA__READ, and WAA__URLLIST_EXT.
Referenced by au__prepare_for_added(), bld__work(), cat__work(), cm__detect(), ign__work(), info__work(), st__work(), url__load_nonempty_list(), and url__work().
int url__load_nonempty_list | ( | char * | dir, | |
int | reserve_space | |||
) |
-.
Wrapper for url__load_list(); Cries for ENOENT
.
This prints a message and stops if no URLs could be read.
Definition at line 873 of file url.c.
References STOPIF_CODE_ERR, url__load_list(), urllist_count, and wc_path.
Referenced by ci__work(), cm__uncopy(), cm__work(), df__work(), log__work(), res__work(), rev__work(), sync__work(), and up__work().
int url__mark_todo | ( | void | ) |
-.
Marks URLs for handling.
This function takes a list of URL names (and optionally target revisions), and marks the URLs by setting url_t::to_be_handled.
url__parm_list gets destroyed.
Definition at line 1460 of file url.c.
References url_t::current_target_override, url_t::current_target_rev, DEBUGP, hlp__parse_rev(), STOPIF, url_t::to_be_handled, url_t::url, url__find_by_name(), url__parm_list, and url__parm_list_used.
Referenced by au__prepare_for_added(), df__work(), and up__work().
int url__open_session | ( | svn_ra_session_t ** | session, | |
char ** | missing_dirs | |||
) |
-.
Opens a session to the current_url .
If missing_dirs is not NULL
, this function returns in *missing_dirs
a copied string with the missing path components from current_url->url
(which should be freed later).
NULL
is returned (not a pointer to a \0
).
This is needed for the mkdir_base
option; we cannot create the hierarchy here, because we need a commit editor for that, but in ci__directory() we cannot use a session based on an non-existing URL.
Definition at line 960 of file url.c.
References BUG_ON, cb__cb_table, cb__does_path_exist(), current_url, DEBUGP, global_pool, hlp__get_svn_config(), hlp__strnalloc(), IF_FREE, url_t::pool, url_t::session, STOPIF, STOPIF_CODE_EPIPE, STOPIF_SVNERR, STOPIF_SVNERR_TEXT, url_t::url, url__canonical_rev(), and url_t::urllen.
Referenced by cat__work(), ci__work(), df__do_diff(), exp__do(), log__work(), rev__install_file(), and url__iterator2().
-.
Returns the full URL for this entry for some other than the highest priority URL.
The space for the output is allocated, and must not be freed.
Definition at line 1243 of file url.c.
References cch__add(), ops__build_path(), estat::path_len, PATH_SEPARATOR, STOPIF, url_t::url, and url_t::urllen.
Referenced by url__full_url().
int url__output_list | ( | void | ) |
-.
Writes the URL list back.
Definition at line 893 of file url.c.
References url_t::current_rev, DEBUGP, url_t::internal_number, url_t::is_readonly, url_t::name, url_t::priority, STOPIF, STOPIF_CODE_ERR, url_t::target_rev, url_t::url, url___set_internal_nums(), urllist, urllist_count, waa__close(), waa__open_byext(), WAA__URLLIST_EXT, and WAA__WRITE.
Referenced by ci__work(), co__work(), sync__work(), up__work(), and url__work().
int url__parse | ( | char * | input, | |
struct url_t * | storage, | |||
int * | def_parms | |||
) |
-.
Parses the given string into the URL storage.
This function preserves it's input. If storage is non- NULL
, it's ->name
member get's a copy of the given (or a deduced) name.
In def_parms the parameters found are flagged - see url_flags; if def_parms is NULL
, an URL must be present.
Definition at line 354 of file url.c.
References url_t::current_rev, url_t::current_target_override, DEBUGP, HAVE_NAME, HAVE_PRIO, HAVE_READONLY, HAVE_TARGET, HAVE_URL, url_t::head_rev, hlp__parse_rev(), hlp__rev_to_string(), hlp__strdup(), hlp__strnalloc(), url_t::internal_number, INVALID_INTERNAL_NUMBER, url_t::is_readonly, url_t::name, url_t::priority, STOPIF, STOPIF_CODE_ERR, url_t::target_rev, url_t::url, and url_t::urllen.
Referenced by exp__work(), and url__insert_or_replace().
int url__store_url_name | ( | char * | parm | ) |
-.
Remember URL name parameter for later processing.
We may have to reallocate. We don't want to allocate a pointer for each argument - we might be run with something like "find / -type f | xargs fsvs update".
Definition at line 1514 of file url.c.
References hlp__realloc(), STOPIF, url__parm_list, url__parm_list_len, and url__parm_list_used.
Referenced by main().
int url__work | ( | struct estat *root | UNUSED, | |
int | argc, | |||
char * | argv[] | |||
) |
-.
Writes the given URLs into the WAA.
Definition at line 1321 of file url.c.
References url_t::current_rev, DEBUGP, hlp__string_from_filep(), IF_FREE, url_t::internal_number, opt__is_verbose(), parm_dump, parm_load, SFF_WHITESPACE, STOPIF, STOPIF_CODE_ERR, STOPIF_CODE_ERR_GOTO, url_t::url, url___dump(), url__allocate(), url__find_by_url_in_list(), url__insert_or_replace(), url__load_list(), url__output_list(), urllist, urllist_count, waa__create_working_copy(), waa__given_or_current_wd(), and waa__set_working_copy().
char** url__parm_list = NULL |
-.
A NULL
terminated array of url parameters.
Does get free()d
by url__close_sessions().
See -u for the specification.
Definition at line 225 of file url.c.
Referenced by au__prepare_for_added(), log__work(), url__close_sessions(), url__mark_todo(), and url__store_url_name().
int url__parm_list_len = 0 |
Definition at line 226 of file url.c.
Referenced by url__close_sessions(), and url__store_url_name().
int url__parm_list_used = 0 |
How many URLs were given as parameters.
Definition at line 227 of file url.c.
Referenced by au__prepare_for_added(), log__work(), url__close_sessions(), url__mark_todo(), url__store_url_name(), and url__to_be_handled().