ra_dav.h

来自「linux subdivision ying gai ke yi le ba」· C头文件 代码 · 共 729 行 · 第 1/2 页

H
729
字号
/*
 * ra_dav.h :  private declarations for the RA/DAV module
 *
 * ====================================================================
 * Copyright (c) 2000-2004 CollabNet.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://subversion.tigris.org/license-1.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 *
 * This software consists of voluntary contributions made by many
 * individuals.  For exact contribution history, see the revision
 * history and logs, available at http://subversion.tigris.org/.
 * ====================================================================
 */



#ifndef SVN_LIBSVN_RA_DAV_H
#define SVN_LIBSVN_RA_DAV_H

#include <apr_pools.h>
#include <apr_tables.h>

#include <ne_request.h>
#include <ne_uri.h>
#include <ne_207.h>            /* for NE_ELM_207_UNUSED */
#include <ne_props.h>          /* for ne_propname */

#include "svn_types.h"
#include "svn_string.h"
#include "svn_error.h"
#include "svn_delta.h"
#include "svn_ra.h"
#include "svn_dav.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */



/* Rename these types and constants to abstract from Neon */

#define SVN_RA_DAV__XML_VALID   (0)
#define SVN_RA_DAV__XML_INVALID (-1)
#define SVN_RA_DAV__XML_DECLINE (-2)

#define SVN_RA_DAV__XML_CDATA   (1<<1)
#define SVN_RA_DAV__XML_COLLECT ((1<<2) | SVN_RA_DAV__XML_CDATA)

typedef int svn_ra_dav__xml_elmid;

/** XML element */
typedef struct {
  /** XML namespace. */
  const char *nspace;

  /** XML tag name. */
  const char *name;

  /** XML tag id to be passed to a handler. */
  svn_ra_dav__xml_elmid id;

  /** Processing flags for this namespace:tag.
   *
   * 0 (zero)                - regular element, may have children,
   * SVN_RA_DAV__XML_CDATA   - child-less element,
   * SVN_RA_DAV__XML_COLLECT - complete contents of such element must be
   *                           collected as CDATA, includes *_CDATA flag. */
  unsigned int flags;

} svn_ra_dav__xml_elm_t;


/** (Neon 0.23) Callback to validate a new child element.
 *
 * @a parent and @a child are element ids found in the array of
 * elements, @a userdata is a user baton. Returns:
 *
 * SVN_RA_DAV__XML_VALID   - this is a valid element processed by this
 *                           handler;
 * SVN_RA_DAV__XML_INVALID - this is not a valid element, parsing should
 *                           stop;
 * SVN_RA_DAV__XML_DECLINE - this handler doesn't know about this element,
 *                           someone else may handle it.
 * 
 * (See @a shim_xml_push_handler in util.c for more information.) */
typedef int svn_ra_dav__xml_validate_cb(void *userdata,
                                        svn_ra_dav__xml_elmid parent,
                                        svn_ra_dav__xml_elmid child);

/** (Neon 0.23) Callback to start parsing a new child element.
 *
 * @a userdata is a user baton. @elm is a member of elements array,
 * and @a atts is an array of name-value XML attributes.
 * See @c svn_ra_dav__xml_validate_cb for return values. 
 *
 * (See @a shim_xml_push_handler in util.c for more information.) */
typedef int svn_ra_dav__xml_startelm_cb(void *userdata,
                                        const svn_ra_dav__xml_elm_t *elm,
                                        const char **atts);

/** (Neon 0.23) Callback to finish parsing a child element.
 *
 * Callback for @c svn_ra_dav__xml_push_handler. @a userdata is a user
 * baton. @elm is a member of elements array, and @a cdata is the contents
 * of the element.
 * See @c svn_ra_dav__xml_validate_cb for return values.
 *
 * (See @a shim_xml_push_handler in util.c for more information.) */
typedef int svn_ra_dav__xml_endelm_cb(void *userdata,
                                      const svn_ra_dav__xml_elm_t *elm,
                                      const char *cdata);



