]> granicus.if.org Git - php/commitdiff
WS & CS fixes
authorfoobar <sniper@php.net>
Fri, 7 Mar 2003 01:03:04 +0000 (01:03 +0000)
committerfoobar <sniper@php.net>
Fri, 7 Mar 2003 01:03:04 +0000 (01:03 +0000)
ext/sysvmsg/php_sysvmsg.h
ext/sysvmsg/sysvmsg.c

index ca72f0a3fc397a5569f7731650634b1f37428fda..1b13955bb1e221e4fca480588dea8da4df711f5a 100644 (file)
@@ -1,20 +1,22 @@
 /*
-   +----------------------------------------------------------------------+
-   | PHP version 4.0                                                      |
-   +----------------------------------------------------------------------+
-   | Copyright (c) 1997, 1998, 1999, 2000, 2001 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$ */
 
 #ifndef PHP_SYSVMSG_H
 #define PHP_SYSVMSG_H
index a198b430db38b8ce35ae697cebed71ed51350b6f..a29944b828e4377826ec3e0e1f3db86e3f8b39b3 100644 (file)
@@ -1,20 +1,21 @@
 /*
-   +----------------------------------------------------------------------+
-   | 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
@@ -40,8 +41,7 @@
 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[]
  *
@@ -82,15 +82,15 @@ ZEND_GET_MODULE(sysvmsg)
  */
 /* 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);
 }
 
@@ -100,8 +100,8 @@ PHP_MINIT_FUNCTION(sysvmsg)
 {
        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;
 }
 /* }}} */
@@ -119,7 +119,7 @@ PHP_MSHUTDOWN_FUNCTION(sysvmsg)
 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();
 }
@@ -135,32 +135,29 @@ PHP_FUNCTION(msg_set_queue)
                        
        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);
                }
@@ -181,9 +178,10 @@ PHP_FUNCTION(msg_stat_queue)
        
        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) {
@@ -215,13 +213,13 @@ PHP_FUNCTION(msg_get_queue)
                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);
@@ -239,9 +237,10 @@ PHP_FUNCTION(msg_remove_queue)
        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) {
@@ -252,7 +251,7 @@ PHP_FUNCTION(msg_remove_queue)
 }
 /* }}} */
 
-/* {{{ 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)
 {
@@ -266,11 +265,12 @@ 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
@@ -280,15 +280,17 @@ PHP_FUNCTION(msg_receive)
                        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);
                
@@ -309,7 +311,7 @@ PHP_FUNCTION(msg_receive)
                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);
@@ -331,7 +333,7 @@ PHP_FUNCTION(msg_receive)
 }
 /* }}} */
 
-/* {{{ 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)
 {
@@ -346,9 +348,10 @@ 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) {