/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2008 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Alan Knowles <alan@akbkhome.com> |
| Wez Furlong <wez@omniti.com> |
| Scott MacVicar <scottmac@php.net> |
| Luca Furini <lfurini@cs.unibo.it> |
| Jerome Renard <jerome.renard_at_gmail.com> |
| Develar <develar_at_gmail.com> |
+----------------------------------------------------------------------+
*/
/* $Id: svn.c 338841 2016-03-29 04:40:47Z alan_k $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_svn.h"
#include "apr_version.h"
#include "svn_pools.h"
#include "svn_sorts.h"
#include "svn_config.h"
#include "svn_auth.h"
#include "svn_path.h"
#include "svn_fs.h"
#include "svn_repos.h"
#include "svn_utf.h"
#include "svn_time.h"
#include "svn_props.h"
#include "svn_version.h"
ZEND_DECLARE_MODULE_GLOBALS(svn)
/* custom property for ignoring SSL cert verification errors */
#define PHP_SVN_AUTH_PARAM_IGNORE_SSL_VERIFY_ERRORS "php:svn:auth:ignore-ssl-verify-errors"
#define PHP_SVN_INIT_CLIENT() \
do { \
if (init_svn_client(TSRMLS_C)) RETURN_FALSE; \
} while (0)
static void php_svn_get_version(char *buf, int buflen);
/* True global resources - no need for thread safety here */
struct php_svn_repos {
long rsrc_id;
apr_pool_t *pool;
svn_repos_t *repos;
};
struct php_svn_fs {
struct php_svn_repos *repos;
svn_fs_t *fs;
};
struct php_svn_fs_root {
struct php_svn_repos *repos;
svn_fs_root_t *root;
};
struct php_svn_repos_fs_txn {
struct php_svn_repos *repos;
svn_fs_txn_t *txn;
};
struct php_svn_log_receiver_baton {
zval *result;
svn_boolean_t omit_messages;
};
/* class entry constants */
static zend_class_entry *ce_Svn;
/* resource constants */
static int le_svn_repos;
static int le_svn_fs;
static int le_svn_fs_root;
static int le_svn_repos_fs_txn;
static ZEND_RSRC_DTOR_FUNC(php_svn_repos_dtor)
{
struct php_svn_repos *r = rsrc->ptr;
/* If root pool doesn't exist, then this resource's pool was already destroyed */
if (SVN_G(pool)) {
svn_pool_destroy(r->pool);
}
efree(r);
}
static ZEND_RSRC_DTOR_FUNC(php_svn_fs_dtor)
{
struct php_svn_fs *r = rsrc->ptr;
zend_list_delete(r->repos->rsrc_id);
efree(r);
}
static ZEND_RSRC_DTOR_FUNC(php_svn_fs_root_dtor)
{
struct php_svn_fs_root *r = rsrc->ptr;
zend_list_delete(r->repos->rsrc_id);
efree(r);
}
static ZEND_RSRC_DTOR_FUNC(php_svn_repos_fs_txn_dtor)
{
struct php_svn_repos_fs_txn *r = rsrc->ptr;
zend_list_delete(r->repos->rsrc_id);
efree(r);
}
#define SVN_STATIC_ME(name) ZEND_FENTRY(name, ZEND_FN(svn_ ## name), NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
/** Fixme = this list needs padding out... */
static zend_function_entry svn_methods[] = {
SVN_STATIC_ME(checkout)
SVN_STATIC_ME(cat)
SVN_STATIC_ME(ls)
SVN_STATIC_ME(log)
SVN_STATIC_ME(auth_set_parameter)
SVN_STATIC_ME(auth_get_parameter)
SVN_STATIC_ME(client_version)
SVN_STATIC_ME(config_ensure)
SVN_STATIC_ME(diff)
SVN_STATIC_ME(cleanup)
SVN_STATIC_ME(revert)
SVN_STATIC_ME(resolved)
SVN_STATIC_ME(commit)
SVN_STATIC_ME(lock)
SVN_STATIC_ME(unlock)
SVN_STATIC_ME(add)
SVN_STATIC_ME(status)
SVN_STATIC_ME(update)
#if defined(PHP_SVN_SUPPORT_DEPTH)
SVN_STATIC_ME(update2)
#endif
SVN_STATIC_ME(import)
SVN_STATIC_ME(info)
SVN_STATIC_ME(export)
SVN_STATIC_ME(copy)
SVN_STATIC_ME(switch)
SVN_STATIC_ME(blame)
SVN_STATIC_ME(delete)
SVN_STATIC_ME(mkdir)
SVN_STATIC_ME(move)
SVN_STATIC_ME(proplist)
SVN_STATIC_ME(propget)
SVN_STATIC_ME(propset)
SVN_STATIC_ME(prop_delete)
SVN_STATIC_ME(revprop_get)
SVN_STATIC_ME(revprop_set)
SVN_STATIC_ME(revprop_delete)
SVN_STATIC_ME(repos_create)
SVN_STATIC_ME(repos_recover)
SVN_STATIC_ME(repos_hotcopy)
SVN_STATIC_ME(repos_open)
SVN_STATIC_ME(repos_fs)
SVN_STATIC_ME(repos_fs_begin_txn_for_commit)
SVN_STATIC_ME(repos_fs_commit_txn)
{NULL, NULL, NULL}
};
/* {{{ svn_functions[] */
zend_function_entry svn_functions[] = {
PHP_FE(svn_checkout, NULL)
PHP_FE(svn_cat, NULL)
PHP_FE(svn_ls, NULL)
PHP_FE(svn_log, NULL)
PHP_FE(svn_auth_set_parameter, NULL)
PHP_FE(svn_auth_get_parameter, NULL)
PHP_FE(svn_client_version, NULL)
PHP_FE(svn_config_ensure, NULL)
PHP_FE(svn_diff, NULL)
PHP_FE(svn_cleanup, NULL)
PHP_FE(svn_revert, NULL)
PHP_FE(svn_resolved, NULL)
PHP_FE(svn_commit, NULL)
PHP_FE(svn_lock, NULL)
PHP_FE(svn_unlock, NULL)
PHP_FE(svn_add, NULL)
PHP_FE(svn_status, NULL)
PHP_FE(svn_update, NULL)
#if defined(PHP_SVN_SUPPORT_DEPTH)
PHP_FE(svn_update2, NULL)
#endif
PHP_FE(svn_import, NULL)
PHP_FE(svn_info, NULL)
PHP_FE(svn_export, NULL)
PHP_FE(svn_copy, NULL)
PHP_FE(svn_switch, NULL)
PHP_FE(svn_blame, NULL)
PHP_FE(svn_delete, NULL)
PHP_FE(svn_mkdir, NULL)
PHP_FE(svn_move, NULL)
PHP_FE(svn_proplist, NULL)
PHP_FE(svn_propget, NULL)
PHP_FE(svn_propset, NULL)
PHP_FE(svn_prop_delete, NULL)
PHP_FE(svn_revprop_get, NULL)
PHP_FE(svn_revprop_set, NULL)
PHP_FE(svn_revprop_delete, NULL)
PHP_FE(svn_repos_create, NULL)
PHP_FE(svn_repos_recover, NULL)
PHP_FE(svn_repos_hotcopy, NULL)
PHP_FE(svn_repos_open, NULL)
PHP_FE(svn_repos_fs, NULL)
PHP_FE(svn_repos_fs_begin_txn_for_commit, NULL)
PHP_FE(svn_repos_fs_commit_txn, NULL)
PHP_FE(svn_fs_revision_root, NULL)
PHP_FE(svn_fs_check_path, NULL)
PHP_FE(svn_fs_revision_prop, NULL)
PHP_FE(svn_fs_dir_entries, NULL)
PHP_FE(svn_fs_node_created_rev, NULL)
PHP_FE(svn_fs_youngest_rev, NULL)
PHP_FE(svn_fs_file_contents, NULL)
PHP_FE(svn_fs_file_length, NULL)
PHP_FE(svn_fs_txn_root, NULL)
PHP_FE(svn_fs_make_file, NULL)
PHP_FE(svn_fs_make_dir, NULL)
PHP_FE(svn_fs_apply_text, NULL)
PHP_FE(svn_fs_copy, NULL)
PHP_FE(svn_fs_delete, NULL)
PHP_FE(svn_fs_begin_txn2, NULL)
PHP_FE(svn_fs_is_dir, NULL)
PHP_FE(svn_fs_is_file, NULL)
PHP_FE(svn_fs_node_prop, NULL)
PHP_FE(svn_fs_change_node_prop, NULL)
PHP_FE(svn_fs_contents_changed, NULL)
PHP_FE(svn_fs_props_changed, NULL)
PHP_FE(svn_fs_abort_txn, NULL)
PHP_FE(svn_fs_open_txn, NULL)
PHP_FE(svn_fs_txn_prop, NULL)
{NULL, NULL, NULL}
};
/* }}} */
/* {{{ svn_module_entry */
zend_module_entry svn_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
"svn",
svn_functions,
PHP_MINIT(svn),
NULL,
NULL,
PHP_RSHUTDOWN(svn),
PHP_MINFO(svn),
#if ZEND_MODULE_API_NO >= 20010901
PHP_SVN_VERSION,
#endif
STANDARD_MODULE_PROPERTIES
};
/* }}} */
#ifdef COMPILE_DL_SVN
ZEND_GET_MODULE(svn)
#endif
/* {{{ php_svn_get_revision_kind */
static enum svn_opt_revision_kind php_svn_get_revision_kind(svn_opt_revision_t revision)
{
switch(revision.value.number) {
case svn_opt_revision_unspecified:
/* through */
case SVN_REVISION_HEAD:
return svn_opt_revision_head;
case SVN_REVISION_BASE:
return svn_opt_revision_base;
case SVN_REVISION_COMMITTED:
return svn_opt_revision_committed;
case SVN_REVISION_PREV:
return svn_opt_revision_previous;
defau