iliaa Sat Oct 7 18:45:44 2006 UTC Modified files: /php-src/ext/shmop shmop.c /php-src/ext/shmop/tests 001.phpt Log: Initial Unicode support http://cvs.php.net/viewvc.cgi/php-src/ext/shmop/shmop.c?r1=1.33&r2=1.34&diff_format=u Index: php-src/ext/shmop/shmop.c diff -u php-src/ext/shmop/shmop.c:1.33 php-src/ext/shmop/shmop.c:1.34 --- php-src/ext/shmop/shmop.c:1.33 Sun Jan 1 13:09:53 2006 +++ php-src/ext/shmop/shmop.c Sat Oct 7 18:45:43 2006 @@ -16,7 +16,7 @@ | Ilia Alshanetsky <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: shmop.c,v 1.33 2006/01/01 13:09:53 sniper Exp $ */ +/* $Id: shmop.c,v 1.34 2006/10/07 18:45:43 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -109,7 +109,7 @@ } /* }}} */ -/* {{{ proto int shmop_open (int key, string flags, int mode, int size) +/* {{{ proto int shmop_open (int key, string flags, int mode, int size) U gets and attaches a shared memory segment */ PHP_FUNCTION(shmop_open) { @@ -119,12 +119,24 @@ int rsid; char *flags; int flags_len; + zend_uchar flag_type; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lsll", &key, &flags, &flags_len, &mode, &size) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ltll", &key, &flags, &flags_len, &flag_type, &mode, &size) == FAILURE) { WRONG_PARAM_COUNT; } + if (flag_type == IS_UNICODE) { + flags = zend_unicode_to_ascii((UChar*)flags, flags_len); + if (!flags) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Binary or ASCII-Unicode string expected, non-ASCII-Unicode string received"); + RETURN_FALSE; + } + } + if (flags_len != 1) { + if (flag_type == IS_UNICODE) { + efree(flags); + } php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s is not a valid flag", flags); RETURN_FALSE; } @@ -179,14 +191,20 @@ shmop->size = shm.shm_segsz; rsid = zend_list_insert(shmop, shm_type); + if (flag_type == IS_UNICODE) { + efree(flags); + } RETURN_LONG(rsid); err: + if (flag_type == IS_UNICODE) { + efree(flags); + } efree(shmop); RETURN_FALSE; } /* }}} */ -/* {{{ proto string shmop_read (int shmid, int start, int count) +/* {{{ proto string shmop_read (int shmid, int start, int count) U reads from a shm segment */ PHP_FUNCTION(shmop_read) { @@ -229,7 +247,7 @@ } /* }}} */ -/* {{{ proto void shmop_close (int shmid) +/* {{{ proto void shmop_close (int shmid) U closes a shared memory segment */ PHP_FUNCTION(shmop_close) { @@ -252,7 +270,7 @@ } /* }}} */ -/* {{{ proto int shmop_size (int shmid) +/* {{{ proto int shmop_size (int shmid) U returns the shm size */ PHP_FUNCTION(shmop_size) { @@ -275,18 +293,18 @@ } /* }}} */ -/* {{{ proto int shmop_write (int shmid, string data, int offset) +/* {{{ proto int shmop_write (int shmid, string data, int offset) U writes to a shared memory segment */ PHP_FUNCTION(shmop_write) { struct php_shmop *shmop; int type; int writesize; - long shmid, offset; + long shmid, offset=0; char *data; int data_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lsl", &shmid, &data, &data_len, &offset) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lS|l", &shmid, &data, &data_len, &offset) == FAILURE) { WRONG_PARAM_COUNT; } @@ -314,7 +332,7 @@ } /* }}} */ -/* {{{ proto bool shmop_delete (int shmid) +/* {{{ proto bool shmop_delete (int shmid) U mark segment for deletion */ PHP_FUNCTION(shmop_delete) { http://cvs.php.net/viewvc.cgi/php-src/ext/shmop/tests/001.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/shmop/tests/001.phpt diff -u php-src/ext/shmop/tests/001.phpt:1.2 php-src/ext/shmop/tests/001.phpt:1.3 --- php-src/ext/shmop/tests/001.phpt:1.2 Thu Dec 16 12:34:31 2004 +++ php-src/ext/shmop/tests/001.phpt Sat Oct 7 18:45:44 2006 @@ -9,8 +9,8 @@ --FILE-- <?php $hex_shm_id = 0xff3; - $write_d1 = "test #1 of the shmop() extension"; - $write_d2 = "test #2 append data to shared memory segment"; + $write_d1 = b"test #1 of the shmop() extension"; + $write_d2 = b"test #2 append data to shared memory segment"; echo "shm open for create: "; $shm_id = shmop_open($hex_shm_id, "n", 0644, 1024);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php