cvs: php3 /functions mail.c php3_mail.h
| From: | Kristian K�hntopp | Date: | Thu, 29 Jun 2000 12:07:47 +0000 |
| Subject: | cvs: php3 /functions mail.c php3_mail.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-540@lists.php.net to get a copy of this message | ||
kk Thu Jun 29 05:07:47 2000 EDT
Modified files:
/php3/functions mail.c php3_mail.h
Log:
To maintain EZMLM mailing lists in a MySQL database, you need a
hash value (why this is just beyond me). This function will
calculate such a hash value.
Index: php3/functions/mail.c
diff -u php3/functions/mail.c:1.61 php3/functions/mail.c:1.62
--- php3/functions/mail.c:1.61 Fri Dec 31 20:31:16 1999
+++ php3/functions/mail.c Thu Jun 29 05:07:47 2000
@@ -28,7 +28,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mail.c,v 1.61 2000/01/01 04:31:16 sas Exp $ */
+/* $Id: mail.c,v 1.62 2000/06/29 12:07:47 kk Exp $ */
#include <stdlib.h>
#include <ctype.h>
@@ -53,6 +53,7 @@
function_entry mail_functions[] = {
{"mail", php3_mail, NULL},
+ {"ezmlm_hash", php3_ezmlm_hash, NULL},
{NULL, NULL, NULL}
};
@@ -159,6 +160,37 @@
}
#endif
return 1;
+}
+
+/* {{{ proto int ezmlm_hash(string hash)
+ Calculate EZMLM list hash value */
+void php3_ezmlm_hash(INTERNAL_FUNCTION_PARAMETERS)
+{
+ pval *pstr;
+ char *str=NULL;
+ unsigned long h = 5381L;
+ int j, l;
+ TLS_VARS;
+
+ if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &pstr) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_string(pstr);
+ if (pstr->value.str.val) {
+ str = pstr->value.str.val;
+ } else {
+ php3_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(h);
}
void php3_info_mail(void)
Index: php3/functions/php3_mail.h
diff -u php3/functions/php3_mail.h:1.3 php3/functions/php3_mail.h:1.4
--- php3/functions/php3_mail.h:1.3 Fri Dec 31 20:44:09 1999
+++ php3/functions/php3_mail.h Thu Jun 29 05:07:47 2000
@@ -28,7 +28,7 @@
*/
-/* $Id: php3_mail.h,v 1.3 2000/01/01 04:44:09 sas Exp $ */
+/* $Id: php3_mail.h,v 1.4 2000/06/29 12:07:47 kk Exp $ */
#ifndef _MAIL_H
#define _MAIL_H
@@ -39,6 +39,7 @@
extern void php3_mail(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_info_mail(void);
extern int _php3_mail(char *to, char *subject, char *message, char *headers);
+extern void php3_ezmlm_hash(INTERNAL_FUNCTION_PARAMETERS);
#else
#define mail_module_ptr NULL