Browse Source

ezmlm_hash() function also available for php4.

PHP-4.0.5
Kristian Köhntopp 26 years ago
parent
commit
02cad904ee
  1. 1
      ext/standard/basic_functions.c
  2. 31
      ext/standard/mail.c
  3. 1
      ext/standard/php_mail.h

1
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)

31
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<l; j++) {
h = (h + (h<<5)) ^ (unsigned long) (unsigned char) tolower(str[j]);
}
h = (h%53);
RETURN_LONG((int) h);
}
/* {{{ proto int mail(string to, string subject, string message [, string additional_headers])
Send an email message */
PHP_FUNCTION(mail)

1
ext/standard/php_mail.h

@ -36,6 +36,7 @@
#if HAVE_SENDMAIL
PHP_FUNCTION(mail);
PHP_FUNCTION(ezmlm_hash);
PHP_MINFO_FUNCTION(mail);
extern int php_mail(char *to, char *subject, char *message, char *headers);

Loading…
Cancel
Save