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

📄 php_notes.c

📁 php-4.4.7学习linux时下载的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
		to		cc		bcc		from		date		status (blank if delivered, otherwise contains failure reason)		priority H: High N: Normal L: Low		receipt 1: Yes 0: No		subject*/PHP_FUNCTION(notes_header_info){	int argc;	pval *argv[3];	pval **server;	pval **mail_box;	pval **msg_number;    STATUS      error = NOERROR;    char        szMailFilePath[MAXPATH+1];    HANDLE      hMessageFile;    HANDLE      hMessageList = NULLHANDLE, hMessage;    DARRAY     *MessageList;    WORD        MessageCount;    char        Originator[MAXRECIPIENTNAME+1];    WORD        OriginatorLength;    char        String[MAXSPRINTF+1];    WORD        StringLength;    TIMEDATE    Time;    BOOL        NonDeliveryReport;	char		error_string[200];	argc = ARG_COUNT(ht);	if (getParametersArray(ht, argc, argv) == FAILURE){		WRONG_PARAM_COUNT;	}	if (zend_get_parameters_ex(3, &server, &mail_box, &msg_number)==FAILURE) {		RETURN_FALSE;	}	convert_to_string_ex(server);	convert_to_string_ex(mail_box);	convert_to_long_ex(msg_number);	error = NotesInitExtended( argc, (char **) argv );	if( error ){		OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string));		php_error(E_WARNING,"Unable to initialize Lotus Notes: %s", error_string);		RETURN_FALSE;	}    OSPathNetConstruct( NULL,               /* port name  */                        Z_STRVAL_PP(server),                           Z_STRVAL_PP(mail_box),                        szMailFilePath);    /* Open the message file. */    if (error = MailOpenMessageFile(szMailFilePath, &hMessageFile)){		OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string));        php_error(E_WARNING,"Error: unable to open '%s': %s", szMailFilePath, error_string);		RETURN_FALSE;    }    /* Create message list of messages in the file - just 64K */    if (error = MailCreateMessageList(hMessageFile,                         &hMessageList, &MessageList, &MessageCount)){		OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string));        php_error(E_WARNING,"Unable to create message list: %s", error_string);		if (hMessageFile != NULLHANDLE){			MailCloseMessageFile(hMessageFile);		}		RETURN_FALSE;    }    /* Print out each of the outbound messages. */	object_init(return_value);    if (error = MailOpenMessage (MessageList, (WORD)Z_LVAL_PP(msg_number), &hMessage)){		OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string));        php_error(E_WARNING,"Unable to open message number %d: %s", (WORD)Z_LVAL_PP(msg_number), error_string);		if (hMessageList != NULLHANDLE){			OSUnlockObject(hMessageList);			OSMemFree(hMessageList);		}		if (hMessageFile != NULLHANDLE){			MailCloseMessageFile(hMessageFile);		}		RETURN_FALSE;    }    /* Get the originator's name/address. */    if (error = MailGetMessageOriginator(MessageList, (WORD)Z_LVAL_PP(msg_number),             Originator, sizeof(Originator), &OriginatorLength)){		OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string));        php_error(E_WARNING,"Unable to get message originator: %s", error_string);		if (hMessageList != NULLHANDLE){			OSUnlockObject(hMessageList);			OSMemFree(hMessageList);		}		if (hMessageFile != NULLHANDLE){			MailCloseMessageFile(hMessageFile);		}		RETURN_FALSE;    }	add_property_string(return_value,"originator",Originator, 1);    /* SendTo */    MailGetMessageItem (hMessage, MAIL_SENDTO_ITEM_NUM, String,                                     MAXSPRINTF, &StringLength);	add_property_string(return_value,"to",String, 1);    /* PostedDate */    MailGetMessageItemTimeDate(hMessage, MAIL_POSTEDDATE_ITEM_NUM, &Time);    ConvertTIMEDATEToText(NULL, NULL, &Time, String,                                 sizeof(String), &StringLength);	add_property_string(return_value,"date",String, 1);    /* BCC */    MailGetMessageItem (hMessage, MAIL_BLINDCOPYTO_ITEM_NUM, String,                                     MAXSPRINTF, &StringLength);   	add_property_string(return_value,"bcc", String, 1);    /* CopyTo */    MailGetMessageItem (hMessage, MAIL_COPYTO_ITEM_NUM, String,                                     MAXSPRINTF, &StringLength);   	add_property_string(return_value,"cc", String, 1);    /* From */    MailGetMessageItem (hMessage, MAIL_FROM_ITEM_NUM, String,                                     MAXSPRINTF, &StringLength);	add_property_string(return_value,"from",String, 1);    /* Subject */    MailGetMessageItem (hMessage, MAIL_SUBJECT_ITEM_NUM, String,                                     MAXSPRINTF, &StringLength);	add_property_string(return_value,"subject",String, 1);    /* Priority H: High N: Normal L: Low*/    MailGetMessageItem (hMessage, MAIL_DELIVERYPRIORITY_ITEM_NUM, String,                                     MAXSPRINTF, &StringLength);	add_property_string(return_value,"priority",String, 1);    /* Return Receipt 1: Yes 0: No*/    MailGetMessageItem (hMessage, MAIL_RETURNRECEIPT_ITEM_NUM, String,                                     MAXSPRINTF, &StringLength);	add_property_string(return_value,"receipt",String, 1);	NonDeliveryReport = MailIsNonDeliveryReport(hMessage);    if (NonDeliveryReport)    {        MailGetMessageItem(hMessage, MAIL_FAILUREREASON_ITEM_NUM,                        String, sizeof(String), &StringLength);		add_property_string(return_value,"status",String, 1);    }	else{		add_property_string(return_value,"status","", 1);	}    MailCloseMessage (hMessage);    /* Free the message list and close the message file */    if (hMessageList != NULLHANDLE){        OSUnlockObject(hMessageList);        OSMemFree(hMessageList);    }    if (hMessageFile != NULLHANDLE){        MailCloseMessageFile(hMessageFile);	}}/* }}} */STATUS near pascal GetUniqueFileName(char *Drive, char *Ext,                                        char *FileName){    int     file;    WORD    Num;    char    Name[17];    char    cwd[MAXPATH];    char   *Dir;            /* Increment through numbered file names until a non-existent one found. */   getcwd(cwd, MAXPATH);   Dir = (char *)&cwd;                    for (Num = 0; Num <= 32767; Num++)    {        _itoa(Num, Name, 10);        _makepath(FileName, Drive, Dir, Name, Ext);        if ((file = open(FileName, O_BINARY | O_RDONLY)) == -1)            return(NOERROR);        close(file);    }    FileName[0] = '\0';    return(ERR_READMAIL_NOUNIQUE);}/* {{{ proto array notes_body(string server, string mailbox, int msg_number)   Opens the message msg_number in the specified mailbox on the specified server (leave server blank for local) and returns an array of body text lines */PHP_FUNCTION(notes_body){	int argc;	pval *argv[3];	pval **server;	pval **mail_box;	pval **msg_number;    STATUS      error = NOERROR;    char        szMailFilePath[MAXPATH+1];    HANDLE      hMessageFile;    HANDLE      hMessageList = NULLHANDLE, hMessage;    DARRAY     *MessageList;    WORD        MessageCount;    char        String[MAXSPRINTF+1];    DWORD       BodyFileSize;    char        BodyFileName[MAXPATH_OLE];    FILE       *BodyFile;	char		error_string[200];	argc = ARG_COUNT(ht);	if (getParametersArray(ht, argc, argv) == FAILURE){		WRONG_PARAM_COUNT;	}	if (zend_get_parameters_ex(3, &server, &mail_box, &msg_number)==FAILURE) {		RETURN_FALSE;	}	convert_to_string_ex(server);	convert_to_string_ex(mail_box);	convert_to_long_ex(msg_number);	error = NotesInitExtended( argc, (char **) argv );	if( error ){		OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string));		php_error(E_WARNING,"Unable to initialize Lotus Notes: %s", error_string);		RETURN_FALSE;	}    OSPathNetConstruct( NULL,               /* port name  */                        Z_STRVAL_PP(server),                           Z_STRVAL_PP(mail_box),                        szMailFilePath);    /* Open the message file. */    if (error = MailOpenMessageFile(szMailFilePath, &hMessageFile)){		OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string));        php_error(E_WARNING,"Error: unable to open '%s': %s.", szMailFilePath, error_string);		RETURN_FALSE;    }    /* Create message list of messages in the file - just 64K */    if (error = MailCreateMessageList(hMessageFile,                         &hMessageList, &MessageList, &MessageCount)){		OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string));        php_error(E_WARNING,"Unable to create message list: %s", error_string);		if (hMessageFile != NULLHANDLE){			MailCloseMessageFile(hMessageFile);		}		RETURN_FALSE;    }    if (error = MailOpenMessage (MessageList, (WORD)Z_LVAL_PP(msg_number), &hMessage)){		OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string));        php_error(E_WARNING,"Unable to open message number %d: %s", (WORD)Z_LVAL_PP(msg_number), error_string);		if (hMessageList != NULLHANDLE){			OSUnlockObject(hMessageList);			OSMemFree(hMessageList);		}		if (hMessageFile != NULLHANDLE){			MailCloseMessageFile(hMessageFile);		}		RETURN_FALSE;    }    /* Body */    if (error = GetUniqueFileName("", "TMP", BodyFileName)){		OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string));		php_error(E_WARNING,"Enable to create temporary file name: %s", error_string);		if (hMessageList != NULLHANDLE){			OSUnlockObject(hMessageList);			OSMemFree(hMessageList);		}		if (hMessageFile != NULLHANDLE){			MailCloseMessageFile(hMessageFile);		}		MailCloseMessage (hMessage);		RETURN_FALSE;    }	/* Using MailGetBodyComposite instead of MailGetBody because it's not limited to 64k */	   if (error = MailGetMessageBodyText(hMessage,                                NULL,     /* Use standard Body item */                                "\r\n",    /* Newline-terminate */                                80,        /* 80 chars per line */                                TRUE,     /* Convert TABs */                                BodyFileName,                                &BodyFileSize)){        unlink(BodyFileName);		OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string));		php_error(E_WARNING,"Unable to get Message body into temporary file: %s", error_string);		if (hMessageList != NULLHANDLE){			OSUnlockObject(hMessageList);			OSMemFree(hMessageList);		}		if (hMessageFile != NULLHANDLE){			MailCloseMessageFile(hMessageFile);		}		MailCloseMessage (hMessage);		RETURN_FALSE;    }    /* Print each line of body text to the screen. */    if (!(BodyFile = fopen(BodyFileName, "r"))){        unlink(BodyFileName);		OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string));		php_error(E_WARNING,"Unable to open temporary file: %s", error_string);		if (hMessageList != NULLHANDLE){			OSUnlockObject(hMessageList);			OSMemFree(hMessageList);		}		if (hMessageFile != NULLHANDLE){			MailCloseMessageFile(hMessageFile);		}		MailCloseMessage (hMessage);		RETURN_FALSE;    }	array_init(return_value);	/* this should probably return the body in one string, but I don't know how */    while (fgets(String, READMAIL_BODY_LINELEN, BodyFile)){        add_next_index_string( return_value, String, 1);    }    fclose(BodyFile);    unlink(BodyFileName);    MailCloseMessage (hMessage);    /* Free the message list and close the message file */    if (hMessageList != NULLHANDLE){        OSUnlockObject(hMessageList);        OSMemFree(hMessageList);    }    if (hMessageFile != NULLHANDLE){        MailCloseMessageFile(hMessageFile);	}}/* }}} *//* {{{ proto bool notes_find_note(string database_name, string name [, string type])   Returns a note id found in database_name *//*Specify the name of the note. Leaving type blankwill default to all, otherwise specify:			FORM		VIEW		FILTER		FIELD*/PHP_FUNCTION(notes_find_note){	int argc;	pval *argv[3];	pval **db;	pval **name;	pval **type;    STATUS      error = NOERROR;	DBHANDLE db_handle;	NOTEID note_id;	char error_string[200];	argc = ARG_COUNT(ht);	if (getParametersArray(ht, argc, argv) == FAILURE){		WRONG_PARAM_COUNT;	}	if (zend_get_parameters_ex(3, &db, &name, &type)==FAILURE) {		RETURN_FALSE;	}	convert_to_string_ex(db);	convert_to_string_ex(name);	convert_to_string_ex(type);	error = NotesInitExtended( argc, (char **) argv );	if( error ){		OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string));		php_error(E_WARNING,"Unable to initialize Lotus Notes: %s", error_string);		RETURN_FALSE;

⌨️ 快捷键说明

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