wez Tue Sep 10 09:04:08 2002 EDT
Modified files:
/php4/ext/sysvmsg config.m4 sysvmsg.c
Log:
Patch for BSD-ish systems from Melvyn Sopacua <[EMAIL PROTECTED]>,
slightly modified.
Index: php4/ext/sysvmsg/config.m4
diff -u php4/ext/sysvmsg/config.m4:1.1 php4/ext/sysvmsg/config.m4:1.2
--- php4/ext/sysvmsg/config.m4:1.1 Thu Apr 25 19:14:43 2002
+++ php4/ext/sysvmsg/config.m4 Tue Sep 10 09:04:07 2002
@@ -1,9 +1,35 @@
-dnl $Id: config.m4,v 1.1 2002/04/25 23:14:43 wez Exp $
+dnl $Id: config.m4,v 1.2 2002/09/10 13:04:07 wez Exp $
PHP_ARG_ENABLE(sysvmsg,whether to enable System V IPC support,
[ --enable-sysvmsg Enable sysvmsg support])
if test "$PHP_SYSVMSG" != "no"; then
+ AC_MSG_CHECKING([whether sys/msg.h defines struct msgbuf or mymsg])
+ AC_TRY_COMPILE(
+ [#include <sys/types.h>
+ #include <sys/ipc.h>
+ #include <sys/msg.h>],
+ [struct msgbuf *foo;
+
+ foo = (struct msgbuf *) malloc(sizeof(struct msgbuf) +1);
+ return 1;],
+ [AC_MSG_RESULT(msgbuf)],
+ [AC_TRY_COMPILE(
+ [#include <sys/types.h>
+ #include <sys/ipc.h>
+ #include <sys/msg.h>
+ ],
+ [struct mymsg *foo;
+
+ foo = (struct mymsg *) malloc(sizeof(struct mymsg) +1);
+ return 1;
+ ],
+ [AC_DEFINE(msgbuf, mymsg, [msgbuf is called mymsg])
+ AC_MSG_RESULT(mymsg)
+ ],
+ [AC_MSG_ERROR([none. Cannot make sysvmsg module])
+ ])
+ ])
AC_DEFINE(HAVE_SYSVMSG, 1, [ ])
PHP_NEW_EXTENSION(sysvmsg, sysvmsg.c, $ext_shared)
fi
Index: php4/ext/sysvmsg/sysvmsg.c
diff -u php4/ext/sysvmsg/sysvmsg.c:1.2 php4/ext/sysvmsg/sysvmsg.c:1.3
--- php4/ext/sysvmsg/sysvmsg.c:1.2 Mon Apr 29 08:52:34 2002
+++ php4/ext/sysvmsg/sysvmsg.c Tue Sep 10 09:04:08 2002
@@ -15,7 +15,7 @@
| Authors: Wez Furlong <[EMAIL PROTECTED] |
+----------------------------------------------------------------------+
*/
-/* $Id: sysvmsg.c,v 1.2 2002/04/29 12:52:34 wez Exp $ */
+/* $Id: sysvmsg.c,v 1.3 2002/09/10 13:04:08 wez Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -29,6 +29,13 @@
#include "ext/standard/php_var.h"
#include "ext/standard/php_smart_str.h"
+/* In order to detect MSG_EXCEPT use at run time; we have no way
+ * of knowing what the bit definitions are, so we can't just define
+ * out own MSG_EXCEPT value. */
+#define PHP_MSG_IPC_NOWAIT 1
+#define PHP_MSG_NOERROR 2
+#define PHP_MSG_EXCEPT 4
+
/* True global resources - no need for thread safety here */
static int le_sysvmsg;
@@ -92,9 +99,9 @@
PHP_MINIT_FUNCTION(sysvmsg)
{
le_sysvmsg = zend_register_list_destructors_ex(sysvmsg_release, NULL, "sysvmsg
queue", module_number);
- REGISTER_LONG_CONSTANT("MSG_IPC_NOWAIT", IPC_NOWAIT,
CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("MSG_NOERROR", MSG_NOERROR, CONST_PERSISTENT|CONST_CS);
- REGISTER_LONG_CONSTANT("MSG_EXCEPT", MSG_EXCEPT, CONST_PERSISTENT|CONST_CS);
+ 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);
return SUCCESS;
}
/* }}} */
@@ -113,7 +120,7 @@
{
php_info_print_table_start();
php_info_print_table_header(2, "sysvmsg support", "enabled");
- php_info_print_table_row(2, "Revision", "$Revision: 1.2 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 1.3 $");
php_info_print_table_end();
}
/* }}} */
@@ -252,6 +259,7 @@
{
zval *out_message, *queue, *out_msgtype, *zerrcode = NULL;
long desiredmsgtype, maxsize, flags = 0;
+ long realflags = 0;
zend_bool do_unserialize = 1;
sysvmsg_queue_t *mq = NULL;
struct msgbuf *messagebuffer = NULL; /* buffer to transmit */
@@ -264,11 +272,26 @@
&out_message, &do_unserialize, &flags, &zerrcode) ==
FAILURE)
return;
+ if (flags != 0) {
+ if (flags & PHP_MSG_EXCEPT) {
+#ifndef MSG_EXCEPT
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "MSG_EXCEPT is not
+supported on your system");
+ RETURN_FALSE;
+#else
+ realflags |= MSG_EXCEPT;
+#endif
+ }
+ if (flags & PHP_MSG_NOERROR)
+ realflags |= MSG_NOERROR;
+ if (flags & PHP_MSG_IPC_NOWAIT)
+ realflags |= IPC_NOWAIT;
+ }
+
ZEND_FETCH_RESOURCE(mq, sysvmsg_queue_t *, &queue, -1, "sysvmsg queue",
le_sysvmsg);
messagebuffer = (struct msgbuf*)emalloc(sizeof(struct msgbuf) + maxsize);
- result = msgrcv(mq->id, messagebuffer, maxsize, desiredmsgtype, flags);
+ result = msgrcv(mq->id, messagebuffer, maxsize, desiredmsgtype, realflags);
zval_dtor(out_msgtype);
zval_dtor(out_message);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php