/*
- +----------------------------------------------------------------------+
- | PHP version 4.0 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2003 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 2.02 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available at through the world-wide-web at |
- | http://www.php.net/license/2_02.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. |
- +----------------------------------------------------------------------+
- | Authors: Wez Furlong <wez@thebrainroom.com |
- +----------------------------------------------------------------------+
- */
+ +----------------------------------------------------------------------+
+ | PHP Version 4 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2003 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.02 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available at through the world-wide-web at |
+ | http://www.php.net/license/2_02.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: Wez Furlong <wez@thebrainroom.com> |
+ +----------------------------------------------------------------------+
+*/
+
/* $Id$ */
#ifdef HAVE_CONFIG_H
static int le_sysvmsg;
static unsigned char sixth_arg_force_ref[] = { 6, BYREF_NONE, BYREF_NONE, BYREF_NONE, BYREF_NONE, BYREF_NONE, BYREF_FORCE };
-static unsigned char msg_receive_args_force_ref[] = { 8, BYREF_NONE, BYREF_NONE, BYREF_FORCE,
- BYREF_NONE, BYREF_FORCE, BYREF_NONE, BYREF_NONE, BYREF_FORCE };
+static unsigned char msg_receive_args_force_ref[] = { 8, BYREF_NONE, BYREF_NONE, BYREF_FORCE, BYREF_NONE, BYREF_FORCE, BYREF_NONE, BYREF_NONE, BYREF_FORCE };
/* {{{ sysvmsg_functions[]
*
*/
/* Remove comments and fill if you need to have entries in php.ini
PHP_INI_BEGIN()
- STD_PHP_INI_ENTRY("sysvmsg.value", "42", PHP_INI_ALL, OnUpdateInt, global_value, zend_sysvmsg_globals, sysvmsg_globals)
- STD_PHP_INI_ENTRY("sysvmsg.string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_sysvmsg_globals, sysvmsg_globals)
+ STD_PHP_INI_ENTRY("sysvmsg.value", "42", PHP_INI_ALL, OnUpdateInt, global_value, zend_sysvmsg_globals, sysvmsg_globals)
+ STD_PHP_INI_ENTRY("sysvmsg.string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_sysvmsg_globals, sysvmsg_globals)
PHP_INI_END()
*/
/* }}} */
static void sysvmsg_release(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
- sysvmsg_queue_t * mq = (sysvmsg_queue_t*)rsrc->ptr;
+ sysvmsg_queue_t * mq = (sysvmsg_queue_t *) rsrc->ptr;
efree(mq);
}
{
le_sysvmsg = zend_register_list_destructors_ex(sysvmsg_release, NULL, "sysvmsg queue", module_number);
REGISTER_LONG_CONSTANT("MSG_IPC_NOWAIT", PHP_MSG_IPC_NOWAIT, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("MSG_NOERROR", PHP_MSG_NOERROR, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("MSG_EXCEPT", PHP_MSG_EXCEPT, CONST_PERSISTENT|CONST_CS);
+ REGISTER_LONG_CONSTANT("MSG_NOERROR", PHP_MSG_NOERROR, CONST_PERSISTENT|CONST_CS);
+ REGISTER_LONG_CONSTANT("MSG_EXCEPT", PHP_MSG_EXCEPT, CONST_PERSISTENT|CONST_CS);
return SUCCESS;
}
/* }}} */
PHP_MINFO_FUNCTION(sysvmsg)
{
php_info_print_table_start();
- php_info_print_table_header(2, "sysvmsg support", "enabled");
+ php_info_print_table_row(2, "sysvmsg support", "enabled");
php_info_print_table_row(2, "Revision", "$Revision$");
php_info_print_table_end();
}
RETVAL_FALSE;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra", &queue, &data) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra", &queue, &data) == FAILURE) {
return;
-
+ }
+
ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, &queue, -1, "sysvmsg queue", le_sysvmsg);
if (msgctl(mq->id, IPC_STAT, &stat) == 0) {
zval **item;
/* now pull out members of data and set them in the stat buffer */
- if (zend_hash_find(Z_ARRVAL_P(data), "msg_perm.uid",
- sizeof("msg_perm.uid"), (void**)&item) == SUCCESS) {
+ if (zend_hash_find(Z_ARRVAL_P(data), "msg_perm.uid", sizeof("msg_perm.uid"), (void **) &item) == SUCCESS) {
convert_to_long_ex(item);
stat.msg_perm.uid = Z_LVAL_PP(item);
}
- if (zend_hash_find(Z_ARRVAL_P(data), "msg_perm.gid",
- sizeof("msg_perm.gid"), (void**)&item) == SUCCESS) {
+ if (zend_hash_find(Z_ARRVAL_P(data), "msg_perm.gid", sizeof("msg_perm.gid"), (void **) &item) == SUCCESS) {
convert_to_long_ex(item);
stat.msg_perm.gid = Z_LVAL_PP(item);
}
- if (zend_hash_find(Z_ARRVAL_P(data), "msg_perm.mode",
- sizeof("msg_perm.mode"), (void**)&item) == SUCCESS) {
+ if (zend_hash_find(Z_ARRVAL_P(data), "msg_perm.mode", sizeof("msg_perm.mode"), (void **) &item) == SUCCESS) {
convert_to_long_ex(item);
stat.msg_perm.mode = Z_LVAL_PP(item);
}
- if (zend_hash_find(Z_ARRVAL_P(data), "msg_qbytes",
- sizeof("msg_qbytes"), (void**)&item) == SUCCESS) {
+ if (zend_hash_find(Z_ARRVAL_P(data), "msg_qbytes", sizeof("msg_qbytes"), (void **) &item) == SUCCESS) {
convert_to_long_ex(item);
stat.msg_qbytes = Z_LVAL_PP(item);
}
RETVAL_FALSE;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &queue) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &queue) == FAILURE) {
return;
-
+ }
+
ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, &queue, -1, "sysvmsg queue", le_sysvmsg);
if (msgctl(mq->id, IPC_STAT, &stat) == 0) {
return;
}
- mq = (sysvmsg_queue_t *)emalloc(sizeof(sysvmsg_queue_t));
+ mq = (sysvmsg_queue_t *) emalloc(sizeof(sysvmsg_queue_t));
mq->key = key;
mq->id = msgget(key, 0);
if (mq->id < 0) {
/* doesn't already exist; create it */
- mq->id = msgget(key, IPC_CREAT|IPC_EXCL|perms);
+ mq->id = msgget(key, IPC_CREAT | IPC_EXCL | perms);
if (mq->id < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed for key 0x%x: %s", key, strerror(errno));
efree(mq);
zval *queue;
sysvmsg_queue_t *mq = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &queue) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &queue) == FAILURE) {
return;
-
+ }
+
ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, &queue, -1, "sysvmsg queue", le_sysvmsg);
if (msgctl(mq->id, IPC_RMID, NULL) == 0) {
}
/* }}} */
-/* {{{ proto mixed msg_receive(resource queue, long desiredmsgtype, long &msgtype, long maxsize, mixed message [[, bool unserialize=true][, long flags=0[, long errorcode]]]
+/* {{{ proto mixed msg_receive(resource queue, long desiredmsgtype, long &msgtype, long maxsize, mixed message [, bool unserialize=true [, long flags=0 [, long errorcode]]])
Send a message of type msgtype (must be > 0) to a message queue */
PHP_FUNCTION(msg_receive)
{
RETVAL_FALSE;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlzlz|blz",
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlzlz|blz",
&queue, &desiredmsgtype, &out_msgtype, &maxsize,
- &out_message, &do_unserialize, &flags, &zerrcode) == FAILURE)
+ &out_message, &do_unserialize, &flags, &zerrcode) == FAILURE) {
return;
-
+ }
+
if (flags != 0) {
if (flags & PHP_MSG_EXCEPT) {
#ifndef MSG_EXCEPT
realflags |= MSG_EXCEPT;
#endif
}
- if (flags & PHP_MSG_NOERROR)
+ if (flags & PHP_MSG_NOERROR) {
realflags |= MSG_NOERROR;
- if (flags & PHP_MSG_IPC_NOWAIT)
+ }
+ if (flags & PHP_MSG_IPC_NOWAIT) {
realflags |= IPC_NOWAIT;
+ }
}
ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, &queue, -1, "sysvmsg queue", le_sysvmsg);
- messagebuffer = (struct php_msgbuf*)emalloc(sizeof(struct php_msgbuf) + maxsize);
+ messagebuffer = (struct php_msgbuf *) emalloc(sizeof(struct php_msgbuf) + maxsize);
result = msgrcv(mq->id, messagebuffer, maxsize, desiredmsgtype, realflags);
if (do_unserialize) {
php_unserialize_data_t var_hash;
zval *tmp = NULL;
- const char *p = (const char*)messagebuffer->mtext;
+ const char *p = (const char *) messagebuffer->mtext;
MAKE_STD_ZVAL(tmp);
PHP_VAR_UNSERIALIZE_INIT(var_hash);
}
/* }}} */
-/* {{{ proto bool msg_send(resource queue, long msgtype, mixed message [[, bool serialize=true][, bool blocking=true][, long errorcode]])
+/* {{{ proto bool msg_send(resource queue, long msgtype, mixed message [, bool serialize=true [, bool blocking=true [, long errorcode]]])
Send a message of type msgtype (must be > 0) to a message queue */
PHP_FUNCTION(msg_send)
{
RETVAL_FALSE;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz|bbz",
- &queue, &msgtype, &message, &do_serialize, &blocking, &zerror) == FAILURE)
+ &queue, &msgtype, &message, &do_serialize, &blocking, &zerror) == FAILURE) {
return;
-
+ }
+
ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t*, &queue, -1, "sysvmsg queue", le_sysvmsg);
if (do_serialize) {