typedef struct {
  apr_pool_t *pool;

  const char *url;                      /* original, unparsed session url */
  ne_uri root;                          /* parsed version of above */
  const char *repos_root;               /* URL for repository root */

  ne_session *sess;                     /* HTTP session to server */
  ne_session *sess2;
  
  const svn_ra_callbacks_t *callbacks;  /* callbacks to get auth data */
  void *callback_baton;

  svn_auth_iterstate_t *auth_iterstate; /* state of authentication retries */

  svn_boolean_t compression;            /* should we use http compression? */
  const char *uuid;                     /* repository UUID */
} svn_ra_session_t;


/* Id used with ne_set_session_private() and ne_get_session_private()
   to retrieve the userdata (which is currently the RA session baton!) */
#define SVN_RA_NE_SESSION_ID   "SVN"


#ifdef SVN_DEBUG
#define DEBUG_CR "\n"
#else
#define DEBUG_CR ""
#endif


/** plugin function prototypes */

svn_error_t *svn_ra_dav__get_latest_revnum(void *session_baton,
                                           svn_revnum_t *latest_revnum,
                                           apr_pool_t *pool);

svn_error_t *svn_ra_dav__get_dated_revision (void *session_baton,
                                             svn_revnum_t *revision,
                                             apr_time_t timestamp,
                                             apr_pool_t *pool);

svn_error_t *svn_ra_dav__change_rev_prop (void *session_baton,
                                          svn_revnum_t rev,
                                          const char *name,
                                          const svn_string_t *value,
                                          apr_pool_t *pool);

svn_error_t *svn_ra_dav__rev_proplist (void *session_baton,
                                       svn_revnum_t rev,
                                       apr_hash_t **props,
                                       apr_pool_t *pool);

svn_error_t *svn_ra_dav__rev_prop (void *session_baton,
                                   svn_revnum_t rev,
                                   const char *name,
                                   svn_string_t **value,
                                   apr_pool_t *pool);

svn_error_t * svn_ra_dav__get_commit_editor(
  void *session_baton,
  const svn_delta_editor_t **editor,
  void **edit_baton,
  const char *log_msg,
  svn_commit_callback_t callback,
  void *callback_baton,
  apr_pool_t *pool);

svn_error_t * svn_ra_dav__get_file(
  void *session_baton,
  const char *path,
  svn_revnum_t revision,
  svn_stream_t *stream,
  svn_revnum_t *fetched_rev,
  apr_hash_t **props,
  apr_pool_t *pool);

svn_error_t *svn_ra_dav__get_dir(
  void *session_baton,
  const char *path,
  svn_revnum_t revision,
  apr_hash_t **dirents,
  svn_revnum_t *fetched_rev,
  apr_hash_t **props,
  apr_pool_t *pool);

svn_error_t * svn_ra_dav__abort_commit(
 void *session_baton,
 void *edit_baton);

svn_error_t * svn_ra_dav__do_update(
  void *session_baton,
  const svn_ra_reporter_t **reporter,
  void **report_baton,
  svn_revnum_t revision_to_update_to,
  const char *update_target,
  svn_boolean_t recurse,
  const svn_delta_editor_t *wc_update,
  void *wc_update_baton,
  apr_pool_t *pool);

svn_error_t * svn_ra_dav__do_status(
  void *session_baton,
  const svn_ra_reporter_t **reporter,
  void **report_baton,
  const char *status_target,
  svn_revnum_t revision,
  svn_boolean_t recurse,
  const svn_delta_editor_t *wc_status,
  void *wc_status_baton,
  apr_pool_t *pool);

svn_error_t * svn_ra_dav__do_switch(
  void *session_baton,
  const svn_ra_reporter_t **reporter,
  void **report_baton,
  svn_revnum_t revision_to_update_to,
  const char *update_target,
  svn_boolean_t recurse,
  const char *switch_url,
  const svn_delta_editor_t *wc_update,
  void *wc_update_baton,
  apr_pool_t *pool);

svn_error_t * svn_ra_dav__do_diff(
  void *session_baton,
  const svn_ra_reporter_t **reporter,
  void **report_baton,
  svn_revnum_t revision,
  const char *diff_target,
  svn_boolean_t recurse,
  svn_boolean_t ignore_ancestry,
  const char *versus_url,
  const svn_delta_editor_t *wc_diff,
  void *wc_diff_baton,
  apr_pool_t *pool);

