⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 php_imap.c

📁 php-4.4.7学习linux时下载的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* {{{ proto int imap_num_recent(resource stream_id)   Gives the number of recent messages in current mailbox */PHP_FUNCTION(imap_num_recent){	zval **streamind;	pils *imap_le_struct;	if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &streamind) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);	RETURN_LONG(imap_le_struct->imap_stream->recent);}/* }}} */#if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)/* {{{ proto array imap_get_quota(resource stream_id, string qroot)	Returns the quota set to the mailbox account qroot */PHP_FUNCTION(imap_get_quota){	zval **streamind, **qroot;	pils *imap_le_struct;	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &qroot) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);	convert_to_string_ex(qroot);	array_init(return_value);	IMAPG(quota_return) = &return_value;	/* set the callback for the GET_QUOTA function */	mail_parameters(NIL, SET_QUOTA, (void *) mail_getquota);	if(!imap_getquota(imap_le_struct->imap_stream, Z_STRVAL_PP(qroot))) {		php_error_docref(NULL TSRMLS_CC, E_WARNING, "c-client imap_getquota failed");		zval_dtor(return_value);		RETURN_FALSE;	}}/* }}} *//* {{{ proto array imap_get_quotaroot(resource stream_id, string mbox)	Returns the quota set to the mailbox account mbox */PHP_FUNCTION(imap_get_quotaroot){	zval **streamind, **mbox;	pils *imap_le_struct;	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &mbox) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);	convert_to_string_ex(mbox);	array_init(return_value);	IMAPG(quota_return) = &return_value;	/* set the callback for the GET_QUOTAROOT function */	mail_parameters(NIL, SET_QUOTA, (void *) mail_getquota);	if(!imap_getquotaroot(imap_le_struct->imap_stream, Z_STRVAL_PP(mbox))) {		php_error_docref(NULL TSRMLS_CC, E_WARNING, "c-client imap_getquotaroot failed");		zval_dtor(return_value);		RETURN_FALSE;	}}/* }}} *//* {{{ proto bool imap_set_quota(resource stream_id, string qroot, int mailbox_size)   Will set the quota for qroot mailbox */PHP_FUNCTION(imap_set_quota){	zval **streamind, **qroot, **mailbox_size;	pils *imap_le_struct;	STRINGLIST	limits;	if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &streamind, &qroot, &mailbox_size) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);	convert_to_string_ex(qroot);	convert_to_long_ex(mailbox_size);	limits.text.data = "STORAGE";	limits.text.size = Z_LVAL_PP(mailbox_size);	limits.next = NIL;	RETURN_BOOL(imap_setquota(imap_le_struct->imap_stream, Z_STRVAL_PP(qroot), &limits)); }/* }}} *//* {{{ proto bool imap_setacl(resource stream_id, string mailbox, string id, string rights)	Sets the ACL for a given mailbox */PHP_FUNCTION(imap_setacl){	zval **streamind, **mailbox, **id, **rights;	pils *imap_le_struct;		if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &streamind, &mailbox, &id, &rights) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);	convert_to_string_ex(mailbox);	convert_to_string_ex(rights);	RETURN_BOOL(imap_setacl(imap_le_struct->imap_stream, Z_STRVAL_PP(mailbox), Z_STRVAL_PP(id), Z_STRVAL_PP(rights)));}/* }}} */#endif /* HAVE_IMAP2000 || HAVE_IMAP2001 *//* {{{ proto bool imap_expunge(resource stream_id)   Permanently delete all messages marked for deletion */PHP_FUNCTION(imap_expunge){	zval **streamind;	pils *imap_le_struct; 	if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &streamind) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);	mail_expunge (imap_le_struct->imap_stream);	RETURN_TRUE;}/* }}} *//* {{{ proto bool imap_close(resource stream_id [, int options])   Close an IMAP stream */PHP_FUNCTION(imap_close){	zval **options, **streamind=NULL;	pils *imap_le_struct=NULL; 	long flags = NIL;	int myargcount=ZEND_NUM_ARGS();	if (myargcount < 1 || myargcount > 2 || zend_get_parameters_ex(myargcount, &streamind, &options) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);	if (myargcount == 2) {		convert_to_long_ex(options);		flags = Z_LVAL_PP(options);		/* Do the translation from PHP's internal PHP_EXPUNGE define to c-client's CL_EXPUNGE */		if (flags & PHP_EXPUNGE) {			flags ^= PHP_EXPUNGE;			flags |= CL_EXPUNGE;		}			imap_le_struct->flags = flags;	}	zend_list_delete(Z_RESVAL_PP(streamind));	RETURN_TRUE;}/* }}} *//* {{{ proto array imap_headers(resource stream_id)   Returns headers for all messages in a mailbox */PHP_FUNCTION(imap_headers){	zval **streamind;	pils *imap_le_struct; 	unsigned long i;	char *t;	unsigned int msgno;	char tmp[MAILTMPLEN];		if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &streamind) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}		ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);	/* Initialize return array */	array_init(return_value);		for (msgno = 1; msgno <= imap_le_struct->imap_stream->nmsgs; msgno++) {		MESSAGECACHE * cache = mail_elt (imap_le_struct->imap_stream, msgno);		mail_fetchstructure(imap_le_struct->imap_stream, msgno, NIL);		tmp[0] = cache->recent ? (cache->seen ? 'R': 'N') : ' ';		tmp[1] = (cache->recent | cache->seen) ? ' ' : 'U';		tmp[2] = cache->flagged ? 'F' : ' ';		tmp[3] = cache->answered ? 'A' : ' ';		tmp[4] = cache->deleted ? 'D' : ' ';		tmp[5] = cache->draft ? 'X' : ' ';		sprintf(tmp + 6, "%4ld) ", cache->msgno);		mail_date(tmp+11, cache);		tmp[22] = ' ';		tmp[23] = '\0';		mail_fetchfrom(tmp+23, imap_le_struct->imap_stream, msgno, (long)20);		strcat(tmp, " ");		if ((i = cache->user_flags)) {			strcat(tmp, "{");			while (i) {				strcat(tmp, imap_le_struct->imap_stream->user_flags[find_rightmost_bit (&i)]);				if (i) strcat(tmp, " ");			}			strcat(tmp, "} ");		}		mail_fetchsubject(t = tmp + strlen(tmp), imap_le_struct->imap_stream, msgno, (long)25);		sprintf(t += strlen(t), " (%ld chars)", cache->rfc822_size);		add_next_index_string(return_value, tmp, 1);	}}/* }}} *//* {{{ proto string imap_body(resource stream_id, int msg_no [, int options])   Read the message body */PHP_FUNCTION(imap_body){	zval **streamind, **msgno, **flags;	pils *imap_le_struct; 	int msgindex, myargc=ZEND_NUM_ARGS();	if (myargc < 2 || myargc > 3 || zend_get_parameters_ex(myargc, &streamind, &msgno, &flags) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);		convert_to_long_ex(msgno);	if (myargc == 3) {		convert_to_long_ex(flags);	}	if ((myargc == 3) && (Z_LVAL_PP(flags) & FT_UID)) {		/* This should be cached; if it causes an extra RTT to the		   IMAP server, then that's the price we pay for making		   sure we don't crash. */		msgindex = mail_msgno(imap_le_struct->imap_stream, Z_LVAL_PP(msgno));	} else {		msgindex = Z_LVAL_PP(msgno);	}	if ((msgindex < 1) || ((unsigned) msgindex > imap_le_struct->imap_stream->nmsgs)) {		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad message number");		RETURN_FALSE;	}	RETVAL_STRING(mail_fetchtext_full (imap_le_struct->imap_stream, Z_LVAL_PP(msgno), NIL, myargc==3 ? Z_LVAL_PP(flags) : NIL), 1);}/* }}} *//* {{{ proto bool imap_mail_copy(resource stream_id, int msg_no, string mailbox [, int options])   Copy specified message to a mailbox */PHP_FUNCTION(imap_mail_copy){	zval **streamind, **seq, **folder, **options;	pils *imap_le_struct; 	int myargcount = ZEND_NUM_ARGS();	if (myargcount > 4 || myargcount < 3 || zend_get_parameters_ex(myargcount, &streamind, &seq, &folder, &options) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);	convert_to_string_ex(seq);	convert_to_string_ex(folder);	if (myargcount == 4) {		convert_to_long_ex(options);	}	if (mail_copy_full(imap_le_struct->imap_stream, Z_STRVAL_PP(seq), Z_STRVAL_PP(folder), myargcount==4 ? Z_LVAL_PP(options) : NIL)==T) {		RETURN_TRUE;	} else {		RETURN_FALSE;	}}/* }}} *//* {{{ proto bool imap_mail_move(resource stream_id, int msg_no, string mailbox [, int options])   Move specified message to a mailbox */PHP_FUNCTION(imap_mail_move){	zval **streamind, **seq, **folder, **options;	pils *imap_le_struct; 	int myargcount = ZEND_NUM_ARGS();	if (myargcount > 4 || myargcount < 3 || zend_get_parameters_ex(myargcount, &streamind, &seq, &folder, &options) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);	convert_to_string_ex(seq);	convert_to_string_ex(folder);	if (myargcount == 4) {		convert_to_long_ex(options);	}	if (mail_copy_full(imap_le_struct->imap_stream, Z_STRVAL_PP(seq), Z_STRVAL_PP(folder), myargcount == 4 ? (Z_LVAL_PP(options) | CP_MOVE) : CP_MOVE) == T) {		RETURN_TRUE;	} else {		RETURN_FALSE;	}}/* }}} *//* {{{ proto bool imap_createmailbox(resource stream_id, string mailbox)   Create a new mailbox */PHP_FUNCTION(imap_createmailbox){	zval **streamind, **folder;	pils *imap_le_struct; 	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &folder) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);	convert_to_string_ex(folder);	if (mail_create(imap_le_struct->imap_stream, Z_STRVAL_PP(folder)) == T) {		RETURN_TRUE;	} else {		RETURN_FALSE;	}}/* }}} *//* {{{ proto bool imap_renamemailbox(resource stream_id, string old_name, string new_name)   Rename a mailbox */PHP_FUNCTION(imap_renamemailbox){	zval **streamind, **old_mailbox, **new_mailbox;	pils *imap_le_struct; 	if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &streamind, &old_mailbox, &new_mailbox) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);	convert_to_string_ex(old_mailbox);	convert_to_string_ex(new_mailbox);	if (mail_rename(imap_le_struct->imap_stream, Z_STRVAL_PP(old_mailbox), Z_STRVAL_PP(new_mailbox))==T) {		RETURN_TRUE;	} else {		RETURN_FALSE;	}}/* }}} *//* {{{ proto bool imap_deletemailbox(resource stream_id, string mailbox)   Delete a mailbox */PHP_FUNCTION(imap_deletemailbox){	zval **streamind, **folder;	pils *imap_le_struct; 	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &folder) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);	convert_to_string_ex(folder);	if (mail_delete(imap_le_struct->imap_stream, Z_STRVAL_PP(folder))==T) {		RETURN_TRUE;	} else {		RETURN_FALSE;	}}/* }}} *//* {{{ proto array imap_list(resource stream_id, string ref, string pattern)   Read the list of mailboxes */PHP_FUNCTION(imap_list){	zval **streamind, **ref, **pat;	pils *imap_le_struct; 	STRINGLIST *cur=NIL;	if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &streamind, &ref, &pat) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);	convert_to_string_ex(ref);	convert_to_string_ex(pat);	/* set flag for normal, old mailbox list */	IMAPG(folderlist_style) = FLIST_ARRAY;		IMAPG(imap_folders) = IMAPG(imap_folders_tail) = NIL;	mail_list(imap_le_struct->imap_stream, Z_STRVAL_PP(ref), Z_STRVAL_PP(pat));	if (IMAPG(imap_folders) == NIL) {		RETURN_FALSE;	}	array_init(return_value);	cur=IMAPG(imap_folders);	while (cur != NIL) {		add_next_index_string(return_value, cur->LTEXT, 1);		cur=cur->next;	}	mail_free_stringlist (&IMAPG(imap_folders));	IMAPG(imap_folders) = IMAPG(imap_folders_tail) = NIL;}/* }}} *//* {{{ proto array imap_getmailboxes(resource stream_id, string ref, string pattern)   Reads the list of mailboxes and returns a full array of objects containing name, attributes, and delimiter *//* Author: CJH */PHP_FUNCTION(imap_list_full){	zval **streamind, **ref, **pat, *mboxob;	pils *imap_le_struct; 	FOBJECTLIST *cur=NIL;	char *delim=NIL;		if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &streamind, &ref, &pat) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}		ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);	convert_to_string_ex(ref);	convert_to_string_ex(pat);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -