cvs: /php3 ChangeLog /php3/functions imap.c imap.h
| From: | Rasmus Lerdorf | Date: | Sat, 24 Jul 1999 19:06:16 +0000 |
| Subject: | cvs: /php3 ChangeLog /php3/functions imap.c imap.h | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-9107@lists.php.net to get a copy of this message | ||
rasmus Sat Jul 24 15:06:16 1999 EDT
Modified files:
/php3 ChangeLog
/php3/functions imap.c imap.h
Log:
imap_search() function from Chuck
Index: php3/ChangeLog
diff -u php3/ChangeLog:1.731 php3/ChangeLog:1.732
--- php3/ChangeLog:1.731 Fri Jul 23 11:06:59 1999
+++ php3/ChangeLog Sat Jul 24 15:06:15 1999
@@ -2,6 +2,7 @@
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
??, Version 3.0.12
+- Add imap_search (Chuck Hagenbuch)
- Added locale support for Perl Compatible Regexp functions (Andrey)
- fix crash on invalid URLs in fopen wrappers (Sascha)
- Add support for gd1.6 (disables the ImageCreateFromGif and ImageGif
Index: php3/functions/imap.c
diff -u php3/functions/imap.c:1.59 php3/functions/imap.c:1.60
--- php3/functions/imap.c:1.59 Tue Jul 20 18:05:18 1999
+++ php3/functions/imap.c Sat Jul 24 15:06:16 1999
@@ -33,7 +33,7 @@
| Andrew Skalski <askalski@chek.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: imap.c,v 1.59 1999/07/20 22:05:18 musone Exp $ */
+/* $Id: imap.c,v 1.60 1999/07/24 19:06:16 rasmus Exp $ */
#define IMAP41
@@ -118,6 +118,10 @@
struct php3_imap_error_struct *next;
} ERRORLIST;
+typedef struct php3_imap_message_struct {
+ unsigned long msgid;
+ struct php3_imap_message_struct *next;
+} MESSAGELIST;
MAILSTREAM *mail_close_it (pils *imap_le_struct);
#ifdef OP_RELOGIN
@@ -188,6 +192,7 @@
{"imap_alerts", php3_imap_alerts, NULL},
{"imap_errors", php3_imap_errors, NULL},
{"imap_last_error", php3_imap_last_error, NULL},
+ {"imap_search", php3_imap_search, NULL},
{NULL, NULL, NULL}
};
@@ -213,7 +218,7 @@
} folderlist_style_t;
/*
- I beleive since this global is used ONLY within this module,
+ I believe since this global is used ONLY within this module,
and nothing will link to this module, we can use the simple
thread local storage
*/
@@ -224,10 +229,15 @@
#endif
char imap_user[80]="";
char imap_password[80]="";
+#ifdef HAVE_IMSP
+extern char imsp_user[80];
+extern char imsp_password[80];
+#endif
STRINGLIST *imap_folders=NIL;
STRINGLIST *imap_sfolders=NIL;
STRINGLIST *imap_alertstack=NIL;
ERRORLIST *imap_errorstack=NIL;
+MESSAGELIST *imap_messages=NIL;
FOBJECTLIST *imap_folder_objects=NIL;
FOBJECTLIST *imap_sfolder_objects=NIL;
folderlist_style_t folderlist_style = FLIST_ARRAY;
@@ -337,6 +347,27 @@
}
}
+/* Mail instantiate MESSAGELIST
+ * Returns: new MESSAGELIST list
+ * Author: CJH
+ */
+MESSAGELIST *mail_newmessagelist (void)
+{
+ return (MESSAGELIST *) memset(fs_get(sizeof(MESSAGELIST)),0,
+ sizeof(MESSAGELIST));
+}
+
+/* Mail garbage collect MESSAGELIST
+ * Accepts: pointer to MESSAGELIST pointer
+ * Author: CJH
+ */
+void mail_free_messagelist (MESSAGELIST **msglist)
+{
+ if (*msglist) { /* only free if exists */
+ mail_free_messagelist (&(*msglist)->next);
+ fs_give ((void **) msglist); /* return string to free storage */
+ }
+}
/* Author: CJH */
int imap_init_request (INIT_FUNC_ARGS) {
@@ -598,8 +629,6 @@
pval *options;
MAILSTREAM *imap_stream;
pils *imap_le_struct;
- list_entry new_le;
- list_entry *le;
long flags=NIL;
long cl_flags=NIL;
#ifdef OP_RELOGIN
@@ -1987,7 +2016,7 @@
}
mail_free_foblist (&imap_sfolder_objects);
efree(delim);
- folderlist_style = FLIST_ARRAY; // reset to default
+ folderlist_style = FLIST_ARRAY; /* reset to default */
}
/* }}} */
@@ -3109,12 +3138,77 @@
/* }}} */
+/* {{{ proto array imap_search(int stream_id, string criteria [, long flags])
+ Return a list of messages matching the criteria. */
+void php3_imap_search(INTERNAL_FUNCTION_PARAMETERS)
+{
+ pval *streamind, *criteria, *search_flags;
+ int ind, ind_type, args;
+ pils *imap_le_struct;
+ long flags;
+ MESSAGELIST *cur;
+
+ args = ARG_COUNT(ht);
+ if (args < 2 || args > 3 || getParameters(ht, args, &streamind, &criteria,
&search_flags) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long(streamind);
+ convert_to_string(criteria);
+
+ if (args == 2) {
+ flags = SE_FREE;
+ } else {
+ convert_to_long(search_flags);
+ flags = search_flags->value.lval;
+ }
+
+ ind = streamind->value.lval;
+ imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
+ if (!imap_le_struct || !IS_STREAM(ind_type)) {
+ php3_error(E_WARNING, "Unable to find stream pointer");
+ RETURN_FALSE;
+ }
+
+ imap_messages = NIL;
+ mail_search_full(imap_le_struct->imap_stream, NIL, mail_criteria(criteria->value.str.val),
flags);
+ if (imap_messages == NIL) {
+ RETURN_FALSE;
+ }
+
+ array_init(return_value);
+ cur = imap_messages;
+ while (cur != NIL) {
+ add_next_index_long(return_value, cur->msgid);
+ cur = cur->next;
+ }
+ mail_free_messagelist(&imap_messages);
+}
+/* }}} */
+
+
/* Interfaces to C-client */
void mm_searched (MAILSTREAM *stream,unsigned long number)
{
+ MESSAGELIST *cur = NIL;
+
+ if (imap_messages == NIL) {
+ imap_messages = mail_newmessagelist();
+ imap_messages->msgid = number;
+ imap_messages->next = NIL;
+ } else {
+ cur = imap_messages;
+ while (cur->next != NIL) {
+ cur = cur->next;
+ }
+ cur->next = mail_newmessagelist();
+ cur = cur->next;
+ cur->msgid = number;
+ cur->next = NIL;
+ }
}
@@ -3298,14 +3392,29 @@
php debugger? */
}
+/* CJH: check the service name in order to allow different IMSP
+ usernames & passwords */
void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
{
- if (*mb->user) {
- strcpy (user,mb->user);
+#ifdef HAVE_IMSP
+ if (*mb->service && strcmp(mb->service, "imsp") == 0) {
+ if (*mb->user) {
+ strcpy(user, mb->user);
+ } else {
+ strcpy(user, imsp_user);
+ }
+ strcpy (pwd,imsp_password);
} else {
- strcpy (user,imap_user);
+#endif
+ if (*mb->user) {
+ strcpy(user, mb->user);
+ } else {
+ strcpy(user, imap_user);
+ }
+ strcpy(pwd, imap_password);
+#ifdef HAVE_IMSP
}
- strcpy (pwd,imap_password);
+#endif
}
Index: php3/functions/imap.h
diff -u php3/functions/imap.h:1.11 php3/functions/imap.h:1.12
--- php3/functions/imap.h:1.11 Fri Jul 2 17:05:17 1999
+++ php3/functions/imap.h Sat Jul 24 15:06:16 1999
@@ -1,4 +1,4 @@
-/* $Id: imap.h,v 1.11 1999/07/02 21:05:17 musone Exp $ */
+/* $Id: imap.h,v 1.12 1999/07/24 19:06:16 rasmus Exp $ */
#ifndef _INCLUDED_IMAP_H
#define _INCLUDED_IMAP_H
@@ -76,6 +76,7 @@
void php3_imap_alerts(INTERNAL_FUNCTION_PARAMETERS);
void php3_imap_errors(INTERNAL_FUNCTION_PARAMETERS);
void php3_imap_last_error(INTERNAL_FUNCTION_PARAMETERS);
+void php3_imap_search(INTERNAL_FUNCTION_PARAMETERS);
#else
#define php3_imap_module_ptr NULL