svn_error_t * svn_ra_dav__get_log(
  void *session_baton,
  const apr_array_header_t *paths,
  svn_revnum_t start,
  svn_revnum_t end,
  svn_boolean_t discover_changed_paths,
  svn_boolean_t strict_node_history,
  svn_log_message_receiver_t receiver,
  void *receiver_baton,
  apr_pool_t *pool);

svn_error_t *svn_ra_dav__do_check_path(
  void *session_baton,
  const char *path,
  svn_revnum_t revision,
  svn_node_kind_t *kind,
  apr_pool_t *pool);

svn_error_t *svn_ra_dav__get_file_revs (void *session_baton,
                                        const char *path,
                                        svn_revnum_t start,
                                        svn_revnum_t end,
                                        svn_ra_file_rev_handler_t handler,
                                        void *handler_baton,
                                        apr_pool_t *pool);


/*
** SVN_RA_DAV__LP_*: local properties for RA/DAV
**
** ra_dav stores properties on the client containing information needed
** to operate against the SVN server. Some of this informations is strictly
** necessary to store, and some is simply stored as a cached value.
*/

#define SVN_RA_DAV__LP_NAMESPACE SVN_PROP_WC_PREFIX "ra_dav:"

/* store the URL where Activities can be created */
/* ### should fix the name to be "activity-coll" at some point */
#define SVN_RA_DAV__LP_ACTIVITY_COLL SVN_RA_DAV__LP_NAMESPACE "activity-url"

/* store the URL of the version resource (from the DAV:checked-in property) */
#define SVN_RA_DAV__LP_VSN_URL          SVN_RA_DAV__LP_NAMESPACE "version-url"


/*
** SVN_RA_DAV__PROP_*: properties that we fetch from the server
**
** These are simply symbolic names for some standard properties that we fetch.
*/
#define SVN_RA_DAV__PROP_BASELINE_COLLECTION    "DAV:baseline-collection"
#define SVN_RA_DAV__PROP_CHECKED_IN     "DAV:checked-in"
#define SVN_RA_DAV__PROP_VCC            "DAV:version-controlled-configuration"
#define SVN_RA_DAV__PROP_VERSION_NAME   "DAV:version-name"
#define SVN_RA_DAV__PROP_CREATIONDATE   "DAV:creationdate"
#define SVN_RA_DAV__PROP_CREATOR_DISPLAYNAME "DAV:creator-displayname"
#define SVN_RA_DAV__PROP_GETCONTENTLENGTH "DAV:getcontentlength"

#define SVN_RA_DAV__PROP_BASELINE_RELPATH \
    SVN_DAV_PROP_NS_DAV "baseline-relative-path"

#define SVN_RA_DAV__PROP_MD5_CHECKSUM SVN_DAV_PROP_NS_DAV "md5-checksum"

#define SVN_RA_DAV__PROP_REPOSITORY_UUID SVN_DAV_PROP_NS_DAV "repository-uuid"


typedef struct {
  /* what is the URL for this resource */
  const char *url;

  /* is this resource a collection? (from the DAV:resourcetype element) */
  int is_collection;

  /* PROPSET: NAME -> VALUE (const char * -> const svn_string_t *) */
  apr_hash_t *propset;

  /* --- only used during response processing --- */
  /* when we see a DAV:href element, what element is the parent? */
  int href_parent;

  apr_pool_t *pool;

} svn_ra_dav_resource_t;

/* ### WARNING: which_props can only identify properties which props.c
   ### knows about. see the elem_definitions[] array. */

/* fetch a bunch of properties from the server. */
svn_error_t * svn_ra_dav__get_props(apr_hash_t **results,
                                    ne_session *sess,
                                    const char *url,
                                    int depth,
                                    const char *label,
                                    const ne_propname *which_props,
                                    apr_pool_t *pool);

/* fetch a single resource's props from the server. */
svn_error_t * svn_ra_dav__get_props_resource(svn_ra_dav_resource_t **rsrc,
                                             ne_session *sess,
                                             const char *url,
                                             const char *label,
                                             const ne_propname *which_props,
                                             apr_pool_t *pool);

/* fetch a single resource's starting props from the server. */
svn_error_t * svn_ra_dav__get_starting_props(svn_ra_dav_resource_t **rsrc,
                                             ne_session *sess,
                                             const char *url,

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?