Пример #1
0
    apr_array_append(apr_pool_t *p,
		      const apr_array_header_t *first,
		      const apr_array_header_t *second)
{
    apr_array_header_t *res = apr_array_copy_hdr(p, first);

    apr_array_cat(res, second);
    return res;
}
Пример #2
0
/*
  little helper function to build the file path if available
*/
static apr_status_t ap_xsendfile_get_filepath(request_rec *r, xsendfile_conf_t *conf, const char *file, /* out */ char **path) {

  const char *root = ap_xsendfile_get_orginal_path(r);
  apr_status_t rv;

  apr_array_header_t *patharr;
  const char **paths;
  int i;


#ifdef _DEBUG
  ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "xsendfile: path is %s", root);
#endif

  /* merge the array */
  if (root) {
    patharr = apr_array_make(r->pool, conf->paths->nelts + 1, sizeof(char*));
    *(const char**)(apr_array_push(patharr)) = root;
    apr_array_cat(patharr, conf->paths);
  } else {
    patharr = conf->paths;
  }
  if (patharr->nelts == 0) {
    return APR_EBADPATH;
  }
  paths = (const char**)patharr->elts;

  for (i = 0; i < patharr->nelts; ++i) {
    if ((rv = apr_filepath_merge(
      path,
      paths[i],
      file,
      APR_FILEPATH_TRUENAME | APR_FILEPATH_NOTABOVEROOT,
      r->pool
    )) == OK) {
      break;
    }
  }
  if (rv != OK) {
    *path = NULL;
  }
  return rv;
}