📄 php_notes.c
字号:
/* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2007 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/2_01.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Brad Atkins <brad@youreshop.com> | +----------------------------------------------------------------------+*/ /* $Id: php_notes.c,v 1.15.8.3.4.2 2007/01/01 09:46:45 sebastian Exp $ */#ifdef COMPILE_DL_NOTES#define HAVE_NOTES 1#endif#ifdef HAVE_CONFIG_H#include "config.h"#endif#include "php.h"#include "php_globals.h"#include "php_notes.h"#include "ext/standard/info.h"#ifdef PHP_WIN32#include <global.h>#else#include <notes_global.h>#endif#include <nsfdb.h>#include <nsfdata.h>#include <osmisc.h>#include <miscerr.h>#include <nif.h>#include <nsfnote.h>#include <editods.h>#include <osmem.h>#include <stdnames.h>#include <nsfsearc.h>#include <colorid.h>#include <names.h>#include <stdnames.h>#include <nsferr.h>/* notes_unread */#include <idtable.h>#include <kfm.h>/* notes_header_info, notes_body */#include <malloc.h>#include <io.h>#include <direct.h>#include <fcntl.h>#include <globerr.h>#ifdef PHP_WIN32#include <mail.h>#else#include <notes_mail.h>#endif#include <mailserv.h>#include <nsf.h>#include <osfile.h> /* OSPathNetConstruct */#include <osenv.h> /* OSGetEnvironmentString *//* notes_nav_create */#include <vmods.h>/* notes_search */#include <ft.h>#include <textlist.h>/* notes_list */#define STRING_LENGTH 256function_entry notes_functions[] = { PHP_FE(notes_create_db, NULL) PHP_FE(notes_drop_db, NULL) PHP_FE(notes_version, NULL) PHP_FE(notes_create_note, NULL) PHP_FE(notes_unread, NULL) PHP_FE(notes_mark_read, NULL) PHP_FE(notes_mark_unread, NULL) PHP_FE(notes_header_info, NULL) PHP_FE(notes_body, NULL) PHP_FE(notes_find_note, NULL) PHP_FE(notes_nav_create, NULL) PHP_FE(notes_search, NULL) PHP_FE(notes_copy_db, NULL) PHP_FE(notes_list_msgs, NULL) {NULL, NULL, NULL}};zend_module_entry notes_module_entry = { STANDARD_MODULE_HEADER, "notes", notes_functions, PHP_MINIT(notes), PHP_MSHUTDOWN(notes), PHP_RINIT(notes), PHP_RSHUTDOWN(notes), PHP_MINFO(notes), NO_VERSION_YET, STANDARD_MODULE_PROPERTIES};#ifdef COMPILE_DL_NOTESZEND_GET_MODULE(notes)#endifPHP_MINIT_FUNCTION(notes){ return SUCCESS;}PHP_MSHUTDOWN_FUNCTION(notes){ return SUCCESS;}PHP_RSHUTDOWN_FUNCTION(notes){ return SUCCESS;}PHP_RINIT_FUNCTION(notes){ return SUCCESS;}PHP_MINFO_FUNCTION(notes){ php_info_print_table_start(); php_info_print_table_row(2, "Lotus Notes Database Support", "enabled"); php_info_print_table_end();}/* {{{ proto bool notes_create_db(string database_name) Creates a Lotus Notes database */PHP_FUNCTION(notes_create_db){ int argc; pval *argv[1]; STATUS error; pval **db; char error_string[200]; argc = ARG_COUNT(ht); if (getParametersArray(ht, argc, argv) == FAILURE) WRONG_PARAM_COUNT; if (zend_get_parameters_ex(1, &db)==FAILURE) { RETURN_FALSE; } convert_to_string_ex(db); 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; } if (error = NSFDbCreate (Z_STRVAL_PP(db), (USHORT) DBCLASS_NOTEFILE, FALSE)) { OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string)); php_error(E_WARNING,"Unable to create database: %s", error_string); NotesTerm(); RETURN_FALSE; } NotesTerm(); RETURN_TRUE;}/* }}} *//* {{{ proto bool notes_drop_db(string database_name) Drops a Lotus Notes database */PHP_FUNCTION(notes_drop_db){ int argc; pval *argv[1]; STATUS error; pval **db; char error_string[200]; argc = ARG_COUNT(ht); if (getParametersArray(ht, argc, argv) == FAILURE) WRONG_PARAM_COUNT; if (zend_get_parameters_ex(1, &db)==FAILURE) { RETURN_FALSE; } convert_to_string_ex(db); 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; } if (error = NSFDbDelete (Z_STRVAL_PP(db))) { OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string)); php_error(E_WARNING,"Unable to delete database: %s", error_string); NotesTerm(); RETURN_FALSE; } NotesTerm(); RETURN_TRUE;}/* }}} *//* {{{ proto string notes_version(string database_name) Gets the Lotus Notes version */PHP_FUNCTION(notes_version){ int argc; pval *argv[1]; STATUS error; DBHANDLE db_handle; WORD wbuild; char error_string[200]; pval **db; argc = ARG_COUNT(ht); if (getParametersArray(ht, argc, argv) == FAILURE){ WRONG_PARAM_COUNT; } if (zend_get_parameters_ex(1, &db)==FAILURE) { RETURN_FALSE; } convert_to_string_ex(db); 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; } if (error = NSFDbOpen(Z_STRVAL_PP(db), &db_handle)) { OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string)); php_error(E_WARNING,"Unable to open database: %s", error_string); NotesTerm(); RETURN_FALSE; } if (error = NSFDbGetBuildVersion(db_handle, &wbuild)) { OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string)); php_error(E_WARNING,"Unable to get Lotus Notes version: %s", error_string); NSFDbClose(db_handle); NotesTerm(); RETURN_FALSE; } NSFDbClose(db_handle); NotesTerm(); if(wbuild > 0 && wbuild < 82) { RETURN_DOUBLE(1.0); } else if (wbuild > 81 && wbuild < 94) { RETURN_DOUBLE(2.0); } else if (wbuild > 93 && wbuild < 119) { RETURN_DOUBLE(3.0); } else if (wbuild > 118 && wbuild < 137) { RETURN_DOUBLE(4.0); } else if (wbuild == 138) { RETURN_DOUBLE(4.1); } else if (wbuild > 139 && wbuild < 146) { RETURN_DOUBLE(4.5); } else if (wbuild == 147) { RETURN_DOUBLE(4.6); } else { RETURN_DOUBLE(5.0); }}/* }}} *//* {{{ proto string notes_create_note(string database_name, string form_name) Creates a note using form form_name */PHP_FUNCTION(notes_create_note){ int argc; pval *argv[2]; STATUS error; DBHANDLE db_handle; NOTEHANDLE note_handle; char error_string[200]; pval **db; pval **form_name; argc = ARG_COUNT(ht); if (getParametersArray(ht, argc, argv) == FAILURE){ WRONG_PARAM_COUNT; } if (zend_get_parameters_ex(2, &db, &form_name)==FAILURE) { RETURN_FALSE; } convert_to_string_ex(db); convert_to_string_ex(form_name); 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; } if (error = NSFDbOpen(Z_STRVAL_PP(db), &db_handle)) { OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string)); php_error(E_WARNING,"Unable to open database: %s", error_string); NotesTerm(); RETURN_FALSE; } if (error = NSFNoteCreate (db_handle, ¬e_handle)) { OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string)); php_error(E_WARNING,"Unable to create note: error_string"); NSFDbClose( db_handle ); RETURN_FALSE; } /* Append the form name item to the new note */ if (error = NSFItemSetText(note_handle, FIELD_FORM, Z_STRVAL_PP(form_name), MAXWORD)) { OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string)); php_error(E_WARNING,"Unable to use the form: %s", error_string); NSFNoteClose (note_handle); NSFDbClose( db_handle ); RETURN_FALSE; } if (error = NSFNoteUpdate (note_handle, 0)) { OSLoadString(NULLHANDLE, ERR(error), error_string, sizeof(error_string)); php_error(E_WARNING,"Unable to save the note: %s", error_string); NSFNoteClose (note_handle); NSFDbClose(db_handle); RETURN_FALSE; } error = NSFNoteClose (note_handle); NSFDbClose(db_handle); NotesTerm(); RETURN_TRUE;}/* }}} *//* Declarations for notes_mark_read and notes_mark_unread */#define ACTION_COUNT_MAX (16)/* Entries in the action table */typedef struct { BOOL AddFlag; /* TRUE: Add, FALSE: Remove */ NOTEID NoteID;} ACTION_ENTRY; /* Table of actions to be performed */ACTION_ENTRY ActionTable [ACTION_COUNT_MAX] = {FALSE, 0L};/* * Forward references */ /* Function to display unread note table */STATUS DisplayUnread ( DBHANDLE db_handle, char NOTESPTR pName, WORD nameLen); /* Function to apply actions to unread note table */STATUS UpdateUnread ( DBHANDLE db_handle, char NOTESPTR pName, WORD nameLen, ACTION_ENTRY *pActions, int actionCount, NOTEID *pUndoID); /* Function that updates a note without changing its unread status */STATUS UndoUnreadStatus ( DBHANDLE db_handle, char NOTESPTR pName, WORD nameLen, ACTION_ENTRY *pActions, int actionCount, NOTEID UndoID);/* {{{ proto string notes_mark_read(string database_name, string user_name, string note_id) Marks a note_id as read for the User user_name. Note: user_name must be fully distinguished user name */PHP_FUNCTION(notes_mark_read){ int argc; int ActionCount; pval *argv[3]; STATUS error; DBHANDLE db_handle; pval **db; pval **note_id; pval **user_name;/* Local data declarations */ WORD UserNameLen = 0; char *pEnd; int curAction; int curArg; NOTEID UndoID = 0L; char error_string[200]; argc = ARG_COUNT(ht); if (getParametersArray(ht, argc, argv) == FAILURE){ WRONG_PARAM_COUNT; } if (zend_get_parameters_ex(3, &db, &user_name, ¬e_id)==FAILURE) { RETURN_FALSE; } convert_to_string_ex(db); convert_to_string_ex(note_id); convert_to_string_ex(user_name); 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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -