johannes                Tue Nov 20 21:25:10 2007 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/sysvmsg/tests  003.phpt 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/sysvmsg        php_sysvmsg.h sysvmsg.c 
  Log:
  MFH: Add msg_queue_exists() function (Benjamin Schulz) [DOC]
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.48&r2=1.2027.2.547.2.965.2.49&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.48 
php-src/NEWS:1.2027.2.547.2.965.2.49
--- php-src/NEWS:1.2027.2.547.2.965.2.48        Tue Nov 20 09:51:11 2007
+++ php-src/NEWS        Tue Nov 20 21:25:10 2007
@@ -1,6 +1,7 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 20??, PHP 5.3.0
+- Added msg_queue_exists() function (Benjamin Schulz)
 - Added 3 Firebird specific attributes that can be set via PDO::setAttribute()
   to control formatting of date/timestamp columns: PDO::FB_ATTR_DATE_FORMAT,
   PDO::FB_ATTR_TIME_FORMAT and PDO::FB_ATTR_TIMESTAMP_FORMAT. 
http://cvs.php.net/viewvc.cgi/php-src/ext/sysvmsg/php_sysvmsg.h?r1=1.6.2.1.2.2&r2=1.6.2.1.2.2.2.1&diff_format=u
Index: php-src/ext/sysvmsg/php_sysvmsg.h
diff -u php-src/ext/sysvmsg/php_sysvmsg.h:1.6.2.1.2.2 
php-src/ext/sysvmsg/php_sysvmsg.h:1.6.2.1.2.2.2.1
--- php-src/ext/sysvmsg/php_sysvmsg.h:1.6.2.1.2.2       Mon Jan  8 22:34:07 2007
+++ php-src/ext/sysvmsg/php_sysvmsg.h   Tue Nov 20 21:25:10 2007
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_sysvmsg.h,v 1.6.2.1.2.2 2007/01/08 22:34:07 nlopess Exp $ */
+/* $Id: php_sysvmsg.h,v 1.6.2.1.2.2.2.1 2007/11/20 21:25:10 johannes Exp $ */
 
 #ifndef PHP_SYSVMSG_H
 #define PHP_SYSVMSG_H
@@ -48,6 +48,7 @@
 PHP_FUNCTION(msg_set_queue);
 PHP_FUNCTION(msg_send);
 PHP_FUNCTION(msg_receive);
+PHP_FUNCTION(msg_queue_exists);
 
 typedef struct {
        key_t key;
http://cvs.php.net/viewvc.cgi/php-src/ext/sysvmsg/sysvmsg.c?r1=1.20.2.3.2.6.2.1&r2=1.20.2.3.2.6.2.2&diff_format=u
Index: php-src/ext/sysvmsg/sysvmsg.c
diff -u php-src/ext/sysvmsg/sysvmsg.c:1.20.2.3.2.6.2.1 
php-src/ext/sysvmsg/sysvmsg.c:1.20.2.3.2.6.2.2
--- php-src/ext/sysvmsg/sysvmsg.c:1.20.2.3.2.6.2.1      Thu Sep 27 18:00:45 2007
+++ php-src/ext/sysvmsg/sysvmsg.c       Tue Nov 20 21:25:10 2007
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: sysvmsg.c,v 1.20.2.3.2.6.2.1 2007/09/27 18:00:45 dmitry Exp $ */
+/* $Id: sysvmsg.c,v 1.20.2.3.2.6.2.2 2007/11/20 21:25:10 johannes Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -72,6 +72,7 @@
        PHP_FE(msg_remove_queue,                        NULL)
        PHP_FE(msg_stat_queue,                          NULL)
        PHP_FE(msg_set_queue,                           NULL)
+       PHP_FE(msg_queue_exists,                        NULL)
        {NULL, NULL, NULL}      /* Must be the last line in sysvmsg_functions[] 
*/
 };
 /* }}} */
@@ -125,7 +126,7 @@
 {
        php_info_print_table_start();
        php_info_print_table_row(2, "sysvmsg support", "enabled");
-       php_info_print_table_row(2, "Revision", "$Revision: 1.20.2.3.2.6.2.1 
$");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.20.2.3.2.6.2.2 
$");
        php_info_print_table_end();
 }
 /* }}} */
@@ -206,6 +207,26 @@
 }
 /* }}} */
 
+
+/* {{{ proto bool msg_queue_exists(int key)
+   Check wether a message queue exists */
+PHP_FUNCTION(msg_queue_exists)
+{
+       long key;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &key) == 
FAILURE)     {
+               return;
+       }
+
+       if (msgget(key, 0) < 0) {
+               RETURN_FALSE;
+       }
+
+       RETURN_TRUE;
+}
+/* }}} */
+
+
 /* {{{ proto resource msg_get_queue(int key [, int perms])
    Attach to a message queue */
 PHP_FUNCTION(msg_get_queue)

http://cvs.php.net/viewvc.cgi/php-src/ext/sysvmsg/tests/003.phpt?view=markup&rev=1.1
Index: php-src/ext/sysvmsg/tests/003.phpt
+++ php-src/ext/sysvmsg/tests/003.phpt
--TEST--
msg_queue_exists()
--SKIPIF--
<?php if (!extension_loaded("sysvmsg")) die("skip sysvmsg extension is not 
available")?>
--FILE--
<?php
$id = ftok(__FILE__, 'r');

msg_remove_queue(msg_get_queue($id, 0600));

var_dump(msg_queue_exists($id));
$res = msg_get_queue($id, 0600);
var_dump($res);
var_dump(msg_queue_exists($id));
var_dump(msg_remove_queue($res));
var_dump(msg_queue_exists($id));
echo "Done\n";
?>
--EXPECTF--
bool(false)
resource(%d) of type (sysvmsg queue)
bool(true)
bool(true)
bool(false)
Done

Reply via email to