Exemplo n.º 1
0
static ap_lua_vm_spec* copy_vm_spec(apr_pool_t* pool, ap_lua_vm_spec* spec) 
{
    ap_lua_vm_spec* copied_spec = apr_pcalloc(pool, sizeof(ap_lua_vm_spec));
    copied_spec->bytecode_len = spec->bytecode_len;
    copied_spec->bytecode = apr_pstrdup(pool, spec->bytecode);
    copied_spec->cb = spec->cb;
    copied_spec->cb_arg = NULL;
    copied_spec->file = apr_pstrdup(pool, spec->file);
    copied_spec->package_cpaths = apr_array_copy(pool, spec->package_cpaths);
    copied_spec->package_paths = apr_array_copy(pool, spec->package_paths);
    copied_spec->pool = pool;
    copied_spec->scope = AP_LUA_SCOPE_SERVER;
    copied_spec->codecache = spec->codecache;
    return copied_spec;
}
Exemplo n.º 2
0
MpAV *modperl_handler_array_merge(apr_pool_t *p, MpAV *base_a, MpAV *add_a)
{
    int i, j;
    modperl_handler_t **base_h, **add_h;
    MpAV *mrg_a;

    if (!add_a) {
        return base_a;
    }

    if (!base_a) {
        return add_a;
    }

    mrg_a = apr_array_copy(p, base_a);

    base_h = (modperl_handler_t **)base_a->elts;
    add_h  = (modperl_handler_t **)add_a->elts;

    for (i=0; i<base_a->nelts; i++) {
        for (j=0; j<add_a->nelts; j++) {
            if (modperl_handler_equal(base_h[i], add_h[j])) {
                MP_TRACE_d(MP_FUNC, "both base and new config contain %s",
                           add_h[j]->name);
            }
            else {
                modperl_handler_array_push(mrg_a, add_h[j]);
                MP_TRACE_d(MP_FUNC, "base does not contain %s",
                           add_h[j]->name);
            }
        }
    }

    return mrg_a;
}
Exemplo n.º 3
0
/** Create MRCP control answer */
MRCP_DECLARE(mrcp_control_descriptor_t*) mrcp_control_answer_create(mrcp_control_descriptor_t *offer, apr_pool_t *pool)
{
    mrcp_control_descriptor_t *answer = mrcp_control_descriptor_create(pool);
    if(offer) {
        *answer = *offer;
        answer->cmid_arr = apr_array_copy(pool,offer->cmid_arr);
    }
    answer->setup_type = MRCP_SETUP_TYPE_PASSIVE;
    return answer;
}
Exemplo n.º 4
0
/* Implements svn_cache__dup_func_t */
static svn_error_t *
dup_pack_manifest(void **out,
                  void *in,
                  apr_pool_t *pool)
{
  apr_array_header_t *manifest = in;

  *out = apr_array_copy(pool, manifest);
  return SVN_NO_ERROR;
}
Exemplo n.º 5
0
/** Copy MRCP control offer */
MRCP_DECLARE(mrcp_control_descriptor_t*) mrcp_control_offer_copy(const mrcp_control_descriptor_t *offer, apr_pool_t *pool)
{
	mrcp_control_descriptor_t *descriptor = mrcp_control_descriptor_create(pool);
	if(offer) {
		*descriptor = *offer;
		descriptor->cmid_arr = apr_array_copy(pool,offer->cmid_arr);
		apt_string_copy(&descriptor->ip,&offer->ip,pool);
		apt_string_copy(&descriptor->resource_name,&offer->resource_name,pool);
		apt_string_copy(&descriptor->session_id,&offer->session_id,pool);
	}
	return descriptor;
}
Exemplo n.º 6
0
apr_array_header_t *
svn_prop_array_dup(const apr_array_header_t *array, apr_pool_t *pool)
{
  int i;
  apr_array_header_t *new_array = apr_array_copy(pool, array);
  for (i = 0; i < new_array->nelts; ++i)
    {
      svn_prop_t *elt = &APR_ARRAY_IDX(new_array, i, svn_prop_t);
      svn_prop__members_dup(elt, pool);
    }
  return new_array;
}
Exemplo n.º 7
0
/** Copy array of name-value pairs */
APT_DECLARE(apt_pair_arr_t*) apt_pair_array_copy(const apt_pair_arr_t *src_arr, apr_pool_t *pool)
{
	int i;
	const apt_pair_t *src_pair;
	apt_pair_t *pair;
	apt_pair_arr_t *arr;
	if(!src_arr) {
		return NULL;
	}
	arr = apr_array_copy(pool,src_arr);
	for(i=0; i<arr->nelts; i++) {
		pair = &APR_ARRAY_IDX(arr,i,apt_pair_t);
		src_pair = &APR_ARRAY_IDX(src_arr,i,const apt_pair_t);
		apt_pair_copy(pair,src_pair,pool);
	}
	return arr;
}
Exemplo n.º 8
0
/* Array elements are assumed to be nul-terminated C strings. */
static apr_array_header_t *
deep_copy_array(apr_array_header_t *s, apr_pool_t *result_pool)
{
  int i;
  apr_array_header_t *d;

  if (!s)
    return NULL;

  d = apr_array_copy(result_pool, s);

  /* Make a deep copy of the strings in the array. */
  for (i = 0; i < s->nelts; ++i)
    {
      APR_ARRAY_IDX(d, i, const char *) =
        apr_pstrdup(result_pool, APR_ARRAY_IDX(s, i, const char *));
    }

  return d;
}
Exemplo n.º 9
0
/* Copy an array with elements that are svn_x509_name_attr_t's */
static apr_array_header_t *
deep_copy_name_attrs(apr_array_header_t *s, apr_pool_t *result_pool)
{
  int i;
  apr_array_header_t *d;

  if (!s)
    return NULL;

  d = apr_array_copy(result_pool, s);

  /* Make a deep copy of the svn_x509_name_attr_t's in the array. */
  for (i = 0; i < s->nelts; ++i)
    {
      APR_ARRAY_IDX(d, i, const svn_x509_name_attr_t *) =
        svn_x509_name_attr_dup(APR_ARRAY_IDX(s, i, svn_x509_name_attr_t *),
                               result_pool, result_pool);
    }

  return d;
}
Exemplo n.º 10
0
svn_error_t *
svn_delta_path_driver(const svn_delta_editor_t *editor,
                      void *edit_baton,
                      svn_revnum_t revision,
                      const apr_array_header_t *paths,
                      svn_delta_path_driver_cb_func_t callback_func,
                      void *callback_baton,
                      apr_pool_t *scratch_pool)
{
    apr_array_header_t *sorted;

    /* REVISION is dropped on the floor.  */

    /* Construct a copy of PATHS, then sort them in a depth-first order.  */
    sorted = apr_array_copy(scratch_pool, paths);
    qsort(sorted->elts, sorted->nelts, sorted->elt_size, svn_sort_compare_paths);

    return svn_error_trace(svn_delta_path_driver2(editor, edit_baton, sorted,
                           callback_func, callback_baton,
                           scratch_pool));
}
Exemplo n.º 11
0
svn_error_t *
svn_ra__locations_from_log(svn_ra_session_t *session,
                           apr_hash_t **locations_p,
                           const char *path,
                           svn_revnum_t peg_revision,
                           const apr_array_header_t *location_revisions,
                           apr_pool_t *pool)
{
  apr_hash_t *locations = apr_hash_make(pool);
  struct log_receiver_baton lrb = { 0 };
  apr_array_header_t *targets;
  svn_revnum_t youngest_requested, oldest_requested, youngest, oldest;
  svn_node_kind_t kind;
  const char *fs_path;
  apr_array_header_t *sorted_location_revisions;

  /* Fetch the absolute FS path associated with PATH. */
  SVN_ERR(get_fs_path(&fs_path, session, path, pool));

  /* Sanity check: verify that the peg-object exists in repos. */
  SVN_ERR(svn_ra_check_path(session, path, peg_revision, &kind, pool));
  if (kind == svn_node_none)
    return svn_error_createf(SVN_ERR_FS_NOT_FOUND, NULL,
                             _("Path '%s' doesn't exist in revision %ld"),
                             fs_path, peg_revision);

  /* Easy out: no location revisions. */
  if (! location_revisions->nelts)
    {
      *locations_p = locations;
      return SVN_NO_ERROR;
    }

  /* Figure out the youngest and oldest revs (amongst the set of
     requested revisions + the peg revision) so we can avoid
     unnecessary log parsing. */
  sorted_location_revisions = apr_array_copy(pool, location_revisions);
  svn_sort__array(sorted_location_revisions, compare_revisions);
  oldest_requested = APR_ARRAY_IDX(sorted_location_revisions, 0, svn_revnum_t);
  youngest_requested = APR_ARRAY_IDX(sorted_location_revisions,
                                     sorted_location_revisions->nelts - 1,
                                     svn_revnum_t);
  youngest = peg_revision;
  youngest = (oldest_requested > youngest) ? oldest_requested : youngest;
  youngest = (youngest_requested > youngest) ? youngest_requested : youngest;
  oldest = peg_revision;
  oldest = (oldest_requested < oldest) ? oldest_requested : oldest;
  oldest = (youngest_requested < oldest) ? youngest_requested : oldest;

  /* Populate most of our log receiver baton structure. */
  lrb.kind = kind;
  lrb.last_path = fs_path;
  lrb.location_revisions = apr_array_copy(pool, sorted_location_revisions);
  lrb.peg_revision = peg_revision;
  lrb.peg_path = NULL;
  lrb.locations = locations;
  lrb.pool = pool;

  /* Let the RA layer drive our log information handler, which will do
     the work of finding the actual locations for our resource.
     Notice that we always run on the youngest rev of the 3 inputs. */
  targets = apr_array_make(pool, 1, sizeof(const char *));
  APR_ARRAY_PUSH(targets, const char *) = path;
  SVN_ERR(svn_ra_get_log2(session, targets, youngest, oldest, 0,
                          TRUE, FALSE, FALSE,
                          apr_array_make(pool, 0, sizeof(const char *)),
                          log_receiver, &lrb, pool));

  /* If the received log information did not cover any of the
     requested revisions, use the last known path.  (This normally
     just means that FS_PATH was not modified between the requested
     revision and OLDEST.  If the file was created at some point after
     OLDEST, then lrb.last_path should be NULL.) */
  if (! lrb.peg_path)
    lrb.peg_path = lrb.last_path;
  if (lrb.last_path)
    {
      int i;
      for (i = 0; i < sorted_location_revisions->nelts; i++)
        {
          svn_revnum_t rev = APR_ARRAY_IDX(sorted_location_revisions, i,
                                           svn_revnum_t);
          if (! apr_hash_get(locations, &rev, sizeof(rev)))
            apr_hash_set(locations, apr_pmemdup(pool, &rev, sizeof(rev)),
                         sizeof(rev), apr_pstrdup(pool, lrb.last_path));
        }
    }

  /* Check that we got the peg path. */
  if (! lrb.peg_path)
    return svn_error_createf
      (APR_EGENERAL, NULL,
       _("Unable to find repository location for '%s' in revision %ld"),
       fs_path, peg_revision);

  /* Sanity check: make sure that our calculated peg path is the same
     as what we expected it to be. */
  if (strcmp(fs_path, lrb.peg_path) != 0)
    return svn_error_createf
      (SVN_ERR_CLIENT_UNRELATED_RESOURCES, NULL,
       _("'%s' in revision %ld is an unrelated object"),
       fs_path, youngest);

  *locations_p = locations;
  return SVN_NO_ERROR;
}