cvs: php4 /ext/vpopmail php_vpopmail.c
| From: | Boian Bonev | Date: | Thu, 24 May 2001 03:31:08 +0000 |
| Subject: | cvs: php4 /ext/vpopmail php_vpopmail.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-5979@lists.php.net to get a copy of this message | ||
bbonev Wed May 23 20:31:08 2001 EDT
Modified files:
/php4/ext/vpopmail php_vpopmail.c
Log:
cosmetic fixes; added 3 of the 7 valias functions
Index: php4/ext/vpopmail/php_vpopmail.c
diff -u php4/ext/vpopmail/php_vpopmail.c:1.8 php4/ext/vpopmail/php_vpopmail.c:1.9
--- php4/ext/vpopmail/php_vpopmail.c:1.8 Thu Feb 8 15:31:00 2001
+++ php4/ext/vpopmail/php_vpopmail.c Wed May 23 20:31:08 2001
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_vpopmail.c,v 1.8 2001/02/08 23:31:00 bbonev Exp $ */
+/* $Id: php_vpopmail.c,v 1.9 2001/05/24 03:31:08 bbonev Exp $ */
/* TODO: move to config.m4 when support for old versions is ready or just
* don't support rather old vpopmail. current version must bail out if
@@ -34,8 +34,6 @@
#if HAVE_VPOPMAIL
-#include "vpopmail.h"
-
#include "ext/standard/exec.h"
#include "ext/standard/info.h"
#include "ext/standard/php_string.h"
@@ -47,9 +45,12 @@
#undef VERSION
#undef PACKAGE
#include "vpopmail_config.h"
-#undef PACKAGE
#include "vpopmail.h"
+#if HAVE_VPOPMAIL_VAUTH
+#include "vauth.h"
+#endif
+
/* vpopmail does not export this, argh! */
#define MAX_BUFF 500
@@ -70,6 +71,12 @@
PHP_FE(vpopmail_passwd, NULL)
PHP_FE(vpopmail_set_user_quota, NULL)
PHP_FE(vpopmail_auth_user, NULL)
+ /* alias management */
+#if VALIAS
+ PHP_FE(vpopmail_alias_add, NULL)
+ PHP_FE(vpopmail_alias_del, NULL)
+ PHP_FE(vpopmail_alias_del_domain, NULL)
+#endif
/* error handling */
PHP_FE(vpopmail_error, NULL)
{NULL, NULL, NULL}
@@ -147,6 +154,11 @@
php_info_print_table_row(2, "vpopmail vadddomain", VPOPMAIL_BIN_DIR VPOPMAIL_ADDD);
php_info_print_table_row(2, "vpopmail vdeldomain", VPOPMAIL_BIN_DIR VPOPMAIL_DELD);
php_info_print_table_row(2, "vpopmail vaddaliasdomain", VPOPMAIL_BIN_DIR VPOPMAIL_ADAD);
+#if VALIAS
+ php_info_print_table_row(2, "vpopmail valias support", "Enabled");
+#else
+ php_info_print_table_row(2, "vpopmail valias support", "Not supported by
vpopmail");
+#endif
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
@@ -191,8 +203,7 @@
if (retval == VA_SUCCESS) {
RETURN_TRUE;
- }
- else {
+ } else {
php_error(E_WARNING, "vpopmail error: %s", verror(retval));
RETURN_FALSE;
}
@@ -220,8 +231,7 @@
if (retval == VA_SUCCESS) {
RETURN_TRUE;
- }
- else {
+ } else {
php_error(E_WARNING, "vpopmail error: %s", verror(retval));
RETURN_FALSE;
}
@@ -564,8 +574,7 @@
if (retval == VA_SUCCESS) {
RETURN_TRUE;
- }
- else {
+ } else {
php_error(E_WARNING, "vpopmail error: %s", verror(retval));
RETURN_FALSE;
}
@@ -597,8 +606,7 @@
if (retval == VA_SUCCESS) {
RETURN_TRUE;
- }
- else {
+ } else {
php_error(E_WARNING, "vpopmail error: %s", verror(retval));
RETURN_FALSE;
}
@@ -641,8 +649,7 @@
if (retval == VA_SUCCESS) {
RETURN_TRUE;
- }
- else {
+ } else {
php_error(E_WARNING, "vpopmail error: %s", verror(retval));
RETURN_FALSE;
}
@@ -677,8 +684,7 @@
if (retval == VA_SUCCESS) {
RETURN_TRUE;
- }
- else {
+ } else {
php_error(E_WARNING, "vpopmail error: %s", verror(retval));
RETURN_FALSE;
}
@@ -693,11 +699,12 @@
zval **domain;
zval **password;
zval **apop;
- struct passwd *retval;
+ /* indeed we do not care of contents; newer vpopmail versions use struct vpasswd instead passwd */
+ void *retval;
int argc=ZEND_NUM_ARGS();
if (argc < 3 || argc > 4
- || zend_get_parameters_ex(ZEND_NUM_ARGS(), &user, &domain, &password, &apop) ==
FAILURE)
+ || zend_get_parameters_ex(argc, &user, &domain, &password, &apop) == FAILURE)
WRONG_PARAM_COUNT;
if (argc > 3)
@@ -712,9 +719,9 @@
VPOPMAILG(vpopmail_errno) = 0;
retval = vauth_user(Z_STRVAL_PP(user),
- Z_STRVAL_PP(domain),
- Z_STRVAL_PP(password),
- (argc>3)?Z_STRVAL_PP(apop):"");
+ Z_STRVAL_PP(domain),
+ Z_STRVAL_PP(password),
+ (argc>3)?Z_STRVAL_PP(apop):"");
/*
* we do not set vpopmail_errno here - it is considered auth_user cannot fail; insted it does not
auth
@@ -723,15 +730,125 @@
if (retval == NULL) {
RETURN_FALSE;
+ } else {
+ RETURN_TRUE;
}
- else {
+}
+/* }}} */
+
+
+#if VALIAS
+
+/*
+ * Alias management functions
+ */
+
+
+/* {{{ proto bool vpopmail_alias_add(string user, string domain, string alias)
+ insert a virtual alias */
+PHP_FUNCTION(vpopmail_alias_add)
+{
+ zval **user;
+ zval **domain;
+ zval **alias;
+ int retval;
+
+ if (ZEND_NUM_ARGS() != 3
+ || zend_get_parameters_ex(ZEND_NUM_ARGS(), &user, &domain, &alias) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+
+ convert_to_string_ex(user);
+ convert_to_string_ex(domain);
+ convert_to_string_ex(alias);
+
+ VPOPMAILLS_FETCH();
+ VPOPMAILG(vpopmail_open) = 1;
+
+ retval = valias_insert(Z_STRVAL_PP(user),
+ Z_STRVAL_PP(domain),
+ Z_STRVAL_PP(alias));
+
+ VPOPMAILG(vpopmail_errno)=retval;
+
+ if (retval == VA_SUCCESS) {
RETURN_TRUE;
+ } else {
+ php_error(E_WARNING, "vpopmail error: %s", verror(retval));
+ RETURN_FALSE;
}
}
/* }}} */
+/* {{{ proto bool vpopmail_alias_del(string user, string domain)
+ deletes all virtual aliases of a user */
+PHP_FUNCTION(vpopmail_alias_del)
+{
+ zval **user;
+ zval **domain;
+ int retval;
+
+ if (ZEND_NUM_ARGS() != 2
+ || zend_get_parameters_ex(ZEND_NUM_ARGS(), &user, &domain) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+
+ convert_to_string_ex(user);
+ convert_to_string_ex(domain);
+
+ VPOPMAILLS_FETCH();
+ VPOPMAILG(vpopmail_open) = 1;
+
+ retval = valias_delete(Z_STRVAL_PP(user), Z_STRVAL_PP(domain));
+
+ VPOPMAILG(vpopmail_errno)=retval;
+
+ if (retval == VA_SUCCESS) {
+ RETURN_TRUE;
+ } else {
+ php_error(E_WARNING, "vpopmail error: %s", verror(retval));
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
+/* {{{ proto bool vpopmail_alias_del_domain(string domain)
+ deletes all virtual aliases of a domain */
+PHP_FUNCTION(vpopmail_alias_del_domain)
+{
+ zval **domain;
+ int retval;
+
+ if (ZEND_NUM_ARGS() != 1
+ || zend_get_parameters_ex(ZEND_NUM_ARGS(), &domain) == FAILURE)
+ WRONG_PARAM_COUNT;
+
+
+ convert_to_string_ex(domain);
+
+ VPOPMAILLS_FETCH();
+ VPOPMAILG(vpopmail_open) = 1;
+
+ retval = valias_delete_domain(Z_STRVAL_PP(domain));
+
+ VPOPMAILG(vpopmail_errno)=retval;
+
+ if (retval == VA_SUCCESS) {
+ RETURN_TRUE;
+ } else {
+ php_error(E_WARNING, "vpopmail error: %s", verror(retval));
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+#endif
+
+/*
+ * Error handling helper
+ */
+
/* {{{ proto string vpopmail_error(void)
- Attempt to validate a username/domain/password. Returns true/false */
+ Get text message for last vpopmail error. Returns string */
PHP_FUNCTION(vpopmail_error)
{
if (ZEND_NUM_ARGS() != 0)