CVS update: php3/functions
| From: | musone | Date: | Fri, 11 Sep 1998 20:09:03 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-982@lists.php.net to get a copy of this message | ||
Date: Friday September 11, 1998 @ 16:09
Author: musone
Update of /repository/php3/functions
In directory asf:/u2/tmp/cvs-serv13387/functions
Modified Files:
imap.c imap.h
Log Message:
added undocumented beta fetch_overview function.
fixed imap_header & header_info from crashing when a header line
is > 1024 characters.
Added patch by Jaime Bozza for rfc822_parse_adr to return an
array of objects instead of a single object.
fixed corresponding documentation.
Index: php3/functions/imap.c
diff -c php3/functions/imap.c:1.35 php3/functions/imap.c:1.36
*** php3/functions/imap.c:1.35 Fri Sep 4 15:03:41 1998
--- php3/functions/imap.c Fri Sep 11 16:09:02 1998
***************
*** 31,37 ****
| Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
! /* $Id: imap.c,v 1.35 1998/09/04 19:03:41 rasmus Exp $ */
#define IMAP41
--- 31,37 ----
| Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
! /* $Id: imap.c,v 1.36 1998/09/11 20:09:02 musone Exp $ */
#define IMAP41
***************
*** 155,160 ****
--- 155,161 ----
{"imap_rename", php3_imap_renamemailbox, NULL},
{"imap_status", php3_imap_status, NULL},
{"imap_bodystruct", php3_imap_bodystruct, NULL},
+ {"imap_fetch_overview", php3_imap_fetch_overview, NULL},
{NULL, NULL, NULL}
};
***************
*** 1049,1057 ****
MESSAGECACHE * cache;
char *mystring;
char dummy[2000];
! char fulladdress[MAILTMPLEN];
ENVELOPE *en;
! ADDRESS *addresstmp;
int myargc;
myargc=ARG_COUNT(ht);
if (myargc<2 || myargc>5 ||
getParameters(ht,myargc,&streamind,&msgno,&fromlength,&subjectlength,&defaulthost)==FAILURE)
{
--- 1050,1058 ----
MESSAGECACHE * cache;
char *mystring;
char dummy[2000];
! char fulladdress[MAILTMPLEN],tempaddress[MAILTMPLEN];
ENVELOPE *en;
! ADDRESS *addresstmp,*addresstmp2;
int myargc;
myargc=ARG_COUNT(ht);
if (myargc<2 || myargc>5 ||
getParameters(ht,myargc,&streamind,&msgno,&fromlength,&subjectlength,&defaulthost)==FAILURE)
{
***************
*** 1096,1105 ****
if(en->to)
{
! addresstmp=en->to;
! fulladdress[0]=0x00;
! rfc822_write_address(fulladdress,addresstmp);
! if(fulladdress) add_property_string( return_value, "toaddress", fulladdress, 1);
array_init( &to );
do {
object_init( &tovals);
--- 1097,1124 ----
if(en->to)
{
! int ok=1;
! addresstmp=en->to;
! fulladdress[0]=0x00;
!
! while(ok && addresstmp) /* while length < 1000 and we are not at the end of the list
*/
! {
! addresstmp2=addresstmp->next; /* save the pointer to the next address */
! addresstmp->next=NULL; /* make this address the only one now. */
! tempaddress[0]=0x00; /* reset tempaddress buffer */
! rfc822_write_address(tempaddress,addresstmp); /* ok, write the address into tempaddress
string */
! if((strlen(tempaddress) + strlen(fulladdress)) < 1000) /* is the new address + total
address < 1000 */
! { /* yes */
! strcat(fulladdress,","); /* put in a comma */
! strcat(fulladdress,tempaddress); /* put in the new address */
! }
! else /* no */
! ok=0; /* stop looping */
! addresstmp=addresstmp2; /* reset the pointer to the next address first! */
! }
!
! if(fulladdress) add_property_string( return_value, "toaddress", fulladdress, 1);
! addresstmp=en->to;
array_init( &to );
do {
object_init( &tovals);
***************
*** 1114,1123 ****
if(en->from)
{
! addresstmp=en->from;
! fulladdress[0]=0x00;
! rfc822_write_address(fulladdress,addresstmp);
if(fulladdress) add_property_string( return_value, "fromaddress", fulladdress, 1);
array_init( &from );
do {
object_init( &fromvals);
--- 1133,1160 ----
if(en->from)
{
! int ok=1;
! addresstmp=en->from;
! fulladdress[0]=0x00;
!
! while(ok && addresstmp) /* while length < 1000 and we are not at the end of the list
*/
! {
! addresstmp2=addresstmp->next; /* save the pointer to the next address */
! addresstmp->next=NULL; /* make this address the only one now. */
! tempaddress[0]=0x00; /* reset tempaddress buffer */
! rfc822_write_address(tempaddress,addresstmp); /* ok, write the address into tempaddress
string */
! if((strlen(tempaddress) + strlen(fulladdress)) < 1000) /* is the new address + total
address < 1000 */
! { /* yes */
! strcat(fulladdress,","); /* put in a comma */
! strcat(fulladdress,tempaddress); /* put in the new address */
! }
! else /* no */
! ok=0; /* stop looping */
! addresstmp=addresstmp2; /* reset the pointer to the next address first! */
! }
!
if(fulladdress) add_property_string( return_value, "fromaddress", fulladdress, 1);
+ addresstmp=en->from;
array_init( &from );
do {
object_init( &fromvals);
***************
*** 1132,1141 ****
if(en->cc)
{
! addresstmp=en->cc;
! fulladdress[0]=0x00;
! rfc822_write_address(fulladdress,addresstmp);
if(fulladdress) add_property_string( return_value, "ccaddress", fulladdress, 1);
array_init( &cc );
do {
object_init( &ccvals);
--- 1169,1196 ----
if(en->cc)
{
! int ok=1;
! addresstmp=en->cc;
! fulladdress[0]=0x00;
!
! while(ok && addresstmp) /* while length < 1000 and we are not at the end of the list
*/
! {
! addresstmp2=addresstmp->next; /* save the pointer to the next address */
! addresstmp->next=NULL; /* make this address the only one now. */
! tempaddress[0]=0x00; /* reset tempaddress buffer */
! rfc822_write_address(tempaddress,addresstmp); /* ok, write the address into tempaddress
string */
! if((strlen(tempaddress) + strlen(fulladdress)) < 1000) /* is the new address + total
address < 1000 */
! { /* yes */
! strcat(fulladdress,","); /* put in a comma */
! strcat(fulladdress,tempaddress); /* put in the new address */
! }
! else /* no */
! ok=0; /* stop looping */
! addresstmp=addresstmp2; /* reset the pointer to the next address first! */
! }
!
if(fulladdress) add_property_string( return_value, "ccaddress", fulladdress, 1);
+ addresstmp=en->cc;
array_init( &cc );
do {
object_init( &ccvals);
***************
*** 1150,1159 ****
if(en->bcc)
{
! addresstmp=en->bcc;
! fulladdress[0]=0x00;
! rfc822_write_address(fulladdress,addresstmp);
if(fulladdress) add_property_string( return_value, "bccaddress", fulladdress, 1);
array_init( &bcc );
do {
object_init( &bccvals);
--- 1205,1231 ----
if(en->bcc)
{
! int ok=1;
! addresstmp=en->bcc;
! fulladdress[0]=0x00;
! while(ok && addresstmp) /* while length < 1000 and we are not at the end of the list
*/
! {
! addresstmp2=addresstmp->next; /* save the pointer to the next address */
! addresstmp->next=NULL; /* make this address the only one now. */
! tempaddress[0]=0x00; /* reset tempaddress buffer */
! rfc822_write_address(tempaddress,addresstmp); /* ok, write the address into tempaddress
string */
! if((strlen(tempaddress) + strlen(fulladdress)) < 1000) /* is the new address + total
address < 1000 */
! { /* yes */
! strcat(fulladdress,","); /* put in a comma */
! strcat(fulladdress,tempaddress); /* put in the new address */
! }
! else /* no */
! ok=0; /* stop looping */
! addresstmp=addresstmp2; /* reset the pointer to the next address first! */
! }
!
if(fulladdress) add_property_string( return_value, "bccaddress", fulladdress, 1);
+ addresstmp=en->bcc;
array_init( &bcc );
do {
object_init( &bccvals);
***************
*** 1168,1177 ****
if(en->reply_to)
{
! addresstmp=en->reply_to;
! fulladdress[0]=0x00;
! rfc822_write_address(fulladdress,addresstmp);
if(fulladdress) add_property_string( return_value, "reply_toaddress", fulladdress,
1);
array_init( &reply_to );
do {
object_init( &reply_tovals);
--- 1240,1266 ----
if(en->reply_to)
{
! int ok=1;
! addresstmp=en->reply_to;
! fulladdress[0]=0x00;
! while(ok && addresstmp) /* while length < 1000 and we are not at the end of the list
*/
! {
! addresstmp2=addresstmp->next; /* save the pointer to the next address */
! addresstmp->next=NULL; /* make this address the only one now. */
! tempaddress[0]=0x00; /* reset tempaddress buffer */
! rfc822_write_address(tempaddress,addresstmp); /* ok, write the address into tempaddress
string */
! if((strlen(tempaddress) + strlen(fulladdress)) < 1000) /* is the new address + total
address < 1000 */
! { /* yes */
! strcat(fulladdress,","); /* put in a comma */
! strcat(fulladdress,tempaddress); /* put in the new address */
! }
! else /* no */
! ok=0; /* stop looping */
! addresstmp=addresstmp2; /* reset the pointer to the next address first! */
! }
!
if(fulladdress) add_property_string( return_value, "reply_toaddress", fulladdress,
1);
+ addresstmp=en->reply_to;
array_init( &reply_to );
do {
object_init( &reply_tovals);
***************
*** 1186,1195 ****
if(en->sender)
{
! addresstmp=en->sender;
! fulladdress[0]=0x00;
! rfc822_write_address(fulladdress,addresstmp);
if(fulladdress) add_property_string( return_value, "senderaddress", fulladdress,
1);
array_init( &sender );
do {
object_init( &sendervals);
--- 1275,1301 ----
if(en->sender)
{
! int ok=1;
! addresstmp=en->sender;
! fulladdress[0]=0x00;
! while(ok && addresstmp) /* while length < 1000 and we are not at the end of the list
*/
! {
! addresstmp2=addresstmp->next; /* save the pointer to the next address */
! addresstmp->next=NULL; /* make this address the only one now. */
! tempaddress[0]=0x00; /* reset tempaddress buffer */
! rfc822_write_address(tempaddress,addresstmp); /* ok, write the address into tempaddress
string */
! if((strlen(tempaddress) + strlen(fulladdress)) < 1000) /* is the new address + total
address < 1000 */
! { /* yes */
! strcat(fulladdress,","); /* put in a comma */
! strcat(fulladdress,tempaddress); /* put in the new address */
! }
! else /* no */
! ok=0; /* stop looping */
! addresstmp=addresstmp2; /* reset the pointer to the next address first! */
! }
!
if(fulladdress) add_property_string( return_value, "senderaddress", fulladdress,
1);
+ addresstmp=en->sender;
array_init( &sender );
do {
object_init( &sendervals);
***************
*** 1204,1213 ****
if(en->return_path)
{
! addresstmp=en->return_path;
! fulladdress[0]=0x00;
! rfc822_write_address(fulladdress,addresstmp);
if(fulladdress) add_property_string( return_value, "return_pathaddress",
fulladdress, 1);
array_init( &return_path );
do {
object_init( &return_pathvals);
--- 1310,1336 ----
if(en->return_path)
{
! int ok=1;
! addresstmp=en->return_path;
! fulladdress[0]=0x00;
! while(ok && addresstmp) /* while length < 1000 and we are not at the end of the list
*/
! {
! addresstmp2=addresstmp->next; /* save the pointer to the next address */
! addresstmp->next=NULL; /* make this address the only one now. */
! tempaddress[0]=0x00; /* reset tempaddress buffer */
! rfc822_write_address(tempaddress,addresstmp); /* ok, write the address into tempaddress
string */
! if((strlen(tempaddress) + strlen(fulladdress)) < 1000) /* is the new address + total
address < 1000 */
! { /* yes */
! strcat(fulladdress,","); /* put in a comma */
! strcat(fulladdress,tempaddress); /* put in the new address */
! }
! else /* no */
! ok=0; /* stop looping */
! addresstmp=addresstmp2; /* reset the pointer to the next address first! */
! }
!
if(fulladdress) add_property_string( return_value, "return_pathaddress",
fulladdress, 1);
+ addresstmp=en->return_path;
array_init( &return_path );
do {
object_init( &return_pathvals);
***************
*** 1638,1645 ****
void php3_imap_rfc822_parse_adrlist(INTERNAL_FUNCTION_PARAMETERS)
{
! pval *string,*defaulthost;
! ENVELOPE *env;
int argc;
env=mail_newenvelope();
--- 1761,1769 ----
void php3_imap_rfc822_parse_adrlist(INTERNAL_FUNCTION_PARAMETERS)
{
! pval *string,*defaulthost,tovals;
! ADDRESS *addresstmp;
! ENVELOPE *env;
int argc;
env=mail_newenvelope();
***************
*** 1650,1664 ****
convert_to_string(string);
convert_to_string(defaulthost);
rfc822_parse_adrlist(&env->to,string->value.str.val,defaulthost->value.str.val);
! if(object_init(return_value) == FAILURE) {
! RETURN_FALSE;
}
! if(env->to->mailbox)
add_property_string(return_value,"mailbox",env->to->mailbox,1);
! if(env->to->host) add_property_string(return_value,"host",env->to->host,1);
! if(env->to->personal)
add_property_string(return_value,"personal",env->to->personal,1);
}
void php3_imap_setflag_full(INTERNAL_FUNCTION_PARAMETERS)
{
pval *streamind;
--- 1774,1797 ----
convert_to_string(string);
convert_to_string(defaulthost);
rfc822_parse_adrlist(&env->to,string->value.str.val,defaulthost->value.str.val);
! if(array_init(return_value) == FAILURE) {
! RETURN_FALSE;
}
! addresstmp=env->to;
! if(addresstmp) do {
! object_init(&tovals);
! if(addresstmp->mailbox)
add_property_string(&tovals,"mailbox",addresstmp->mailbox,1);
! if(addresstmp->host)
add_property_string(&tovals,"host",addresstmp->host,1);
! if(addresstmp->personal)
add_property_string(&tovals,"personal",addresstmp->personal,1);
! if(addresstmp->adl) add_property_string(&tovals,"adl",addresstmp->adl,1);
! add_next_index_object(return_value, tovals);
! } while (addresstmp = addresstmp->next);
}
+
+
+
void php3_imap_setflag_full(INTERNAL_FUNCTION_PARAMETERS)
{
pval *streamind;
***************
*** 1970,1975 ****
--- 2103,2163 ----
}
add_assoc_object( return_value, "parameters", parametres );
}
+
+
+ void php3_imap_fetch_overview(INTERNAL_FUNCTION_PARAMETERS)
+ {
+ pval *streamind, *sequence;
+ int ind, ind_type;
+ pils *imap_le_struct;
+ pval myoverview;
+ char address[MAILTMPLEN];
+ int myargc=ARG_COUNT(ht);
+ if (myargc != 2 || getParameters(ht,myargc,&streamind,&sequence) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long(streamind);
+ convert_to_string(sequence);
+
+ ind = streamind->value.lval;
+ imap_le_struct = (pils *)php3_list_find(ind, &ind_type);
+
+ if (!imap_le_struct || ind_type != le_imap) {
+ php3_error(E_WARNING, "Unable to find stream pointer");
+ RETURN_FALSE;
+ }
+ array_init(return_value);
+ if (imap_le_struct->imap_stream->dtb &&
!(imap_le_struct->imap_stream->dtb->overview) &&
+ mail_uid_sequence (imap_le_struct->imap_stream,(char *)sequence)) {
+ MESSAGECACHE *elt;
+ ENVELOPE *env;
+ unsigned long i;
+ for (i = 1; i <= imap_le_struct->imap_stream->nmsgs; i++)
+ if (((elt = mail_elt (imap_le_struct->imap_stream,i))->sequence) &&
+ (env = mail_fetch_structure (imap_le_struct->imap_stream,i,NIL,NIL))) {
+ object_init(&myoverview);
+ add_property_string(&myoverview,"subject",env->subject,1);
+ rfc822_write_address(address,env->from);
+ add_property_string(&myoverview,"from",address,1);
+ add_property_string(&myoverview,"date",env->date,1);
+ add_property_string(&myoverview,"message_id",env->message_id,1);
+ add_property_string(&myoverview,"references",env->references,1);
+ add_property_long(&myoverview,"size",elt->rfc822_size);
+
add_property_long(&myoverview,"uid",mail_uid(imap_le_struct->imap_stream,i));
+ add_property_long(&myoverview,"msgno",i);
+ add_property_long(&myoverview,"recent",elt->recent);
+ add_property_long(&myoverview,"flagged",elt->flagged);
+ add_property_long(&myoverview,"answered",elt->answered);
+ add_property_long(&myoverview,"deleted",elt->deleted);
+ add_property_long(&myoverview,"seen",elt->seen);
+ add_next_index_object(return_value,myoverview);
+ }
+ }
+ }
+
+
+
/* Interfaces to C-client */
Index: php3/functions/imap.h
diff -c php3/functions/imap.h:1.6 php3/functions/imap.h:1.7
*** php3/functions/imap.h:1.6 Fri Sep 4 00:28:32 1998
--- php3/functions/imap.h Fri Sep 11 16:09:03 1998
***************
*** 64,69 ****
--- 64,70 ----
void php3_imap_fetchtext_full(INTERNAL_FUNCTION_PARAMETERS);
void php3_imap_status(INTERNAL_FUNCTION_PARAMETERS);
void php3_imap_bodystruct(INTERNAL_FUNCTION_PARAMETERS);
+ void php3_imap_fetch_overview(INTERNAL_FUNCTION_PARAMETERS);
#else
#define php3_imap_module_ptr NULL
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net