⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 locks.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * locks.c :  entry point for locking RA functions for ra_serf * * ==================================================================== * Copyright (c) 2006 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/. * ==================================================================== */#include <apr_uri.h>#include <expat.h>#include <serf.h>#include "svn_pools.h"#include "svn_ra.h"#include "svn_dav.h"#include "svn_xml.h"#include "../libsvn_ra/ra_loader.h"#include "svn_config.h"#include "svn_delta.h"#include "svn_version.h"#include "svn_path.h"#include "svn_time.h"#include "svn_private_config.h"#include "ra_serf.h"/* * This enum represents the current state of our XML parsing for a REPORT. */typedef enum {  NONE = 0,  PROP,  LOCK_DISCOVERY,  ACTIVE_LOCK,  LOCK_TYPE,  LOCK_SCOPE,  DEPTH,  TIMEOUT,  LOCK_TOKEN,  COMMENT,} lock_state_e;typedef struct {  const char *data;  apr_size_t len;} lock_prop_info_t;typedef struct {  apr_pool_t *pool;  const char *path;  svn_lock_t *lock;  svn_boolean_t force;  svn_revnum_t revision;  svn_boolean_t read_headers;  /* Our HTTP status code and reason. */  int status_code;  const char *reason;  /* The currently collected value as we build it up */  const char *tmp;  apr_size_t tmp_len;  /* are we done? */  svn_boolean_t done;  /* Any errors. */  svn_error_t *error;} lock_info_t;static lock_prop_info_t*push_state(svn_ra_serf__xml_parser_t *parser,           lock_info_t *lock_ctx,           lock_state_e state){  svn_ra_serf__xml_push_state(parser, state);  switch (state)    {    case LOCK_TYPE:    case LOCK_SCOPE:    case DEPTH:    case TIMEOUT:    case LOCK_TOKEN:    case COMMENT:        parser->state->private = apr_pcalloc(parser->state->pool,                                             sizeof(lock_prop_info_t));        break;      default:        break;    }  return parser->state->private;}/* * Expat callback invoked on a start element tag for a PROPFIND response. */static svn_error_t *start_lock(svn_ra_serf__xml_parser_t *parser,           void *userData,           svn_ra_serf__dav_props_t name,           const char **attrs){  lock_info_t *ctx = userData;  lock_state_e state;  state = parser->state->current_state;  if (state == NONE && strcmp(name.name, "prop") == 0)    {      svn_ra_serf__xml_push_state(parser, PROP);    }  else if (state == PROP &&           strcmp(name.name, "lockdiscovery") == 0)    {      push_state(parser, ctx, LOCK_DISCOVERY);    }  else if (state == LOCK_DISCOVERY &&           strcmp(name.name, "activelock") == 0)    {      push_state(parser, ctx, ACTIVE_LOCK);    }  else if (state == ACTIVE_LOCK)    {      if (strcmp(name.name, "locktype") == 0)        {          push_state(parser, ctx, LOCK_TYPE);        }      else if (strcmp(name.name, "lockscope") == 0)        {          push_state(parser, ctx, LOCK_SCOPE);        }      else if (strcmp(name.name, "depth") == 0)        {          push_state(parser, ctx, DEPTH);        }      else if (strcmp(name.name, "timeout") == 0)        {          push_state(parser, ctx, TIMEOUT);        }      else if (strcmp(name.name, "locktoken") == 0)        {          push_state(parser, ctx, LOCK_TOKEN);        }      else if (strcmp(name.name, "owner") == 0)        {          push_state(parser, ctx, COMMENT);        }    }  else if (state == LOCK_TYPE)    {      if (strcmp(name.name, "write") == 0)        {          /* Do nothing. */        }      else        {          abort();        }    }  else if (state == LOCK_SCOPE)    {      if (strcmp(name.name, "exclusive") == 0)        {          /* Do nothing. */        }      else        {          abort();        }    }  return SVN_NO_ERROR;}/* * Expat callback invoked on an end element tag for a PROPFIND response. */static svn_error_t *end_lock(svn_ra_serf__xml_parser_t *parser,         void *userData,         svn_ra_serf__dav_props_t name){  lock_info_t *ctx = userData;  lock_state_e state;  state = parser->state->current_state;  if (state == PROP &&      strcmp(name.name, "prop") == 0)    {      svn_ra_serf__xml_pop_state(parser);    }  else if (state == LOCK_DISCOVERY &&           strcmp(name.name, "lockdiscovery") == 0)    {      svn_ra_serf__xml_pop_state(parser);    }  else if (state == ACTIVE_LOCK &&           strcmp(name.name, "activelock") == 0)    {      svn_ra_serf__xml_pop_state(parser);    }  else if (state == LOCK_TYPE &&           strcmp(name.name, "locktype") == 0)    {      svn_ra_serf__xml_pop_state(parser);    }  else if (state == LOCK_SCOPE &&           strcmp(name.name, "lockscope") == 0)    {      svn_ra_serf__xml_pop_state(parser);    }  else if (state == DEPTH &&           strcmp(name.name, "depth") == 0)    {      svn_ra_serf__xml_pop_state(parser);    }  else if (state == TIMEOUT &&           strcmp(name.name, "timeout") == 0)    {      lock_prop_info_t *info = parser->state->private;      if (strcmp(info->data, "Infinite") == 0)        {          ctx->lock->expiration_date = 0;        }      else        {          SVN_ERR(svn_time_from_cstring(&ctx->lock->creation_date,                                        info->data, ctx->pool));        }      svn_ra_serf__xml_pop_state(parser);    }  else if (state == LOCK_TOKEN &&           strcmp(name.name, "locktoken") == 0)    {      lock_prop_info_t *info = parser->state->private;      if (!ctx->lock->token && info->len)        {          apr_collapse_spaces((char*)info->data, info->data);          ctx->lock->token = apr_pstrndup(ctx->pool, info->data, info->len);        }      /* We don't actually need the lock token. */      svn_ra_serf__xml_pop_state(parser);    }  else if (state == COMMENT &&           strcmp(name.name, "owner") == 0)    {      lock_prop_info_t *info = parser->state->private;      if (info->len)        {          ctx->lock->comment = apr_pstrndup(ctx->pool, info->data, info->len);        }      svn_ra_serf__xml_pop_state(parser);    }  return SVN_NO_ERROR;}static svn_error_t *cdata_lock(svn_ra_serf__xml_parser_t *parser,           void *userData,           const char *data,           apr_size_t len){  lock_info_t *lock_ctx = userData;  lock_state_e state;  lock_prop_info_t *info;  state = parser->state->current_state;  info = parser->state->private;  switch (state)    {    case LOCK_TYPE:    case LOCK_SCOPE:    case DEPTH:    case TIMEOUT:    case LOCK_TOKEN:    case COMMENT:        svn_ra_serf__expand_string(&info->data, &info->len,                                   data, len, parser->state->pool);        break;      default:        break;    }  return SVN_NO_ERROR;}static const svn_ra_serf__dav_props_t lock_props[] ={  { "DAV:", "lockdiscovery" },  { NULL }};static apr_status_tset_lock_headers(serf_bucket_t *headers,                 void *baton,                 apr_pool_t *pool){  lock_info_t *lock_ctx = baton;  if (lock_ctx->force == TRUE)    {      serf_bucket_headers_set(headers, SVN_DAV_OPTIONS_HEADER,                              SVN_DAV_OPTION_LOCK_STEAL);    }  if (SVN_IS_VALID_REVNUM(lock_ctx->revision))    {      serf_bucket_headers_set(headers, SVN_DAV_VERSION_NAME_HEADER,                              apr_ltoa(pool, lock_ctx->revision));    }  return APR_SUCCESS;}static apr_status_thandle_lock(serf_request_t *request,            serf_bucket_t *response,            void *handler_baton,            apr_pool_t *pool){  svn_ra_serf__xml_parser_t *xml_ctx = handler_baton;  lock_info_t *ctx = xml_ctx->user_data;  apr_status_t status;  if (ctx->read_headers == FALSE)    {      serf_bucket_t *headers;      const char *val;      serf_status_line sl;      apr_status_t rv;      rv = serf_bucket_response_status(response, &sl);      ctx->status_code = sl.code;      ctx->reason = sl.reason;

⌨️ 快捷键说明

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