johannes                Tue Nov 20 21:24:35 2007 UTC

  Added files:                 
    /php-src/ext/sysvmsg/tests  003.phpt 

  Modified files:              
    /php-src/ext/sysvmsg        php_sysvmsg.h sysvmsg.c 
  Log:
  Add msg_queue_exists() function (Benjamin Schulz)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/sysvmsg/php_sysvmsg.h?r1=1.9&r2=1.10&diff_format=u
Index: php-src/ext/sysvmsg/php_sysvmsg.h
diff -u php-src/ext/sysvmsg/php_sysvmsg.h:1.9 
php-src/ext/sysvmsg/php_sysvmsg.h:1.10
--- php-src/ext/sysvmsg/php_sysvmsg.h:1.9       Mon Jan  8 22:35:25 2007
+++ php-src/ext/sysvmsg/php_sysvmsg.h   Tue Nov 20 21:24:34 2007
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_sysvmsg.h,v 1.9 2007/01/08 22:35:25 nlopess Exp $ */
+/* $Id: php_sysvmsg.h,v 1.10 2007/11/20 21:24:34 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.32&r2=1.33&diff_format=u
Index: php-src/ext/sysvmsg/sysvmsg.c
diff -u php-src/ext/sysvmsg/sysvmsg.c:1.32 php-src/ext/sysvmsg/sysvmsg.c:1.33
--- php-src/ext/sysvmsg/sysvmsg.c:1.32  Thu Sep 27 18:28:42 2007
+++ php-src/ext/sysvmsg/sysvmsg.c       Tue Nov 20 21:24:34 2007
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: sysvmsg.c,v 1.32 2007/09/27 18:28:42 dmitry Exp $ */
+/* $Id: sysvmsg.c,v 1.33 2007/11/20 21:24:34 johannes Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -73,6 +73,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[] 
*/
 };
 /* }}} */
@@ -136,7 +137,7 @@
 {
        php_info_print_table_start();
        php_info_print_table_row(2, "sysvmsg support", "enabled");
-       php_info_print_table_row(2, "Revision", "$Revision: 1.32 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.33 $");
        php_info_print_table_end();
 }
 /* }}} */
@@ -217,6 +218,24 @@
 }
 /* }}} */
 
+/* {{{ 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]) U
    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

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to