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

📄 liveprops.c

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
      /* only defined for VCRs (in the public space and in a BC space) */      /* ### note that a VCC (a special VCR) is defined as _PRIVATE for now */      if (resource->type == DAV_RESOURCE_TYPE_PRIVATE          && resource->info->restype == DAV_SVN_RESTYPE_VCC)        {          svn_revnum_t revnum;          serr = svn_fs_youngest_rev(&revnum, resource->info->repos->fs, p);          if (serr != NULL)            {              /* ### what to do? */              svn_error_clear(serr);              value = "###error###";              break;            }          s = dav_svn_build_uri(resource->info->repos,                                DAV_SVN_BUILD_URI_BASELINE,                                 revnum, NULL, 0 /* add_href */, p);          value = apr_psprintf(p, "<D:href>%s</D:href>",                                apr_xml_quote_string(p, s, 1));        }      else if (resource->type != DAV_RESOURCE_TYPE_REGULAR)        {          /* not defined for this resource type */          return DAV_PROP_INSERT_NOTSUPP;        }      else        {          svn_revnum_t rev_to_use =            dav_svn_get_safe_cr(resource->info->root.root,                                resource->info->repos_path, p);          s = dav_svn_build_uri(resource->info->repos,                                DAV_SVN_BUILD_URI_VERSION,                                rev_to_use, resource->info->repos_path,                                0 /* add_href */, p);          value = apr_psprintf(p, "<D:href>%s</D:href>",                                apr_xml_quote_string(p, s, 1));        }      break;    case DAV_PROPID_version_controlled_configuration:      /* only defined for VCRs */      /* ### VCRs within the BC should not have this property! */      /* ### note that a VCC (a special VCR) is defined as _PRIVATE for now */      if (resource->type != DAV_RESOURCE_TYPE_REGULAR)        return DAV_PROP_INSERT_NOTSUPP;      value = dav_svn_build_uri(resource->info->repos, DAV_SVN_BUILD_URI_VCC,                                SVN_IGNORED_REVNUM, NULL,                                 1 /* add_href */, p);      break;    case DAV_PROPID_version_name:      /* only defined for Version Resources and Baselines */      /* ### whoops. also defined for VCRs. deal with it later. */      if ((resource->type != DAV_RESOURCE_TYPE_VERSION)          && (! resource->versioned))        return DAV_PROP_INSERT_NOTSUPP;      if (resource->type == DAV_RESOURCE_TYPE_PRIVATE          && resource->info->restype == DAV_SVN_RESTYPE_VCC)        {          return DAV_PROP_INSERT_NOTSUPP;        }      if (resource->baselined)        {          /* just the revision number for baselines */          value = apr_psprintf(p, "%ld",                               resource->info->root.rev);        }      else        {          svn_revnum_t committed_rev = SVN_INVALID_REVNUM;                    /* Get the CR field out of the node's skel.  Notice that the             root object might be an ID root -or- a revision root. */          serr = svn_fs_node_created_rev(&committed_rev,                                         resource->info->root.root,                                         resource->info->repos_path, p);          if (serr != NULL)            {              /* ### what to do? */              svn_error_clear(serr);              value = "###error###";              break;            }                    /* Convert the revision into a quoted string */          s = apr_psprintf(p, "%ld", committed_rev);          value = apr_xml_quote_string(p, s, 1);        }      break;    case SVN_PROPID_baseline_relative_path:      /* only defined for VCRs */      /* ### VCRs within the BC should not have this property! */      /* ### note that a VCC (a special VCR) is defined as _PRIVATE for now */      if (resource->type != DAV_RESOURCE_TYPE_REGULAR)        return DAV_PROP_INSERT_NOTSUPP;      /* drop the leading slash, so it is relative */      s = resource->info->repos_path + 1;      value = apr_xml_quote_string(p, s, 1);      break;    case SVN_PROPID_md5_checksum:      if ((! resource->collection)          && (! resource->baselined)          && (resource->type == DAV_RESOURCE_TYPE_REGULAR              || resource->type == DAV_RESOURCE_TYPE_WORKING              || resource->type == DAV_RESOURCE_TYPE_VERSION))        {          unsigned char digest[APR_MD5_DIGESTSIZE];          serr = svn_fs_file_md5_checksum(digest,                                          resource->info->root.root,                                          resource->info->repos_path, p);          if (serr != NULL)            {              /* ### what to do? */              svn_error_clear(serr);              value = "###error###";              break;            }          value = svn_md5_digest_to_cstring(digest, p);          if (! value)            return DAV_PROP_INSERT_NOTSUPP;        }      else        return DAV_PROP_INSERT_NOTSUPP;      break;    case SVN_PROPID_repository_uuid:      serr = svn_fs_get_uuid(resource->info->repos->fs, &value, p);      if (serr != NULL)        {          /* ### what to do? */          svn_error_clear(serr);          value = "###error###";          break;        }      break;    case SVN_PROPID_deadprop_count:      {        unsigned int propcount;        apr_hash_t *proplist;                if (resource->type != DAV_RESOURCE_TYPE_REGULAR)          return DAV_PROP_INSERT_NOTSUPP;        serr = svn_fs_node_proplist(&proplist,                                    resource->info->root.root,                                    resource->info->repos_path, p);        if (serr != NULL)          {            /* ### what to do? */            svn_error_clear(serr);            value = "###error###";            break;            }                 propcount = apr_hash_count(proplist);        value = apr_psprintf(p, "%u", propcount);        break;      }          default:      /* ### what the heck was this property? */      return DAV_PROP_INSERT_NOTDEF;    }  /* assert: value != NULL */  /* get the information and global NS index for the property */  global_ns = dav_get_liveprop_info(propid, &dav_svn_liveprop_group, &info);  /* assert: info != NULL && info->name != NULL */  if (what == DAV_PROP_INSERT_NAME      || (what == DAV_PROP_INSERT_VALUE && *value == '\0')) {    s = apr_psprintf(response_pool, "<lp%d:%s/>" DEBUG_CR, global_ns,                     info->name);  }  else if (what == DAV_PROP_INSERT_VALUE) {    s = apr_psprintf(response_pool, "<lp%d:%s>%s</lp%d:%s>" DEBUG_CR,                     global_ns, info->name, value, global_ns, info->name);  }  else {    /* assert: what == DAV_PROP_INSERT_SUPPORTED */    s = apr_psprintf(response_pool,                     "<D:supported-live-property D:name=\"%s\" "                     "D:namespace=\"%s\"/>" DEBUG_CR,                     info->name, dav_svn_namespace_uris[info->ns]);  }  apr_text_append(response_pool, phdr, s);  /* we inserted whatever was asked for */  return what;}static int dav_svn_is_writable(const dav_resource *resource, int propid){  const dav_liveprop_spec *info;  (void) dav_get_liveprop_info(propid, &dav_svn_liveprop_group, &info);  return info->is_writable;}static dav_error * dav_svn_patch_validate(const dav_resource *resource,                                          const apr_xml_elem *elem,                                          int operation, void **context,                                          int *defer_to_dead){  /* NOTE: this function will not be called unless/until we have     modifiable (writable) live properties. */  return NULL;}static dav_error * dav_svn_patch_exec(const dav_resource *resource,                                      const apr_xml_elem *elem,                                      int operation, void *context,                                      dav_liveprop_rollback **rollback_ctx){  /* NOTE: this function will not be called unless/until we have     modifiable (writable) live properties. */  return NULL;}static void dav_svn_patch_commit(const dav_resource *resource,                                 int operation, void *context,                                 dav_liveprop_rollback *rollback_ctx){  /* NOTE: this function will not be called unless/until we have     modifiable (writable) live properties. */}static dav_error * dav_svn_patch_rollback(const dav_resource *resource,                                          int operation, void *context,                                          dav_liveprop_rollback *rollback_ctx){  /* NOTE: this function will not be called unless/until we have     modifiable (writable) live properties. */  return NULL;}const dav_hooks_liveprop dav_svn_hooks_liveprop = {  dav_svn_insert_prop,  dav_svn_is_writable,  dav_svn_namespace_uris,  dav_svn_patch_validate,  dav_svn_patch_exec,  dav_svn_patch_commit,  dav_svn_patch_rollback,};void dav_svn_gather_propsets(apr_array_header_t *uris){  /* ### what should we use for a URL to describe the available prop set? */  /* ### for now... nothing. we will *only* have DAV properties */#if 0    *(const char **)apr_array_push(uris) =        "<http://subversion.tigris.org/dav/propset/svn/1>";#endif}int dav_svn_find_liveprop(const dav_resource *resource,                          const char *ns_uri, const char *name,                          const dav_hooks_liveprop **hooks){  /* don't try to find any liveprops if this isn't "our" resource */  if (resource->hooks != &dav_svn_hooks_repos)    return 0;  return dav_do_find_liveprop(ns_uri, name, &dav_svn_liveprop_group, hooks);}void dav_svn_insert_all_liveprops(request_rec *r, const dav_resource *resource,                                  dav_prop_insert what, apr_text_header *phdr){    const dav_liveprop_spec *spec;    apr_pool_t *pool;    apr_pool_t *subpool;    /* don't insert any liveprops if this isn't "our" resource */    if (resource->hooks != &dav_svn_hooks_repos)        return;    if (!resource->exists) {        /* a lock-null resource */        /*        ** ### technically, we should insert empty properties. dunno offhand        ** ### what part of the spec said this, but it was essentially thus:        ** ### "the properties should be defined, but may have no value".        */        return;    }    pool = resource->info->pool;    subpool = svn_pool_create(pool);    resource->info->pool = subpool;    for (spec = dav_svn_props; spec->name != NULL; ++spec)      {        svn_pool_clear(subpool);        (void) dav_svn_insert_prop(resource, spec->propid, what, phdr);      }    resource->info->pool = pool;    svn_pool_destroy(subpool);    /* ### we know the others aren't defined as liveprops */}void dav_svn_register_uris(apr_pool_t *p){    /* register the namespace URIs */    dav_register_liveprop_group(p, &dav_svn_liveprop_group);}int dav_svn_get_last_modified_time(const char **datestring,                                   apr_time_t *timeval,                                   const dav_resource *resource,                                   enum dav_svn_time_format format,                                   apr_pool_t *pool){  svn_revnum_t committed_rev = SVN_INVALID_REVNUM;  svn_string_t *committed_date = NULL;  svn_error_t *serr;  apr_time_t timeval_tmp;  if ((datestring == NULL) && (timeval == NULL))    return 0;  if (resource->baselined && resource->type == DAV_RESOURCE_TYPE_VERSION)    {      /* A baseline URI. */      committed_rev = resource->info->root.rev;    }  else if (resource->type == DAV_RESOURCE_TYPE_REGULAR           || resource->type == DAV_RESOURCE_TYPE_WORKING           || resource->type == DAV_RESOURCE_TYPE_VERSION)    {      serr = svn_fs_node_created_rev(&committed_rev,                                     resource->info->root.root,                                     resource->info->repos_path, pool);      if (serr != NULL)        {          svn_error_clear(serr);          return 1;        }    }  else    {      /* unsupported resource kind -- has no mod-time */      return 1;    }  serr = dav_svn_get_path_revprop(&committed_date,                                  resource,                                  committed_rev,                                  SVN_PROP_REVISION_DATE,                                  pool);  if (serr)    {      svn_error_clear(serr);      return 1;    }  if (committed_date == NULL)    return 1;  /* return the ISO8601 date as an apr_time_t */  serr = svn_time_from_cstring(&timeval_tmp, committed_date->data, pool);  if (serr != NULL)    {      svn_error_clear(serr);      return 1;    }  if (timeval)    memcpy(timeval, &timeval_tmp, sizeof(*timeval));  if (! datestring)    return 0;  if (format == dav_svn_time_format_iso8601)    {      *datestring = committed_date->data;    }  else if (format == dav_svn_time_format_rfc1123)    {      apr_time_exp_t tms;      apr_status_t status;            /* convert the apr_time_t into an apr_time_exp_t */      status = apr_time_exp_gmt(&tms, timeval_tmp);      if (status != APR_SUCCESS)        return 1;                    /* stolen from dav/fs/repos.c   :-)  */      *datestring = apr_psprintf(pool, "%s, %.2d %s %d %.2d:%.2d:%.2d GMT",                                 apr_day_snames[tms.tm_wday],                                 tms.tm_mday, apr_month_snames[tms.tm_mon],                                 tms.tm_year + 1900,                                 tms.tm_hour, tms.tm_min, tms.tm_sec);          }  else /* unknown time format */    {      return 1;    }  return 0;}                                              

⌨️ 快捷键说明

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