|
|
|
@ -109,7 +109,7 @@ PHP_MINFO_FUNCTION(shmop) |
|
|
|
} |
|
|
|
/* }}} */ |
|
|
|
|
|
|
|
/* {{{ 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 @@ PHP_FUNCTION(shmop_open) |
|
|
|
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 @@ PHP_FUNCTION(shmop_open) |
|
|
|
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 @@ PHP_FUNCTION(shmop_read) |
|
|
|
} |
|
|
|
/* }}} */ |
|
|
|
|
|
|
|
/* {{{ 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 @@ PHP_FUNCTION(shmop_close) |
|
|
|
} |
|
|
|
/* }}} */ |
|
|
|
|
|
|
|
/* {{{ 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 @@ PHP_FUNCTION(shmop_size) |
|
|
|
} |
|
|
|
/* }}} */ |
|
|
|
|
|
|
|
/* {{{ 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 @@ PHP_FUNCTION(shmop_write) |
|
|
|
} |
|
|
|
/* }}} */ |
|
|
|
|
|
|
|
/* {{{ proto bool shmop_delete (int shmid) |
|
|
|
/* {{{ proto bool shmop_delete (int shmid) U |
|
|
|
mark segment for deletion */ |
|
|
|
PHP_FUNCTION(shmop_delete) |
|
|
|
{ |
|
|
|
|