From 02cad904ee2254f8a0e3fc8bf6b7d5ddd6200434 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20K=C3=B6hntopp?= Date: Thu, 29 Jun 2000 14:07:10 +0000 Subject: [PATCH] ezmlm_hash() function also available for php4. --- ext/standard/basic_functions.c | 1 + ext/standard/mail.c | 31 +++++++++++++++++++++++++++++++ ext/standard/php_mail.h | 1 + 3 files changed, 33 insertions(+) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 717a776339..91ce4a2de3 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -455,6 +455,7 @@ function_entry basic_functions[] = { /* functions from mail.c */ PHP_FE(mail, NULL) + PHP_FE(ezmlm_hash, NULL) /* functions from syslog.c */ PHP_FE(openlog, NULL) diff --git a/ext/standard/mail.c b/ext/standard/mail.c index 4e71e33320..16753a7c5c 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -38,6 +38,37 @@ ZEND_GET_MODULE(odbc) #endif +/* {{{ proto int ezmlm_hash(string addr) + Calculate EZMLM list hash value. */ +PHP_FUNCTION(ezmlm_hash) +{ + pval **pstr = NULL; + char *str=NULL; + unsigned long h = 5381L; + int j, l; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &pstr) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_string_ex(pstr); + if ((*pstr)->value.str.val) { + str = (*pstr)->value.str.val; + } else { + php_error(E_WARNING, "Must give string parameter to ezmlm_hash()"); + RETURN_FALSE; + } + + l = strlen(str); + for (j=0; j