summaryrefslogtreecommitdiff
path: root/ext/sysvmsg/sysvmsg.c
diff options
context:
space:
mode:
authorJohannes Schlüter <johannes@php.net>2007-11-20 21:25:10 +0000
committerJohannes Schlüter <johannes@php.net>2007-11-20 21:25:10 +0000
commit611a56fababe4a74297161b1827c13c0a1c67846 (patch)
treef47cd54572915f5815c8987491598fe9c97781e2 /ext/sysvmsg/sysvmsg.c
parente077331077fac8232259d4872008c2c5724f8eab (diff)
downloadphp-git-611a56fababe4a74297161b1827c13c0a1c67846.tar.gz
MFH: Add msg_queue_exists() function (Benjamin Schulz) [DOC]
Diffstat (limited to 'ext/sysvmsg/sysvmsg.c')
-rw-r--r--ext/sysvmsg/sysvmsg.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/ext/sysvmsg/sysvmsg.c b/ext/sysvmsg/sysvmsg.c
index 7ab5b387f2..778f275ccc 100644
--- a/ext/sysvmsg/sysvmsg.c
+++ b/ext/sysvmsg/sysvmsg.c
@@ -72,6 +72,7 @@ const zend_function_entry sysvmsg_functions[] = {
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[] */
};
/* }}} */
@@ -206,6 +207,26 @@ PHP_FUNCTION(msg_stat_queue)
}
/* }}} */
+
+/* {{{ 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)