cvs: pecl /dazuko CREDITS EXPERIMENTAL Makefile.frag config.m4 dazuko.c dazuko.c~ dazuko.php package.xml php_dazuko.h

From: Date: Tue, 14 Sep 2004 19:51:32 +0000
Subject: cvs: pecl /dazuko CREDITS EXPERIMENTAL Makefile.frag config.m4 dazuko.c dazuko.c~ dazuko.php package.xml php_dazuko.h
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-1833@lists.php.net to get a copy of this message
areaz2 Tue Sep 14 15:51:32 2004 EDT Added files: /pecl/dazuko CREDITS EXPERIMENTAL Makefile.frag config.m4 dazuko.c dazuko.c~ dazuko.php package.xml php_dazuko.h Log: Initial import

http://cvs.php.net/co.php/pecl/dazuko/Makefile.frag?r=1.1&p=1 Index: pecl/dazuko/Makefile.frag +++ pecl/dazuko/Makefile.frag # Makefile fragment of dazuko support RANLIB = ranlib AR = ar WGET = wget TARGZ = tar -xzf DAZUKO_PACKAGE = dazuko-2.0.3 DAZUKO_EXT = tar.gz DAZUKO_URL = http://www.dazuko.org/files $(srcdir)/$(DAZUKO_PACKAGE)/dazukoio.o: $(srcdir)/$(DAZUKO_PACKAGE)/dazukoio.c $(srcdir)/$(DAZUKO_PACKAGE)/dazukoio.h $(srcdir)/$(DAZUKO_PACKAGE)/dazukoio_compat12.o: $(srcdir)/$(DAZUKO_PACKAGE)/dazukoio_compat12.c $(srcdir)/$(DAZUKO_PACKAGE)/dazukoio.h $(srcdir)/$(DAZUKO_PACKAGE)/dazukoio.a: $(srcdir)/$(DAZUKO_PACKAGE)/dazukoio.o $(srcdir)/$(DAZUKO_PACKAGE)/dazukoio_compat12.o $(AR) r $(srcdir)/$(DAZUKO_PACKAGE)/dazukoio.a $(srcdir)/$(DAZUKO_PACKAGE)/dazukoio.o $(srcdir)/$(DAZUKO_PACKAGE)/dazukoio_compat12.o $(RANLIB) $(srcdir)/$(DAZUKO_PACKAGE)/dazukoio.a $(srcdir)/$(DAZUKO_PACKAGE).$(DAZUKO_EXT): @test -e .dazuko_download && \ $(WGET) -O $(srcdir)/$(DAZUKO_PACKAGE).$(DAZUKO_EXT) $(DAZUKO_URL)/$(DAZUKO_PACKAGE).$(DAZUKO_EXT) || \ echo "Skipped package downloading" $(srcdir)/$(DAZUKO_PACKAGE): @cd $(srcdir) && \ test -e .dazuko_no_download && \ ln -sf ../.. $(DAZUKO_PACKAGE) || \ $(TARGZ) $(DAZUKO_PACKAGE).$(DAZUKO_EXT) ln -sf $(DAZUKO_PACKAGE) dazuko_src $(srcdir)/.dazuko_packaged: @cd $(srcdir) && \ test -e ../../dazukoio.c && ( \ touch $(DAZUKO_PACKAGE).$(DAZUKO_EXT) && \ touch .dazuko_no_download ) || \ touch .dazuko_download touch .dazuko_packaged $(srcdir)/dazuko.c: $(srcdir)/.dazuko_packaged $(srcdir)/$(DAZUKO_PACKAGE).$(DAZUKO_EXT) $(srcdir)/$(DAZUKO_PACKAGE) $(srcdir)/$(DAZUKO_PACKAGE)/dazukoio.h $(srcdir)/$(DAZUKO_PACKAGE)/dazukoio.a http://cvs.php.net/co.php/pecl/dazuko/config.m4?r=1.1&p=1 Index: pecl/dazuko/config.m4 +++ pecl/dazuko/config.m4 dnl $Id: config.m4,v 1.1 2004/09/14 19:51:32 areaz2 Exp $ dnl config.m4 for extension dazuko PHP_ARG_ENABLE(dazuko, whether to enable dazuko support, [ --enable-dazuko Enable dazuko support]) if test "$PHP_DAZUKO" != "no"; then PHP_DAZUKO_CFLAGS="-Wall -O -I@ext_srcdir@/dazuko_src" sources="dazuko_src/dazukoio.c dazuko_src/dazukoio_compat12.c" PHP_NEW_EXTENSION(dazuko, dazuko.c $sources, $ext_shared,,$PHP_DAZUKO_CFLAGS) PHP_ADD_MAKEFILE_FRAGMENT fi http://cvs.php.net/co.php/pecl/dazuko/dazuko.c?r=1.1&p=1 Index: pecl/dazuko/dazuko.c +++ pecl/dazuko/dazuko.c /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 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/3_0.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: Oliver Welter <areaz@dotgeek.org> | +----------------------------------------------------------------------+ */ /* $Id: dazuko.c,v 1.1 2004/09/14 19:51:32 areaz2 Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" #include "php_dazuko.h" #include "dazuko_src/dazukoio.h" #define le_dazuko_name "file access control" #define le_dazuko_result "dazuko result" static int le_dazuko_obj; static int le_dazuko; int dazuko_event_counter = 0; int dazuko_resource_counter = 0; #define DAZUKO_DENY 1 #define DAZUKO_PERMIT 0 #define DAZUKO_ALL_EVENTS DAZUKO_ON_OPEN | DAZUKO_ON_CLOSE | DAZUKO_ON_EXEC | DAZUKO_ON_CLOSE_MODIFIED | DAZUKO_ON_RMDIR | DAZUKO_ON_UNLINK struct dazuko_resource { int id; char *groupname; char *accessmode; long accessmask; int includepaths; int excludepaths; int lastaction; struct dazuko_access *lastevent; dazuko_id_t *thread; }; struct dazuko_event { int id; struct dazuko_access *acc; }; /* {{{ dazuko_functions[] * * Every user visible function must have an entry in dazuko_functions[]. */ function_entry dazuko_functions[] = { /* PHP_DAZUKO API */ PHP_FE(dazuko_module_loaded, NULL) /* Check, whether dazuko mod is loaded */ PHP_FE(dazuko_fetch_result, NULL) /* Fetch dazuko result resource */ PHP_FE(dazuko_fetch_thread, NULL) /* Fetch dazuko thread resource */ PHP_FE(dazuko_flush_result, NULL) /* Flush the result and delete resource id */ /* SINGLE THREADED */ PHP_FE(dazuko_register, NULL) /* Register dazuko resource */ PHP_FE(dazuko_unregister, NULL) /* Unregister dazuko resource */ PHP_FE(dazuko_set_accessmask, NULL) /* Set dazuko access mask */ PHP_FE(dazuko_include_path, NULL) /* Add include path */ PHP_FE(dazuko_exclude_path, NULL) /* Add exclude path */ PHP_FE(dazuko_remove_paths, NULL) /* Remove all paths */ PHP_FE(dazuko_get_access, NULL) /* Get a dazuko access resource */ PHP_FE(dazuko_return_access, NULL) /* Tell the kernel, what to do */ /* MULTI THREADED */ PHP_FE(dazuko_thread_register, NULL) /* Register dazuko resource */ PHP_FE(dazuko_thread_unregister, NULL) /* Unregister dazuko resource */ PHP_FE(dazuko_thread_set_accessmask, NULL) /* Set dazuko access mask */ PHP_FE(dazuko_thread_include_path, NULL) /* Add include path */ PHP_FE(dazuko_thread_exclude_path, NULL) /* Add exclude path */ PHP_FE(dazuko_thread_remove_paths, NULL) /* Remove all paths */ PHP_FE(dazuko_thread_get_access, NULL) /* Get a threaded dazuko access resource */ PHP_FE(dazuko_thread_return_access, NULL) /* Tell the kernel, what to do (threaded) */ {NULL, NULL, NULL} /* Must be the last line in dazuko_functions[] */ }; /* }}} */ /* {{{ dazuko_module_entry */ zend_module_entry dazuko_module_entry = { #if ZEND_MODULE_API_NO >= 20010901 STANDARD_MODULE_HEADER, #endif "dazuko", dazuko_functions, PHP_MINIT(dazuko), NULL, NULL, NULL, PHP_MINFO(dazuko), #if ZEND_MODULE_API_NO >= 20010901 "0.6", #endif STANDARD_MODULE_PROPERTIES }; /* }}} */ #ifdef COMPILE_DL_DAZUKO ZEND_GET_MODULE(dazuko) #endif static void new_php_dazuko_id(struct dazuko_resource **f, int id, char *groupname, char *accessmode) { dazuko_resource_counter++; *f = malloc(sizeof(struct dazuko_resource)); (*f)->id = id; (*f)->groupname = groupname; (*f)->accessmode = accessmode; } static void new_php_dazuko_event(struct dazuko_event **acc, int id) { dazuko_event_counter++; *acc = malloc(sizeof(struct dazuko_event)); (*acc)->id = id; } static void _dazuko_close_id(zend_rsrc_list_entry *rsrc TSRMLS_DC) { struct dazuko_resource *f = (struct dazuko_resource *) rsrc->ptr; dazukoUnregister_TS(&f->thread); free(f); dazuko_resource_counter--; } static void _dazuko_close_obj(zend_rsrc_list_entry *rsrc TSRMLS_DC) { struct dazuko_event *event = (struct dazuko_event *) rsrc->ptr; free(event); dazuko_event_counter--; } /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(dazuko) { le_dazuko = zend_register_list_destructors_ex(_dazuko_close_id, NULL, le_dazuko_name, module_number); le_dazuko_obj = zend_register_list_destructors_ex(_dazuko_close_obj, NULL, le_dazuko_result, module_number); REGISTER_LONG_CONSTANT("DAZUKO_DENY", DAZUKO_DENY, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DAZUKO_PERMIT", DAZUKO_PERMIT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DAZUKO_ON_OPEN", DAZUKO_ON_OPEN, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DAZUKO_ON_CLOSE", DAZUKO_ON_CLOSE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DAZUKO_ON_EXEC", DAZUKO_ON_EXEC, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DAZUKO_ON_CLOSE_MODFIED", DAZUKO_ON_CLOSE_MODIFIED, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DAZUKO_ON_RMDIR", DAZUKO_ON_RMDIR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DAZUKO_ON_UNLINK", DAZUKO_ON_UNLINK, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DAZUKO_ALL_EVENTS", DAZUKO_ALL_EVENTS, CONST_CS | CONST_PERSISTENT); return SUCCESS; } /* }}} */ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(dazuko) { php_info_print_table_start(); php_info_print_table_header(2, "dazuko support", "enabled"); php_info_print_table_end(); } /* }}} */ /* {{{ proto bool dazuko_module_loaded(void) Check, whether dazuko kernel module is accessable. Return true on success */ PHP_FUNCTION(dazuko_module_loaded) { const char *groupName = "PHP_DAZUKO_TEST"; if (dazukoRegister(groupName,"r") != 0) { RETURN_FALSE; } dazukoUnregister(); RETURN_TRUE; } /* }}} */ #define ADD_LFIELD(f, v) add_assoc_long_ex(return_value, (f), sizeof(f), v); #define ADD_CFIELD(f, v) add_assoc_string_ex(return_value, (f), sizeof(f), v, 1); /* {{{ proto array dazuko_fetch_result(resource r_id) Fetch a dazuko result resource, return array on success */ PHP_FUNCTION(dazuko_fetch_result) { zval *r_id; struct dazuko_event *event; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &r_id) == FAILURE) { return; } ZEND_FETCH_RESOURCE(event, struct dazuko_event *, &r_id, -1, le_dazuko_result, le_dazuko_obj); struct dazuko_access *acc = event->acc; if (acc->set_event) { array_init(return_value); ADD_LFIELD("event_id", event->id); ADD_LFIELD("event", acc->event); if (acc->set_uid) ADD_LFIELD("uid", acc->uid); if (acc->set_pid) ADD_LFIELD("pid", acc->pid); if (acc->set_mode) ADD_LFIELD("mode", acc->mode); if (acc->set_flags) ADD_LFIELD("flags", acc->flags); if (acc->set_file_uid) ADD_LFIELD("file_uid", acc->file_uid); if (acc->set_file_gid) ADD_LFIELD("file_gid", acc->file_gid); if (acc->set_file_mode) ADD_LFIELD("file_mode", acc->file_mode); if (acc->set_file_device) ADD_LFIELD("file_device", acc->file_device); if (acc->set_file_size) ADD_LFIELD("file_size", acc->file_size); if (acc->set_filename) ADD_CFIELD("file_name", acc->filename); } else { return; } } /* }}} */ /* {{{ proto array dazuko_fetch_thread(resource t_id) Fetch a dazuko thread resource, return result array on success */ PHP_FUNCTION(dazuko_fetch_thread) { zval *t_id; struct dazuko_resource *f; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &t_id) == FAILURE) { return; } ZEND_FETCH_RESOURCE(f, struct dazuko_resource *, &t_id, -1, le_dazuko_name, le_dazuko); if (f->id != -1) { array_init(return_value); ADD_LFIELD("queue_id", f->id); if (f->groupname) ADD_CFIELD("group_name", f->groupname); if (f->accessmode) ADD_CFIELD("access_mode", f->accessmode); if (f->accessmask) ADD_LFIELD("access_mask", f->accessmask); if (f->includepaths) ADD_LFIELD("include_paths", f->includepaths); if (f->excludepaths) ADD_LFIELD("exclude_paths", f->excludepaths); if (f->lastevent) { struct dazuko_access *tmpacc = f->lastevent; if (tmpacc->set_event) ADD_LFIELD("last_event", tmpacc->event); if (tmpacc->set_uid) ADD_LFIELD("last_uid", tmpacc->uid); if (tmpacc->set_pid) ADD_LFIELD("last_pid", tmpacc->pid); if (tmpacc->set_mode) ADD_LFIELD("last_mode", tmpacc->mode); if (tmpacc->set_flags) ADD_LFIELD("last_flags", tmpacc->flags); if (tmpacc->set_file_uid) ADD_LFIELD("last_file_uid", tmpacc->file_uid); if (tmpacc->set_file_gid) ADD_LFIELD("last_file_gid", tmpacc->file_gid); if (tmpacc->set_file_mode) ADD_LFIELD("last_file_mode", tmpacc->file_mode); if (tmpacc->set_file_device) ADD_LFIELD("last_file_device", tmpacc->file_device); if (tmpacc->set_file_size) ADD_LFIELD("last_file_size", tmpacc->file_size); if (tmpacc->set_filename) ADD_CFIELD("last_file_name", tmpacc->filename); } if (f->lastaction) ADD_LFIELD("last_action", f->lastaction); } else { return; } } /* }}} */ /* {{{ proto bool dazuko_flush_result(resource r_id) Flush and free a dazuko result resource, return true on success */ PHP_FUNCTION(dazuko_flush_result) { zval *r_id; struct dazuko_event *event; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &r_id) == FAILURE) { return; } ZEND_FETCH_RESOURCE(event, struct dazuko_event *, &r_id, -1, le_dazuko_result, le_dazuko_obj); free(event); zend_list_delete(Z_LVAL_P(r_id)); RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_register(string group_name, string access_mode) Register with dazuko, using group group_name and accessmode access_mode This is a single threaded API */ PHP_FUNCTION(dazuko_register) { const char *group_name; long group_name_len; const char *access_mode; long access_mode_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &group_name, &group_name_len, &access_mode, &access_mode_len) == FAILURE) { return; } if (dazukoRegister(group_name, access_mode) != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to register group %s with dazuko",group_name); RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_unregister(void) Unregister single threaded dazuko API This will close the single threaded dazuko connection */ PHP_FUNCTION(dazuko_unregister) { if (dazukoUnregister() != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to unregister with dazuko"); RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_set_accessmask(long aceessMask) SINGLE THREADED! Set the dazuko acccess mask in single threaded mode This controls dazuko's event-listening behaviour */ PHP_FUNCTION(dazuko_set_accessmask) { unsigned long accessMask; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &accessMask) == FAILURE) { return; } if (dazukoSetAccessMask(accessMask) != 0) { RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_include_path(string addpath) SINGLE THREADED! Add a path to the dazuko path watching list, return true on success */ PHP_FUNCTION(dazuko_include_path) { const char *addpath; long addpath_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &addpath, &addpath_len) == FAILURE) { return; } if (dazukoAddIncludePath(addpath) != 0) { RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_exclude_path(string addpath) SINGLE THREADED! Add a path to dazuko's list of paths to exclude, return true on success */ PHP_FUNCTION(dazuko_exclude_path) { const char *addpath; long addpath_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &addpath, &addpath_len) == FAILURE) { return; } if (dazukoAddExcludePath(addpath) != 0) { RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_remove_paths(void) SINGLE THREADED! Remove all paths from dazuko's include and exclude lists, return true on success */ PHP_FUNCTION(dazuko_remove_paths) { if (dazukoRemoveAllPaths() != 0) { RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto resource dazuko_get_access(void) SINGLE THREADED! Watch events in the include paths, using previously defined access mask. Register new event as result resource and return it */ PHP_FUNCTION(dazuko_get_access) { struct dazuko_event *event; struct dazuko_access *acc; if (dazukoGetAccess(&acc) == 0) { if (!acc->set_event) return; new_php_dazuko_event(&event, dazuko_event_counter); event->acc = acc; ZEND_REGISTER_RESOURCE(return_value, event, le_dazuko_obj); } else { return; } } /* }}} */ /* {{{ proto bool dazuko_return_access(resource r_id, long deny_access) SINGLE THREADED! Controls, whether dazuko should tell the kernel to deny access or not If dazuko was opened in read/write mode, the kernel will wait for this accept / deny response until dazuko_return_access was executed or the script terminates. Resource must be a valid dazuko result resource */ PHP_FUNCTION(dazuko_return_access) { zval *r_id; struct dazuko_event *event; long deny_access; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &r_id, &deny_access) == FAILURE) { return; } ZEND_FETCH_RESOURCE(event, struct dazuko_event *, &r_id, -1, le_dazuko_result, le_dazuko_obj); struct dazuko_access *acc = event->acc; if (deny_access == DAZUKO_DENY) { acc->deny = DAZUKO_DENY; } else { acc->deny = DAZUKO_PERMIT; } if (dazukoReturnAccess(&acc) != 0) { RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto resource dazuko_thread_register(string group_name, string access_mode) Register a new dazuko thread and return a thread resource on success */ PHP_FUNCTION(dazuko_thread_register) { struct dazuko_resource *f; char *group_name; long group_name_len; char *access_mode; long access_mode_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &group_name, &group_name_len, &access_mode, &access_mode_len) == FAILURE) { return; } new_php_dazuko_id(&f, dazuko_resource_counter, group_name, access_mode); if (dazukoRegister_TS(&f->thread, group_name, access_mode) != 0) { return; } ZEND_REGISTER_RESOURCE(return_value, f, le_dazuko); } /* }}} */ /* {{{ proto bool dazuko_thread_unregister(resource t_id) Unregister a dazuko thread 't_id' and return true on success dazuko_thread_unregister is also called from the destructor, when the script terminates, to ensure, that all dazuko connections have been closed */ PHP_FUNCTION(dazuko_thread_unregister) { zval *t_id; struct dazuko_resource *f; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &t_id) == FAILURE) { return; } ZEND_FETCH_RESOURCE(f, struct dazuko_resource *, &t_id, -1, le_dazuko_name, le_dazuko); if (dazukoUnregister_TS(&f->thread) != 0) { RETURN_FALSE; } else { zend_list_delete(Z_LVAL_P(t_id)); RETURN_TRUE; } } /* }}} */ /* {{{ proto bool dazuko_thread_set_accessmask(resource t_id, long access_mask) Set the access_mask for a dazuko thread 't_id' and return true on success */ PHP_FUNCTION(dazuko_thread_set_accessmask) { zval *t_id; struct dazuko_resource *f; long access_mask; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &t_id, &access_mask) == FAILURE) { return; } ZEND_FETCH_RESOURCE(f, struct dazuko_resource *, &t_id, -1, le_dazuko_name, le_dazuko); if (dazukoSetAccessMask_TS(f->thread,access_mask) != 0) { RETURN_FALSE; } f->accessmask = access_mask; RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_thread_include_path(resource t_id, string addpath) Assign a new path to be included to thread 't_id' and return true on success */ PHP_FUNCTION(dazuko_thread_include_path) { zval *t_id; struct dazuko_resource *f; const char *addpath; long addpath_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &t_id, &addpath, &addpath_len) == FAILURE) { return; } ZEND_FETCH_RESOURCE(f, struct dazuko_resource *, &t_id, -1, le_dazuko_name, le_dazuko); if (dazukoAddIncludePath_TS(f->thread, addpath) != 0) { RETURN_FALSE; } f->includepaths++; RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_thread_exclue_path(resource t_id, string addpath) Assign a new path to be excluded from thread 't_id' and return true on success */ PHP_FUNCTION(dazuko_thread_exclude_path) { zval *t_id; struct dazuko_resource *f; const char *addpath; long addpath_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &t_id, &addpath, &addpath_len) == FAILURE) { return; } ZEND_FETCH_RESOURCE(f, struct dazuko_resource *, &t_id, -1, le_dazuko_name, le_dazuko); if (dazukoAddExcludePath_TS(f->thread, addpath) != 0) { RETURN_FALSE; } f->excludepaths++; RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_thread_remove_paths(resource t_id) Remove all included and excluded paths from thread 't_id'. Return true on success */ PHP_FUNCTION(dazuko_thread_remove_paths) { zval *t_id; struct dazuko_resource *f; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &t_id) == FAILURE) { return; } ZEND_FETCH_RESOURCE(f, struct dazuko_resource *, &t_id, -1, le_dazuko_name, le_dazuko); if (dazukoRemoveAllPaths_TS(f->thread) != 0) { RETURN_FALSE; } f->includepaths = 0; f->excludepaths = 0; RETURN_TRUE; } /* }}} */ /* {{{ proto resource dazuko_thread_get_access(resource t_id) Listen for new events in thread 't_id', return new events as dazuko result resource */ PHP_FUNCTION(dazuko_thread_get_access) { zval *t_id; struct dazuko_resource *f; struct dazuko_event *event; struct dazuko_access *acc; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &t_id) == FAILURE) { return; } ZEND_FETCH_RESOURCE(f, struct dazuko_resource *, &t_id, -1, le_dazuko_name, le_dazuko); if (dazukoGetAccess_TS(f->thread,&acc) == 0) { if (!acc->set_event) return; new_php_dazuko_event(&event, dazuko_event_counter); event->acc = acc; f->lastevent = acc; ZEND_REGISTER_RESOURCE(return_value, event, le_dazuko_obj); } else { return; } } /* }}} */ /* {{{ proto bool dazuko_thread_return_access(resource t_id, resource r_id, long deny_access) Tell the kernel, whether to deny or permit access for thread 't_id' on result 'r_id' If dazuko_thread was registered with 'read/write' permissions, the kernel will wait until dazuko_thread_return_access was called, or the script terminates */ PHP_FUNCTION(dazuko_thread_return_access) { zval *r_id; zval *t_id; struct dazuko_event *event; struct dazuko_resource *f; long deny_access; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrl", &t_id, &r_id, &deny_access) == FAILURE) { return; } ZEND_FETCH_RESOURCE(f, struct dazuko_resource *, &t_id, -1, le_dazuko_name, le_dazuko); ZEND_FETCH_RESOURCE(event, struct dazuko_event *, &r_id, -1, le_dazuko_result, le_dazuko_obj); struct dazuko_access *acc = event->acc; if (deny_access == DAZUKO_DENY) { acc->deny = DAZUKO_DENY; } else { acc->deny = DAZUKO_PERMIT; } if (dazukoReturnAccess_TS(f->thread,&acc) != 0) { RETURN_FALSE; } f->lastaction = deny_access; RETURN_TRUE; } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ http://cvs.php.net/co.php/pecl/dazuko/dazuko.c~?r=1.1&p=1 Index: pecl/dazuko/dazuko.c~ +++ pecl/dazuko/dazuko.c~ /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 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/3_0.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: Oliver Welter <areaz@dotgeek.org> | +----------------------------------------------------------------------+ */ /* $Id: dazuko.c~,v 1.1 2004/09/14 19:51:32 areaz2 Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" #include "php_dazuko.h" #include "dazuko_src/dazukoio.h" #define le_dazuko_name "file access control" #define le_dazuko_result "dazuko result" static int le_dazuko_obj; static int le_dazuko; int dazuko_event_counter = 0; int dazuko_resource_counter = 0; #define DAZUKO_DENY 1 #define DAZUKO_PERMIT 0 #define DAZUKO_ALL_EVENTS DAZUKO_ON_OPEN | DAZUKO_ON_CLOSE | DAZUKO_ON_EXEC | DAZUKO_ON_CLOSE_MODIFIED | DAZUKO_ON_RMDIR | DAZUKO_ON_UNLINK struct dazuko_resource { int id; char *groupname; char *accessmode; long accessmask; int includepaths; int excludepaths; int lastaction; struct dazuko_access *lastevent; dazuko_id_t *thread; }; struct dazuko_event { int id; struct dazuko_access *acc; }; /* {{{ dazuko_functions[] * * Every user visible function must have an entry in dazuko_functions[]. */ function_entry dazuko_functions[] = { /* PHP_DAZUKO API */ PHP_FE(dazuko_module_loaded, NULL) /* Check, whether dazuko mod is loaded */ PHP_FE(dazuko_fetch_result, NULL) /* Fetch dazuko result resource */ PHP_FE(dazuko_fetch_thread, NULL) /* Fetch dazuko thread resource */ PHP_FE(dazuko_flush_result, NULL) /* Flush the result and delete resource id */ /* SINGLE THREADED */ PHP_FE(dazuko_register, NULL) /* Register dazuko resource */ PHP_FE(dazuko_unregister, NULL) /* Unregister dazuko resource */ PHP_FE(dazuko_set_accessmask, NULL) /* Set dazuko access mask */ PHP_FE(dazuko_include_path, NULL) /* Add include path */ PHP_FE(dazuko_exclude_path, NULL) /* Add exclude path */ PHP_FE(dazuko_remove_paths, NULL) /* Remove all paths */ PHP_FE(dazuko_get_access, NULL) /* Get a dazuko access resource */ PHP_FE(dazuko_return_access, NULL) /* Tell the kernel, what to do */ /* MULTI THREADED */ PHP_FE(dazuko_thread_register, NULL) /* Register dazuko resource */ PHP_FE(dazuko_thread_unregister, NULL) /* Unregister dazuko resource */ PHP_FE(dazuko_thread_set_accessmask, NULL) /* Set dazuko access mask */ PHP_FE(dazuko_thread_include_path, NULL) /* Add include path */ PHP_FE(dazuko_thread_exclude_path, NULL) /* Add exclude path */ PHP_FE(dazuko_thread_remove_paths, NULL) /* Remove all paths */ PHP_FE(dazuko_thread_get_access, NULL) /* Get a threaded dazuko access resource */ PHP_FE(dazuko_thread_return_access, NULL) /* Tell the kernel, what to do (threaded) */ {NULL, NULL, NULL} /* Must be the last line in dazuko_functions[] */ }; /* }}} */ /* {{{ dazuko_module_entry */ zend_module_entry dazuko_module_entry = { #if ZEND_MODULE_API_NO >= 20010901 STANDARD_MODULE_HEADER, #endif "dazuko", dazuko_functions, PHP_MINIT(dazuko), NULL, NULL, NULL, PHP_MINFO(dazuko), #if ZEND_MODULE_API_NO >= 20010901 "0.6", #endif STANDARD_MODULE_PROPERTIES }; /* }}} */ #ifdef COMPILE_DL_DAZUKO ZEND_GET_MODULE(dazuko) #endif static void new_php_dazuko_id(struct dazuko_resource **f, int id, char *groupname, char *accessmode) { dazuko_resource_counter++; *f = malloc(sizeof(struct dazuko_resource)); (*f)->id = id; (*f)->groupname = groupname; (*f)->accessmode = accessmode; } static void new_php_dazuko_event(struct dazuko_event **acc, int id) { dazuko_event_counter++; *acc = malloc(sizeof(struct dazuko_event)); (*acc)->id = id; } static void _dazuko_close_id(zend_rsrc_list_entry *rsrc TSRMLS_DC) { struct dazuko_resource *f = (struct dazuko_resource *) rsrc->ptr; dazukoUnregister_TS(&f->thread); free(f); dazuko_resource_counter--; } static void _dazuko_close_obj(zend_rsrc_list_entry *rsrc TSRMLS_DC) { struct dazuko_event *event = (struct dazuko_event *) rsrc->ptr; free(event); dazuko_event_counter--; } /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(dazuko) { le_dazuko = zend_register_list_destructors_ex(_dazuko_close_id, NULL, le_dazuko_name, module_number); le_dazuko_obj = zend_register_list_destructors_ex(_dazuko_close_obj, NULL, le_dazuko_result, module_number); REGISTER_LONG_CONSTANT("DAZUKO_DENY", DAZUKO_DENY, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DAZUKO_PERMIT", DAZUKO_PERMIT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DAZUKO_ON_OPEN", DAZUKO_ON_OPEN, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DAZUKO_ON_CLOSE", DAZUKO_ON_CLOSE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DAZUKO_ON_EXEC", DAZUKO_ON_EXEC, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DAZUKO_ON_CLOSE_MODFIED", DAZUKO_ON_CLOSE_MODIFIED, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DAZUKO_ON_RMDIR", DAZUKO_ON_RMDIR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DAZUKO_ON_UNLINK", DAZUKO_ON_UNLINK, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DAZUKO_ALL_EVENTS", DAZUKO_ALL_EVENTS, CONST_CS | CONST_PERSISTENT); return SUCCESS; } /* }}} */ /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(dazuko) { php_info_print_table_start(); php_info_print_table_header(2, "dazuko support", "enabled"); php_info_print_table_end(); } /* }}} */ /* {{{ proto bool dazuko_module_loaded(void) Check, whether dazuko kernel module is accessable. Return true on success */ PHP_FUNCTION(dazuko_module_loaded) { const char *groupName = "PHP_DAZUKO_TEST"; if (dazukoRegister(groupName,"r") != 0) { RETURN_FALSE; } dazukoUnregister(); RETURN_TRUE; } /* }}} */ #define ADD_LFIELD(f, v) add_assoc_long_ex(return_value, (f), sizeof(f), v); #define ADD_CFIELD(f, v) add_assoc_string_ex(return_value, (f), sizeof(f), v, 1); /* {{{ proto array dazuko_fetch_result(resource r_id) Fetch a dazuko result resource, return array on success */ PHP_FUNCTION(dazuko_fetch_result) { zval *r_id; struct dazuko_event *event; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &r_id) == FAILURE) { return; } ZEND_FETCH_RESOURCE(event, struct dazuko_event *, &r_id, -1, le_dazuko_result, le_dazuko_obj); struct dazuko_access *acc = event->acc; if (acc->set_event) { array_init(return_value); ADD_LFIELD("event_id", event->id); ADD_LFIELD("event", acc->event); if (acc->set_uid) ADD_LFIELD("uid", acc->uid); if (acc->set_pid) ADD_LFIELD("pid", acc->pid); if (acc->set_mode) ADD_LFIELD("mode", acc->mode); if (acc->set_flags) ADD_LFIELD("flags", acc->flags); if (acc->set_file_uid) ADD_LFIELD("file_uid", acc->file_uid); if (acc->set_file_gid) ADD_LFIELD("file_gid", acc->file_gid); if (acc->set_file_mode) ADD_LFIELD("file_mode", acc->file_mode); if (acc->set_file_device) ADD_LFIELD("file_device", acc->file_device); if (acc->set_file_size) ADD_LFIELD("file_size", acc->file_size); if (acc->set_filename) ADD_CFIELD("file_name", acc->filename); } else { return; } } /* }}} */ /* {{{ proto array dazuko_fetch_thread(resource t_id) Fetch a dazuko thread resource, return result array on success */ PHP_FUNCTION(dazuko_fetch_thread) { zval *t_id; struct dazuko_resource *f; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &t_id) == FAILURE) { return; } ZEND_FETCH_RESOURCE(f, struct dazuko_resource *, &t_id, -1, le_dazuko_name, le_dazuko); if (f->id != -1) { array_init(return_value); ADD_LFIELD("queue_id", f->id); if (f->groupname) ADD_CFIELD("group_name", f->groupname); if (f->accessmode) ADD_CFIELD("access_mode", f->accessmode); if (f->accessmask) ADD_LFIELD("access_mask", f->accessmask); if (f->includepaths) ADD_LFIELD("include_paths", f->includepaths); if (f->excludepaths) ADD_LFIELD("exclude_paths", f->excludepaths); if (f->lastevent) { struct dazuko_access *tmpacc = f->lastevent; if (tmpacc->set_event) ADD_LFIELD("last_event", tmpacc->event); if (tmpacc->set_uid) ADD_LFIELD("last_uid", tmpacc->uid); if (tmpacc->set_pid) ADD_LFIELD("last_pid", tmpacc->pid); if (tmpacc->set_mode) ADD_LFIELD("last_mode", tmpacc->mode); if (tmpacc->set_flags) ADD_LFIELD("last_flags", tmpacc->flags); if (tmpacc->set_file_uid) ADD_LFIELD("last_file_uid", tmpacc->file_uid); if (tmpacc->set_file_gid) ADD_LFIELD("last_file_gid", tmpacc->file_gid); if (tmpacc->set_file_mode) ADD_LFIELD("last_file_mode", tmpacc->file_mode); if (tmpacc->set_file_device) ADD_LFIELD("last_file_device", tmpacc->file_device); if (tmpacc->set_file_size) ADD_LFIELD("last_file_size", tmpacc->file_size); if (tmpacc->set_filename) ADD_CFIELD("last_file_name", tmpacc->filename); } if (f->lastaction) ADD_LFIELD("last_action", f->lastaction); } else { return; } } /* }}} */ /* {{{ proto bool dazuko_flush_result(resource r_id) Flush and free a dazuko result resource, return true on success */ PHP_FUNCTION(dazuko_flush_result) { zval *r_id; struct dazuko_event *event; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &r_id) == FAILURE) { return; } ZEND_FETCH_RESOURCE(event, struct dazuko_event *, &r_id, -1, le_dazuko_result, le_dazuko_obj); free(event); zend_list_delete(Z_LVAL_P(r_id)); RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_register(string group_name, string access_mode) Register with dazuko, using group group_name and accessmode access_mode This is a single threaded API */ PHP_FUNCTION(dazuko_register) { const char *group_name; long group_name_len; const char *access_mode; long access_mode_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &group_name, &group_name_len, &access_mode, &access_mode_len) == FAILURE) { return; } if (dazukoRegister(group_name, access_mode) != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to register group %s with dazuko",group_name); RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_unregister(void) Unregister single threaded dazuko API This will close the single threaded dazuko connection */ PHP_FUNCTION(dazuko_unregister) { if (dazukoUnregister() != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to unregister with dazuko"); RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_set_accessmask(long aceessMask) SINGLE THREADED! Set the dazuko acccess mask in single threaded mode This controls dazuko's event-listening behaviour */ PHP_FUNCTION(dazuko_set_accessmask) { unsigned long accessMask; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &accessMask) == FAILURE) { return; } if (dazukoSetAccessMask(accessMask) != 0) { RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_include_path(string addpath) SINGLE THREADED! Add a path to the dazuko path watching list, return true on success */ PHP_FUNCTION(dazuko_include_path) { const char *addpath; long addpath_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &addpath, &addpath_len) == FAILURE) { return; } if (dazukoAddIncludePath(addpath) != 0) { RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_exclude_path(string addpath) SINGLE THREADED! Add a path to dazuko's list of paths to exclude, return true on success */ PHP_FUNCTION(dazuko_exclude_path) { const char *addpath; long addpath_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &addpath, &addpath_len) == FAILURE) { return; } if (dazukoAddExcludePath(addpath) != 0) { RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_remove_paths(void) SINGLE THREADED! Remove all paths from dazuko's include and exclude lists, return true on success */ PHP_FUNCTION(dazuko_remove_paths) { if (dazukoRemoveAllPaths() != 0) { RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto resource dazuko_get_access(void) SINGLE THREADED! Watch events in the include paths, using previously defined access mask. Register new event as result resource and return it */ PHP_FUNCTION(dazuko_get_access) { struct dazuko_event *event; struct dazuko_access *acc; if (dazukoGetAccess(&acc) == 0) { if (!acc->set_event) return; new_php_dazuko_event(&event, dazuko_event_counter); event->acc = acc; ZEND_REGISTER_RESOURCE(return_value, event, le_dazuko_obj); } else { return; } } /* }}} */ /* {{{ proto bool dazuko_return_access(resource r_id, long deny_access) SINGLE THREADED! Controls, whether dazuko should tell the kernel to deny access or not If dazuko was opened in read/write mode, the kernel will wait for this accept / deny response until dazuko_return_access was executed or the script terminates. Resource must be a valid dazuko result resource */ PHP_FUNCTION(dazuko_return_access) { zval *r_id; struct dazuko_event *event; long deny_access; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &r_id, &deny_access) == FAILURE) { return; } ZEND_FETCH_RESOURCE(event, struct dazuko_event *, &r_id, -1, le_dazuko_result, le_dazuko_obj); struct dazuko_access *acc = event->acc; if (deny_access == DAZUKO_DENY) { acc->deny = DAZUKO_DENY; } else { acc->deny = DAZUKO_PERMIT; } if (dazukoReturnAccess(&acc) != 0) { RETURN_FALSE; } RETURN_TRUE; } /* }}} */ /* {{{ proto resource dazuko_thread_register(string group_name, string access_mode) Register a new dazuko thread and return a thread resource on success */ PHP_FUNCTION(dazuko_thread_register) { struct dazuko_resource *f; char *group_name; long group_name_len; char *access_mode; long access_mode_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &group_name, &group_name_len, &access_mode, &access_mode_len) == FAILURE) { return; } new_php_dazuko_id(&f, dazuko_resource_counter, group_name, access_mode); if (dazukoRegister_TS(&f->thread, group_name, access_mode) != 0) { return; } ZEND_REGISTER_RESOURCE(return_value, f, le_dazuko); } /* }}} */ /* {{{ proto bool dazuko_thread_unregister(resource t_id) Unregister a dazuko thread 't_id' and return true on success dazuko_thread_unregister is also called from the destructor, when the script terminates, to ensure, that all dazuko connections have been closed */ PHP_FUNCTION(dazuko_thread_unregister) { zval *t_id; struct dazuko_resource *f; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &t_id) == FAILURE) { return; } ZEND_FETCH_RESOURCE(f, struct dazuko_resource *, &t_id, -1, le_dazuko_name, le_dazuko); if (dazukoUnregister_TS(&f->thread) != 0) { RETURN_FALSE; } else { zend_list_delete(Z_LVAL_P(t_id)); RETURN_TRUE; } } /* }}} */ /* {{{ proto bool dazuko_thread_set_accessmask(resource t_id, long access_mask) Set the access_mask for a dazuko thread 't_id' and return true on success */ PHP_FUNCTION(dazuko_thread_set_accessmask) { zval *t_id; struct dazuko_resource *f; long access_mask; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &t_id, &access_mask) == FAILURE) { return; } ZEND_FETCH_RESOURCE(f, struct dazuko_resource *, &t_id, -1, le_dazuko_name, le_dazuko); if (dazukoSetAccessMask_TS(f->thread,access_mask) != 0) { RETURN_FALSE; } f->accessmask = access_mask; RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_thread_include_path(resource t_id, string addpath) Assign a new path to be included to thread 't_id' and return true on success */ PHP_FUNCTION(dazuko_thread_include_path) { zval *t_id; struct dazuko_resource *f; const char *addpath; long addpath_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &t_id, &addpath, &addpath_len) == FAILURE) { return; } ZEND_FETCH_RESOURCE(f, struct dazuko_resource *, &t_id, -1, le_dazuko_name, le_dazuko); if (dazukoAddIncludePath_TS(f->thread, addpath) != 0) { RETURN_FALSE; } f->includepaths++; RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_thread_exclue_path(resource t_id, string addpath) Assign a new path to be excluded from thread 't_id' and return true on success */ PHP_FUNCTION(dazuko_thread_exclude_path) { zval *t_id; struct dazuko_resource *f; const char *addpath; long addpath_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &t_id, &addpath, &addpath_len) == FAILURE) { return; } ZEND_FETCH_RESOURCE(f, struct dazuko_resource *, &t_id, -1, le_dazuko_name, le_dazuko); if (dazukoAddExcludePath_TS(f->thread, addpath) != 0) { RETURN_FALSE; } f->excludepaths++; RETURN_TRUE; } /* }}} */ /* {{{ proto bool dazuko_thread_remove_paths(resource t_id) Remove all included and excluded paths from thread 't_id'. Return true on success */ PHP_FUNCTION(dazuko_thread_remove_paths) { zval *t_id; struct dazuko_resource *f; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &t_id) == FAILURE) { return; } ZEND_FETCH_RESOURCE(f, struct dazuko_resource *, &t_id, -1, le_dazuko_name, le_dazuko); if (dazukoRemoveAllPaths_TS(f->thread) != 0) { RETURN_FALSE; } f->includepaths = 0; f->excludepaths = 0; RETURN_TRUE; } /* }}} */ /* {{{ proto resource dazuko_thread_get_access(resource t_id) Listen for new events in thread 't_id', return new events as dazuko result resource */ PHP_FUNCTION(dazuko_thread_get_access) { zval *t_id; struct dazuko_resource *f; struct dazuko_event *event; struct dazuko_access *acc; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &t_id) == FAILURE) { return; } ZEND_FETCH_RESOURCE(f, struct dazuko_resource *, &t_id, -1, le_dazuko_name, le_dazuko); if (dazukoGetAccess_TS(f->thread,&acc) == 0) { if (!acc->set_event) return; new_php_dazuko_event(&event, dazuko_event_counter); event->acc = acc; f->lastevent = acc; ZEND_REGISTER_RESOURCE(return_value, event, le_dazuko_obj); } else { return; } } /* }}} */ /* {{{ proto bool dazuko_thread_return_access(resource t_id, resource r_id, long deny_access) Tell the kernel, whether to deny or permit access for thread 't_id' on result 'r_id' If dazuko_thread was registered with 'read/write' permissions, the kernel will wait until dazuko_thread_return_access was called, or the script terminates */ PHP_FUNCTION(dazuko_thread_return_access) { zval *r_id; zval *t_id; struct dazuko_event *event; struct dazuko_resource *f; long deny_access; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrl", &t_id, &r_id, &deny_access) == FAILURE) { return; } ZEND_FETCH_RESOURCE(f, struct dazuko_resource *, &t_id, -1, le_dazuko_name, le_dazuko); ZEND_FETCH_RESOURCE(event, struct dazuko_event *, &r_id, -1, le_dazuko_result, le_dazuko_obj); struct dazuko_access *acc = event->acc; if (deny_access == DAZUKO_DENY) { acc->deny = DAZUKO_DENY; } else { acc->deny = DAZUKO_PERMIT; } if (dazukoReturnAccess_TS(f->thread,&acc) != 0) { RETURN_FALSE; } f->lastaction = deny_access; RETURN_TRUE; } /* }}} */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ http://cvs.php.net/co.php/pecl/dazuko/dazuko.php?r=1.1&p=1 Index: pecl/dazuko/dazuko.php +++ pecl/dazuko/dazuko.php <? if(!extension_loaded('dazuko')) { dl('dazuko.' . PHP_SHLIB_SUFFIX); } $module = 'dazuko'; $functions = get_extension_funcs($module); echo "Functions available in the test extension:<br>\n"; foreach($functions as $func) { echo $func."<br>\n"; } ?> http://cvs.php.net/co.php/pecl/dazuko/package.xml?r=1.1&p=1 Index: pecl/dazuko/package.xml +++ pecl/dazuko/package.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0"> <package version="1.0"> <name>dazuko</name> <summary>Dazuko file-access-control</summary> <description>Dazuko (in german: (Da)tei (Zu)griffs (Ko)ntrolle) file-access-control allows you to communicate with the dazuko-kernel module (See: http://www.dazuko.org for details). It is used to allow or disallow access to a file or directory, based upon the event, the file or directory was accessed. So it is possible to use dazuko to code virus scanners and other security frameworks.</description> <maintainers> <maintainer> <user>areaz2</user> <name>Oliver Welter</name> <email>areaz@dotgeek.org</email> <role>lead</role> </maintainer> </maintainers> <release> <version>0.4</version> <date>2004-09-11</date> <license>PHP</license> <state>beta</state> <notes>Fixed Makefile.frag directory bug</notes> <filelist> <file role="src" name="package.xml"/> <file role="doc" md5sum="15a46cf81285bc139144de7666f7139d" name="CREDITS"/> <file role="doc" md5sum="de2e96bd4a85103a007679494d543254" name="EXPERIMENTAL"/> <file role="src" md5sum="c51eea4346d91a3d9f6e9451fc04b383" name="Makefile.frag"/> <file role="src" md5sum="516987f2bdc0d8548da54826794366b4" name="config.m4"/> <file role="src" md5sum="71c9e5048153d26526a30faa2857cd0e" name="dazuko.c"/> <file role="src" md5sum="c329c980895ff0112d3034ee71831d0c" name="dazuko.php"/> <file role="src" md5sum="38b9366c8c7625ebf5442b715aaf618e" name="php_dazuko.h"/> </filelist> </release> </package> http://cvs.php.net/co.php/pecl/dazuko/php_dazuko.h?r=1.1&p=1 Index: pecl/dazuko/php_dazuko.h +++ pecl/dazuko/php_dazuko.h /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 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/3_0.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: Oliver Welter <areaz@dotgeek.org> | +----------------------------------------------------------------------+ */ /* $Id: php_dazuko.h,v 1.1 2004/09/14 19:51:32 areaz2 Exp $ */ #ifndef PHP_DAZUKO_H #define PHP_DAZUKO_H extern zend_module_entry dazuko_module_entry; #define phpext_dazuko_ptr &dazuko_module_entry #ifdef PHP_WIN32 #define PHP_DAZUKO_API __declspec(dllexport) #else #define PHP_DAZUKO_API #endif #ifdef ZTS #include "TSRM.h" #endif PHP_MINIT_FUNCTION(dazuko); PHP_MSHUTDOWN_FUNCTION(dazuko); PHP_RINIT_FUNCTION(dazuko); PHP_RSHUTDOWN_FUNCTION(dazuko); PHP_MINFO_FUNCTION(dazuko); PHP_FUNCTION(dazuko_module_loaded); PHP_FUNCTION(dazuko_fetch_result); PHP_FUNCTION(dazuko_fetch_thread); PHP_FUNCTION(dazuko_flush_result); PHP_FUNCTION(dazuko_return_access); PHP_FUNCTION(dazuko_get_access); PHP_FUNCTION(dazuko_thread_return_access); PHP_FUNCTION(dazuko_thread_get_access); PHP_FUNCTION(dazuko_register); PHP_FUNCTION(dazuko_unregister); PHP_FUNCTION(dazuko_set_accessmask); PHP_FUNCTION(dazuko_include_path); PHP_FUNCTION(dazuko_exclude_path); PHP_FUNCTION(dazuko_remove_paths); PHP_FUNCTION(dazuko_thread_register); PHP_FUNCTION(dazuko_thread_unregister); PHP_FUNCTION(dazuko_thread_set_accessmask); PHP_FUNCTION(dazuko_thread_include_path); PHP_FUNCTION(dazuko_thread_exclude_path); PHP_FUNCTION(dazuko_thread_remove_paths); #ifdef ZTS #define DAZUKO_G(v) TSRMG(dazuko_globals_id, zend_dazuko_globals *, v) #else #define DAZUKO_G(v) (dazuko_globals.v) #endif #endif /* PHP_DAZUKO_H */ /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */
« previous php.pecl.cvs (#1833) next »