url.c File Reference

urls action, and functions for URLs. More...

#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"
Include dependency graph for url.c:

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.
int url__must_write_defs = 0
 Whether the URL list in FSVS_CONF must be written.

Detailed Description

urls action, and functions for URLs.

Definition in file url.c.


Define Documentation

#define HAVE_NAME   (1)

Definition at line 345 of file url.c.

Referenced by url__insert_or_replace(), and url__parse().

#define HAVE_PRIO   (2)

Definition at line 346 of file url.c.

Referenced by url__insert_or_replace(), and url__parse().

#define HAVE_READONLY   (16)

Definition at line 349 of file url.c.

Referenced by url__insert_or_replace(), and url__parse().

#define HAVE_TARGET   (8)

Definition at line 348 of file url.c.

Referenced by url__insert_or_replace(), and url__parse().

#define HAVE_URL   (4)

Definition at line 347 of file url.c.

Referenced by url__insert_or_replace(), and url__parse().


Function Documentation

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 669 of file url.c.

Referenced by url___set_internal_nums().

Here is the caller graph for this function:

int url___dump ( char *  format  ) 

Dumps the URLs to STDOUT .

Definition at line 1235 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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 687 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().

Here is the call graph for this function:

Here is the caller graph for this function:

int url__allocate ( int  reserve_space  ) 

-.

Allocate additional space for the given number of URLs.

Definition at line 753 of file url.c.

References hlp__calloc(), hlp__realloc(), STOPIF, urllist, and urllist_count.

Referenced by co__work(), url__load_list(), and url__work().

Here is the call graph for this function:

Here is the caller graph for this function:

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 1658 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().

Here is the caller graph for this function:

int url__close_session ( struct url_t cur  ) 

-.

Closes given RA session and frees associated memory.

Definition at line 1185 of file url.c.

References BUG_ON, DEBUGP, url_t::pool, url_t::session, and url_t::url.

Referenced by exp__work(), and url__close_sessions().

Here is the caller graph for this function:

int url__close_sessions ( void   ) 

-.

Closes all RA sessions.

Definition at line 1205 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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 1227 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().

Here is the caller graph for this function:

int url__find ( char *  url,
struct url_t **  output 
)

-.

Looks for an URL matching url, and returns its address.

Definition at line 1410 of file url.c.

References url_t::url, url_t::urllen, urllist, and urllist_count.

Referenced by df__do_diff(), and rev__install_file().

Here is the caller graph for this function:

int url__find_by_intnum ( int  intnum,
struct url_t **  storage 
)

-.

Returns a struct url_t matching the given internal number.

Definition at line 314 of file url.c.

References DEBUGP, urllist, and urllist_count.

Referenced by ops__load_1entry(), and url__load_list().

Here is the caller graph for this function:

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 245 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().

Here is the caller graph for this function:

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 307 of file url.c.

References url__find_by_url_in_list(), urllist, and urllist_count.

Referenced by url__insert_or_replace().

Here is the call graph for this function:

Here is the caller graph for this function:

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 280 of file url.c.

References DEBUGP.

Referenced by url__find_by_url(), and url__work().

Here is the caller graph for this function:

int url__full_url ( struct estat sts,
char **  url 
)

-.

Returns the full URL for this entry.

Definition at line 1397 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().

Here is the call graph for this function:

Here is the caller graph for this function:

int url__indir_sorter ( const void *  a,
const void *  b 
)

-.

For use in qsort().

Definition at line 779 of file url.c.

References url__sorter().

Referenced by url__load_list().

Here is the call graph for this function:

Here is the caller graph for this function:

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 580 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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 1700 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

We read two sources; the one in FSVS_CONF normally holds the URL, the target revision, the priority, the name, the internal number, and the readonly flag.

The current revision is read from FSVS_WAA.

See also:
Files used by fsvs.

Definition at line 804 of file url.c.

References url_t::current_rev, DEBUGP, hlp__alloc(), hlp__string_from_filep(), url_t::internal_number, STOPIF, STOPIF_CODE_ERR, url__allocate(), url__find_by_intnum(), url__indir_sorter(), url__insert_or_replace(), url__must_write_defs, urllist, urllist_count, waa__open_byext(), WAA__READ, WAA__URL_REVS, 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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 950 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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 1575 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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).

Note:
The session is then registered at the existing part, so all accesses must include this relative part!

If the URL is ok, a 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 1072 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().

Here is the call graph for this function:

Here is the caller graph for this function:

int url__other_full_url ( struct estat sts,
struct url_t url,
char **  output 
)

-.

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 1355 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().

Here is the call graph for this function:

Here is the caller graph for this function:

int url__output_list ( void   ) 

-.

Writes the URL list back.

The data is written in two different locations.

The internal number was chosen as combining key, because the URL might include strange characters, and there might not be a name.

Todo:
is 1024 bytes always enough? Maybe there's an RFC. Make that dynamically - look how much we'll need.

Todo:
: writev

Definition at line 975 of file url.c.

References BUG_ON, 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(), url__must_write_defs, urllist, urllist_count, waa__close(), waa__open_byext(), WAA__URL_REVS, WAA__URLLIST_EXT, and WAA__WRITE.

Referenced by ci__work(), co__work(), sync__work(), up__work(), and url__work().

Here is the call graph for this function:

Here is the caller graph for this function:

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 362 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, url__must_write_defs, and url_t::urllen.

Referenced by exp__work(), and url__insert_or_replace().

Here is the call graph for this function:

Here is the caller graph for this function:

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 1629 of file url.c.

References hlp__realloc(), STOPIF, url__parm_list, url__parm_list_len, and url__parm_list_used.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

int url__work ( struct estat *root  UNUSED,
int  argc,
char *  argv[] 
)

Variable Documentation

Whether the URL list in FSVS_CONF must be written.

Definition at line 236 of file url.c.

Referenced by cb__remove_url(), url__load_list(), url__output_list(), url__parse(), and url__work().

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 232 of file url.c.

Referenced by au__prepare_for_added(), log__work(), url__close_sessions(), url__mark_todo(), and url__store_url_name().

Definition at line 233 of file url.c.

Referenced by url__close_sessions(), and url__store_url_name().

How many URLs were given as parameters.

Definition at line 234 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().


Generated for fsvs by  doxygen 1.6.1