Skip to content
Browse files

Big rename: change extension name from zeromq to zmq and all classes …

…from ZeroMQ* to ZMQ
  • Loading branch information...
1 parent aecf5bf commit 2826eafb6ec328125b7b72eafb2d2eb83d61ca92 Mikko Koppanen committed Apr 11, 2010
View
4 README
@@ -1,11 +1,11 @@
-Experimental PHP bindings for ZeroMQ.
+Experimental PHP bindings for 0MQ.
The API is roughly as follows:
<?php
/* Create new queue object */
-$queue = new ZeroMQ(ZeroMQ::SOCKET_REQ, "MySock1");
+$queue = new ZMQ(ZMQ::SOCKET_REQ, "MySock1");
/* Connect to an endpoint */
$queue->connect("tcp://127.0.0.1:5555");
View
58 api.php
@@ -1,7 +1,7 @@
<pre><code>
<?php
-class ZeroMQ {
+class ZMQ {
/**
* Peer to peer socket
@@ -143,8 +143,8 @@ class ZeroMQ {
const POLL_OUT = 2;
/**
- * Construct a new ZeroMQ object. The extending class must call this method.
- * The type is one of the ZeroMQ::SOCKET_* constants.
+ * Construct a new ZMQ object. The extending class must call this method.
+ * The type is one of the ZMQ::SOCKET_* constants.
* Persistent id allows reusing the socket over multiple requests.
* If persistent_id parameter is specific the type parameter is ignored and the
* socket is of type that it was initially created with. Persistent context must
@@ -154,7 +154,7 @@ class ZeroMQ {
* @param integer $type The type of the socket
* @param string $persistent_id The persistent id. Can be used to create
* persistent connections
- * @throws ZeroMQException
+ * @throws ZMQException
* @return void
*/
public function __construct($type, $persistent_id = null) {}
@@ -164,17 +164,17 @@ public function __construct($type, $persistent_id = null) {}
*
* @param string $message The message to send
* @param integer $flags self::MODE_NOBLOCK or 0
- * @throws ZeroMQException if sending message fails
+ * @throws ZMQException if sending message fails
*
- * @return ZeroMQ
+ * @return ZMQ
*/
public function send($message, $flags = 0) {}
/**
* Receives a message from the queue.
*
* @param integer $flags self::MODE_NOBLOCK or 0
- * @throws ZeroMQException if receiving fails.
+ * @throws ZMQException if receiving fails.
*
* @return string
*/
@@ -188,8 +188,8 @@ public function recv($flags = 0) {}
* @param string $dsn The connect dsn
* @param boolean $force Tries to connect to end-point even if the object is already connected to the $dsn
*
- * @throws ZeroMQException If connection fails
- * @return ZeroMQ
+ * @throws ZMQException If connection fails
+ * @return ZMQ
*/
public function connect($dsn, $force = false) {}
@@ -202,8 +202,8 @@ public function connect($dsn, $force = false) {}
* @param string $dsn The bind dsn
* @param boolean $force Tries to bind to end-point even if the object is already bound to the $dsn
*
- * @throws ZeroMQException if binding fails
- * @return ZeroMQ
+ * @throws ZMQException if binding fails
+ * @return ZMQ
*/
public function bind($dsn, $force = false) {}
@@ -214,18 +214,18 @@ public function bind($dsn, $force = false) {}
* @param integer $key The option key
* @param mixed $value The option value
*
- * @throws ZeroMQException
- * @return ZeroMQ
+ * @throws ZMQException
+ * @return ZMQ
*/
public function setSockOpt($key, $value) {}
/**
- * Gets a socket option. This method is available if ZeroMQ extension
- * has been compiled against ZeroMQ version 2.0.7 or higher
+ * Gets a socket option. This method is available if ZMQ extension
+ * has been compiled against ZMQ version 2.0.7 or higher
*
* @param integer $key The option key
*
- * @throws ZeroMQException
+ * @throws ZMQException
* @return mixed
*/
public function getSockOpt($key) {}
@@ -235,15 +235,15 @@ public function getSockOpt($key) {}
* set before connect / bind / setSockOpt is called. For persistent objects
* it is on the first instanciation.
*
- * $poll must be true if the object is going to be added into ZeroMQPoll.
+ * $poll must be true if the object is going to be added into ZMQPoll.
*
*
* @param integer $app_threads How many application threads
* @param integer $io_threads How many io threads
* @param boolean $poll Whether to support polling
*
- * @throws ZeroMQException if the socket has been initialized already
- * @return ZeroMQ
+ * @throws ZMQException if the socket has been initialized already
+ * @return ZMQ
*/
public function setContextOptions($app_threads, $io_threads, $poll = false) {}
@@ -259,33 +259,33 @@ public function getContextOptions() {}
* Get endpoints where the socket is connected to. The return array
* contains two sub-arrays: 'connect' and 'bind'
*
- * @throws ZeroMQException
+ * @throws ZMQException
* @return array
*/
public function getEndpoints() {}
/**
- * Return the socket type. Returns one of ZeroMQ::SOCKET_* constants
+ * Return the socket type. Returns one of ZMQ::SOCKET_* constants
*
- * @throws ZeroMQException
+ * @throws ZMQException
* @return integer
*/
public function getSocketType() {}
}
-class ZeroMQPoll {
+class ZMQPoll {
/**
* Add a new object into the poll set
*
- * @param ZeroMQ $object Object to add to set
- * @param integer $type Bit-mask of ZeroMQ::POLL_* constants
+ * @param ZMQ $object Object to add to set
+ * @param integer $type Bit-mask of ZMQ::POLL_* constants
*
- * @throws ZeroMQPollException if the object has not been initialized with polling
- * @return ZeroMQPoll
+ * @throws ZMQPollException if the object has not been initialized with polling
+ * @return ZMQPoll
*/
- public function add(ZeroMQ $object, $type) {}
+ public function add(ZMQ $object, $type) {}
/**
* Execute the poll. Readable and writable sockets are returned
@@ -297,7 +297,7 @@ public function add(ZeroMQ $object, $type) {}
* @param array &$writable array where to return the writable objects
* @param integer $timeout Timeout for poll in milliseconds. -1 polls as long as one of the objects comes readable/writable
*
- * @throws ZeroMQPollException if polling fails
+ * @throws ZMQPollException if polling fails
* @return integer
*/
public function poll(array &$readable, array &$writable, $timeout = -1) {}
View
28 config.m4
@@ -1,7 +1,7 @@
-PHP_ARG_WITH(zeromq, whether to enable ZeroMQ support,
-[ --with-zeromq[=DIR] Enable Zero Message Queue support. DIR is the prefix to libzmq installation directory.], yes)
+PHP_ARG_WITH(zmq, whether to enable 0MQ support,
+[ --with-zmq[=DIR] Enable 0MQ support. DIR is the prefix to libzmq installation directory.], yes)
-if test "$PHP_ZEROMQ" != "no"; then
+if test "$PHP_ZMQ" != "no"; then
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test "x$PKG_CONFIG" = "xno"; then
@@ -12,25 +12,25 @@ if test "$PHP_ZEROMQ" != "no"; then
ORIG_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
AC_MSG_CHECKING(libzmq installation)
- if test "x$PHP_ZEROMQ" = "xyes"; then
+ if test "x$PHP_ZMQ" = "xyes"; then
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/opt/lib/pkgconfig:/opt/local/lib/pkgconfig
else
- export PKG_CONFIG_PATH=$PHP_ZEROMQ:$PHP_ZEROMQ/lib/pkgconfig
+ export PKG_CONFIG_PATH=$PHP_ZMQ:$PHP_ZMQ/lib/pkgconfig
fi
if $PKG_CONFIG --exists libzmq; then
AC_MSG_RESULT([found])
- PHP_ZEROMQ_LIBS=`$PKG_CONFIG libzmq --libs`
- PHP_ZEROMQ_INCS=`$PKG_CONFIG libzmq --cflags`
+ PHP_ZMQ_LIBS=`$PKG_CONFIG libzmq --libs`
+ PHP_ZMQ_INCS=`$PKG_CONFIG libzmq --cflags`
- PHP_EVAL_LIBLINE($PHP_ZEROMQ_LIBS, ZEROMQ_SHARED_LIBADD)
- PHP_EVAL_INCLINE($PHP_ZEROMQ_INCS)
+ PHP_EVAL_LIBLINE($PHP_ZMQ_LIBS, ZMQ_SHARED_LIBADD)
+ PHP_EVAL_INCLINE($PHP_ZMQ_INCS)
else
AC_MSG_ERROR(Unable to find libzmq installation)
fi
- AC_CHECK_HEADERS([stdint.h],[php_zeromq_have_stdint=yes; break;])
- if test $php_zeromq_have_stdint != "yes"; then
+ AC_CHECK_HEADERS([stdint.h],[php_zmq_have_stdint=yes; break;])
+ if test $php_zmq_have_stdint != "yes"; then
AC_MSG_ERROR(Unable to find stdint.h)
fi
@@ -39,11 +39,11 @@ if test "$PHP_ZEROMQ" != "no"; then
],[
AC_MSG_RESULT(WARNING: libzmq version 2.0.7 or higher is highly recommended)
],[
- ZEROMQ_SHARED_LIBADD -lzmq
+ ZMQ_SHARED_LIBADD -lzmq
])
- PHP_SUBST(ZEROMQ_SHARED_LIBADD)
- PHP_NEW_EXTENSION(zeromq, zeromq.c, $ext_shared)
+ PHP_SUBST(ZMQ_SHARED_LIBADD)
+ PHP_NEW_EXTENSION(zmq, zmq.c, $ext_shared)
PKG_CONFIG_PATH="$ORIG_PKG_CONFIG_PATH"
fi
View
2 examples/client.php
@@ -6,7 +6,7 @@
*/
/* Create new queue object */
-$queue = new ZeroMQ(ZeroMQ::SOCKET_REQ, "MySock1");
+$queue = new ZMQ(ZMQ::SOCKET_REQ, "MySock1");
$queue->connect("tcp://127.0.0.1:5555");
/* Assign socket 1 to the queue, send and receive */
View
6 examples/poll-server.php
@@ -1,13 +1,13 @@
<?php
/* Create socket, request-reply pattern (reply socket) */
-$server = new ZeroMQ(ZeroMQ::SOCKET_REP);
+$server = new ZMQ(ZMQ::SOCKET_REP);
$server->setContextOptions(1, 1, true)
->bind("tcp://127.0.0.1:5555");
/* Create new pollset for incoming message */
-$poll = new ZeroMQPoll();
-$poll->add($server, ZeroMQ::POLL_IN | ZeroMQ::POLL_OUT);
+$poll = new ZMQPoll();
+$poll->add($server, ZMQ::POLL_IN | ZMQ::POLL_OUT);
/* Initialise readable and writable arrays */
$readable = array();
View
2 examples/simple-server.php
@@ -4,7 +4,7 @@
The server waits for messages from the client
and echoes back the received message
*/
-$server = new ZeroMQ(ZeroMQ::SOCKET_REP);
+$server = new ZMQ(ZMQ::SOCKET_REP);
$server->bind("tcp://127.0.0.1:5555");
/* Loop receiving and echoing back */
View
18 package.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<package packagerversion="1.4.9" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
- <name>zeromq</name>
- <uri>http://github.com/mkoppanen/php-zeromq</uri>
- <summary>ZeroMQ for PHP</summary>
+ <name>zmq</name>
+ <uri>http://github.com/mkoppanen/php-zmq</uri>
+ <summary>0MQ for PHP</summary>
<description>PHP extension for 0MQ messaging system</description>
<lead>
<name>Mikko Koppanen</name>
@@ -26,23 +26,23 @@
<dir name="/">
<!-- Support files -->
<file name="config.m4" role="src" />
- <file name="zeromq.spec" role="src">
+ <file name="zmq.spec" role="src">
<tasks:replace from="@PACKAGE_VERSION@" to="version" type="package-info" />
</file>
<!-- Headers -->
- <file name="php_zeromq.h" role="src">
+ <file name="php_zmq.h" role="src">
<tasks:replace from="@PACKAGE_VERSION@" to="version" type="package-info" />
</file>
- <file name="php_zeromq_private.h" role="src" />
+ <file name="php_zmq_private.h" role="src" />
<!-- Source files -->
- <file name="zeromq.c" role="src" />
+ <file name="zmq.c" role="src" />
<!-- misc files -->
<file name="README" role="doc" />
<file name="LICENSE" role="doc" />
- <file name="zeromq.spec" role="doc">
+ <file name="zmq.spec" role="doc">
<tasks:replace from="@PACKAGE_VERSION@" to="version" type="package-info" />
</file>
</dir>
@@ -57,6 +57,6 @@
</pearinstaller>
</required>
</dependencies>
- <providesextension>zeromq</providesextension>
+ <providesextension>zmq</providesextension>
<extsrcrelease />
</package>
View
16 php_zeromq.h → php_zmq.h
@@ -1,6 +1,6 @@
/*
+-----------------------------------------------------------------------------------+
-| ZeroMQ extension for PHP |
+| ZMQ extension for PHP |
| Copyright (c) 2010, Mikko Koppanen <mkoppanen@php.net> |
| All rights reserved. |
+-----------------------------------------------------------------------------------+
@@ -28,11 +28,11 @@
+-----------------------------------------------------------------------------------+
*/
-#ifndef _PHP_ZEROMQ_H_
-# define _PHP_ZEROMQ_H_
+#ifndef _PHP_ZMQ_H_
+# define _PHP_ZMQ_H_
-#define PHP_ZEROMQ_EXTNAME "zeromq"
-#define PHP_ZEROMQ_EXTVER "@PACKAGE_VERSION@"
+#define PHP_ZMQ_EXTNAME "zmq"
+#define PHP_ZMQ_EXTVER "@PACKAGE_VERSION@"
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -44,7 +44,7 @@
#include "php.h"
-extern zend_module_entry zeromq_module_entry;
-#define phpext_zeromq_ptr &zeromq_module_entry
+extern zend_module_entry zmq_module_entry;
+#define phpext_zmq_ptr &zmq_module_entry
-#endif /* _PHP_ZEROMQ_H_ */
+#endif /* _PHP_ZMQ_H_ */
View
78 php_zeromq_private.h → php_zmq_private.h
@@ -1,6 +1,6 @@
/*
+-----------------------------------------------------------------------------------+
-| ZeroMQ extension for PHP |
+| ZMQ extension for PHP |
| Copyright (c) 2010, Mikko Koppanen <mkoppanen@php.net> |
| All rights reserved. |
+-----------------------------------------------------------------------------------+
@@ -28,8 +28,8 @@
+-----------------------------------------------------------------------------------+
*/
-#ifndef _PHP_ZEROMQ_PRIVATE_H_
-# define _PHP_ZEROMQ_PRIVATE_H_
+#ifndef _PHP_ZMQ_PRIVATE_H_
+# define _PHP_ZMQ_PRIVATE_H_
#include "ext/standard/info.h"
#include "Zend/zend_exceptions.h"
@@ -38,87 +38,87 @@
#include <stdint.h>
#include <zmq.h>
-/* {{{ typedef struct _php_zeromq_context_opts */
-typedef struct _php_zeromq_context_opts {
+/* {{{ typedef struct _php_zmq_context_opts */
+typedef struct _php_zmq_context_opts {
zend_bool is_persistent;
int app_threads;
int io_threads;
zend_bool poll;
-} php_zeromq_context_opts;
+} php_zmq_context_opts;
/* }}}*/
-/* {{{ typedef struct _php_zeromq_context */
-typedef struct _php_zeromq_context {
+/* {{{ typedef struct _php_zmq_context */
+typedef struct _php_zmq_context {
void *context;
- php_zeromq_context_opts opts;
-} php_zeromq_context;
+ php_zmq_context_opts opts;
+} php_zmq_context;
/* }}} */
-/* {{{ typedef struct _php_zeromq_socket_opts */
-typedef struct _php_zeromq_socket_opts {
+/* {{{ typedef struct _php_zmq_socket_opts */
+typedef struct _php_zmq_socket_opts {
zend_bool is_persistent;
int type;
char *p_id;
-} php_zeromq_socket_opts;
+} php_zmq_socket_opts;
/* }}} */
-/* {{{ typedef struct _php_zeromq_socket */
-typedef struct _php_zeromq_socket {
+/* {{{ typedef struct _php_zmq_socket */
+typedef struct _php_zmq_socket {
void *socket;
- php_zeromq_context *ctx;
+ php_zmq_context *ctx;
HashTable connect;
HashTable bind;
- php_zeromq_socket_opts opts;
-} php_zeromq_socket;
+ php_zmq_socket_opts opts;
+} php_zmq_socket;
/* }}} */
-/* {{{ typedef struct _php_zeromq_object */
-typedef struct _php_zeromq_object {
+/* {{{ typedef struct _php_zmq_object */
+typedef struct _php_zmq_object {
zend_object zo;
- php_zeromq_socket *zms;
+ php_zmq_socket *zms;
/* options for the context */
- php_zeromq_context_opts ctx_opts;
+ php_zmq_context_opts ctx_opts;
/* The socket options */
- php_zeromq_socket_opts socket_opts;
-} php_zeromq_object;
+ php_zmq_socket_opts socket_opts;
+} php_zmq_object;
/* }}} */
-/* {{{ typedef struct _php_zeromq_poll_object */
-typedef struct _php_zeromq_poll_object {
+/* {{{ typedef struct _php_zmq_poll_object */
+typedef struct _php_zmq_poll_object {
zend_object zo;
zmq_pollitem_t *items;
int num_items;
zval **objects;
-} php_zeromq_poll_object;
+} php_zmq_poll_object;
/* }}} */
-ZEND_BEGIN_MODULE_GLOBALS(zeromq)
+ZEND_BEGIN_MODULE_GLOBALS(php_zmq)
zend_bool persist_context;
-ZEND_END_MODULE_GLOBALS(zeromq)
+ZEND_END_MODULE_GLOBALS(php_zmq)
-ZEND_EXTERN_MODULE_GLOBALS(zeromq);
+ZEND_EXTERN_MODULE_GLOBALS(php_zmq);
#ifdef ZTS
-# define ZEROMQ_G(v) TSRMG(zeromq_globals_id, zend_zeromq_globals *, v)
+# define ZMQ_G(v) TSRMG(php_zmq_globals_id, zend_php_zmq_globals *, v)
#else
-# define ZEROMQ_G(v) (zeromq_globals.v)
+# define ZMQ_G(v) (php_zmq_globals.v)
#endif
-#define PHP_ZEROMQ_OBJECT (php_zeromq_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+#define PHP_ZMQ_OBJECT (php_zmq_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
-#define PHP_ZEROMQ_POLL_OBJECT (php_zeromq_poll_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+#define PHP_ZMQ_POLL_OBJECT (php_zmq_poll_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
-#define ZEROMQ_RETURN_THIS RETURN_ZVAL(getThis(), 1, 0);
+#define ZMQ_RETURN_THIS RETURN_ZVAL(getThis(), 1, 0);
-#ifdef _DEBUG_ZEROMQ_
-# define php_zeromq_printf(...) fprintf (stderr, __VA_ARGS__)
+#ifdef _DEBUG_ZMQ_
+# define php_zmq_printf(...) fprintf (stderr, __VA_ARGS__)
#else
-# define php_zeromq_printf(...)
+# define php_zmq_printf(...)
#endif
-#endif /* _PHP_ZEROMQ_PRIVATE_H_ */
+#endif /* _PHP_ZMQ_PRIVATE_H_ */
View
6 tests/003-contextoptions.phpt
@@ -7,12 +7,12 @@ set/get context options
include dirname(__FILE__) . '/zeromq_test_helper.inc';
-$test = new ZeroMQ(ZeroMQ::SOCKET_REQ);
+$test = new ZMQ(ZMQ::SOCKET_REQ);
$test->setContextOptions(2, 2, true);
try {
$test->setContextOptions(-1, -1);
-} catch (ZeroMQException $e) {
+} catch (ZMQException $e) {
echo "incorrect args\n";
}
@@ -21,7 +21,7 @@ $test->bind(ZEROMQ_TEST_DSN);
try {
$test->setContextOptions(4,2);
-} catch (ZeroMQException $e) {
+} catch (ZMQException $e) {
echo "Got exception\n";
}
View
12 tests/006-sockopt.phpt
@@ -5,16 +5,16 @@ Test getsockopt / setsockopt
--FILE--
<?php
-if (!is_callable('ZeroMQ', 'getSockOpt'))
+if (!is_callable('ZMQ', 'getSockOpt'))
die("skip zeromq 2.0.7 or higher required");
-$test = new ZeroMQ(ZeroMQ::SOCKET_REP);
+$test = new ZMQ(ZMQ::SOCKET_REP);
-$test->setSockOpt(ZeroMQ::SOCKOPT_HWM, 1);
-var_dump($test->getSockOpt(ZeroMQ::SOCKOPT_HWM));
+$test->setSockOpt(ZMQ::SOCKOPT_HWM, 1);
+var_dump($test->getSockOpt(ZMQ::SOCKOPT_HWM));
-$test->setSockOpt(ZeroMQ::SOCKOPT_IDENTITY, "hello");
-var_dump($test->getSockOpt(ZeroMQ::SOCKOPT_IDENTITY));
+$test->setSockOpt(ZMQ::SOCKOPT_IDENTITY, "hello");
+var_dump($test->getSockOpt(ZMQ::SOCKOPT_IDENTITY));
--EXPECT--
int(1)
View
2 tests/skipif.inc
@@ -1,5 +1,5 @@
<?php
-if (!extension_loaded("zeromq")) die("skip");
+if (!extension_loaded("zmq")) die("skip");
?>
View
4 tests/zeromq_test_helper.inc
@@ -5,15 +5,15 @@ define('ZEROMQ_TEST_DSN2', 'tcp://127.0.0.1:6655');
function create_server($persistent_id = null)
{
- $server = new ZeroMQ(ZeroMQ::SOCKET_REP, $persistent_id);
+ $server = new ZMQ(ZMQ::SOCKET_REP, $persistent_id);
$server->bind(ZEROMQ_TEST_DSN);
return $server;
}
function create_client($persistent_id = null)
{
- $client = new ZeroMQ(ZeroMQ::SOCKET_REQ, $persistent_id);
+ $client = new ZMQ(ZMQ::SOCKET_REQ, $persistent_id);
$client->connect(ZEROMQ_TEST_DSN);
return $client;
View
562 zeromq.c → zmq.c
@@ -1,6 +1,6 @@
/*
+-----------------------------------------------------------------------------------+
-| ZeroMQ extension for PHP |
+| ZMQ extension for PHP |
| Copyright (c) 2010, Mikko Koppanen <mkoppanen@php.net> |
| All rights reserved. |
+-----------------------------------------------------------------------------------+
@@ -28,21 +28,21 @@
+-----------------------------------------------------------------------------------+
*/
-#include "php_zeromq.h"
-#include "php_zeromq_private.h"
+#include "php_zmq.h"
+#include "php_zmq_private.h"
-zend_class_entry *php_zeromq_sc_entry;
-zend_class_entry *php_zeromq_poll_sc_entry;
+zend_class_entry *php_zmq_sc_entry;
+zend_class_entry *php_zmq_poll_sc_entry;
-zend_class_entry *php_zeromq_exception_sc_entry;
-zend_class_entry *php_zeromq_poll_exception_sc_entry;
+zend_class_entry *php_zmq_exception_sc_entry;
+zend_class_entry *php_zmq_poll_exception_sc_entry;
-static zend_object_handlers zeromq_object_handlers;
-static zend_object_handlers zeromq_poll_object_handlers;
+static zend_object_handlers zmq_object_handlers;
+static zend_object_handlers zmq_poll_object_handlers;
-ZEND_DECLARE_MODULE_GLOBALS(zeromq);
+ZEND_DECLARE_MODULE_GLOBALS(php_zmq);
-#define PHP_ZEROMQ_BUF_SIZE 512
+#define PHP_ZMQ_BUF_SIZE 512
#ifndef Z_ADDREF_P
# define Z_ADDREF_P(pz) (pz)->refcount++
@@ -57,80 +57,80 @@ ZEND_DECLARE_MODULE_GLOBALS(zeromq);
#endif
/* list entries */
-static int le_zeromq_socket, le_zeromq_context;
+static int le_zmq_socket, le_zmq_context;
-/** {{{ static int php_zeromq_socket_list_entry(void)
+/** {{{ static int php_zmq_socket_list_entry(void)
*/
-static int php_zeromq_socket_list_entry(void)
+static int php_zmq_socket_list_entry(void)
{
- return le_zeromq_socket;
+ return le_zmq_socket;
}
/* }}} */
-/* {{{ static int php_zeromq_context_list_entry(void)
+/* {{{ static int php_zmq_context_list_entry(void)
*/
-static int php_zeromq_context_list_entry(void)
+static int php_zmq_context_list_entry(void)
{
- return le_zeromq_context;
+ return le_zmq_context;
}
/* }}} */
-/* {{{ static void php_zeromq_context_destroy(php_zeromq_context *ctx)
- Destroy the zeromq context and free memory associated
+/* {{{ static void php_zmq_context_destroy(php_zmq_context *ctx)
+ Destroy the zmq context and free memory associated
*/
-static void php_zeromq_context_destroy(php_zeromq_context *ctx)
+static void php_zmq_context_destroy(php_zmq_context *ctx)
{
(void) zmq_term(ctx->context);
pefree(ctx, ctx->opts.is_persistent);
}
/* }}} */
-/* {{{ static php_zeromq_context *php_zeromq_context_new(php_zeromq_context_opts *ctx_opts TSRMLS_DC)
- Create a new zeromq context
+/* {{{ static php_zmq_context *php_zmq_context_new(php_zmq_context_opts *ctx_opts TSRMLS_DC)
+ Create a new zmq context
*/
-static php_zeromq_context *php_zeromq_context_new(php_zeromq_context_opts *ctx_opts TSRMLS_DC)
+static php_zmq_context *php_zmq_context_new(php_zmq_context_opts *ctx_opts TSRMLS_DC)
{
- php_zeromq_context *ctx;
+ php_zmq_context *ctx;
- ctx = pecalloc(1, sizeof(php_zeromq_context), ctx_opts->is_persistent);
+ ctx = pecalloc(1, sizeof(php_zmq_context), ctx_opts->is_persistent);
ctx->context = zmq_init(ctx_opts->app_threads, ctx_opts->io_threads, ctx_opts->poll);
if (!ctx->context) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error creating context: %s", zmq_strerror(errno));
}
- memcpy(&(ctx->opts), ctx_opts, sizeof(php_zeromq_context_opts));
+ memcpy(&(ctx->opts), ctx_opts, sizeof(php_zmq_context_opts));
return ctx;
}
/* }}} */
-/* {{{ static php_zeromq_context *php_zeromq_context_get(php_zeromq_context_opts *ctx_opts TSRMLS_DC)
+/* {{{ static php_zmq_context *php_zmq_context_get(php_zmq_context_opts *ctx_opts TSRMLS_DC)
Get a context. If context does not exist in persistent list allocates a new one
*/
-static php_zeromq_context *php_zeromq_context_get(php_zeromq_context_opts *ctx_opts TSRMLS_DC)
+static php_zmq_context *php_zmq_context_get(php_zmq_context_opts *ctx_opts TSRMLS_DC)
{
- php_zeromq_context *ctx;
+ php_zmq_context *ctx;
char *plist_key;
int plist_key_len;
zend_rsrc_list_entry le, *le_p = NULL;
if (ctx_opts->is_persistent) {
- plist_key_len = spprintf(&plist_key, 0, "zeromq_context:[%d]-[%d]-[%d]", ctx_opts->app_threads, ctx_opts->io_threads, ctx_opts->poll);
+ plist_key_len = spprintf(&plist_key, 0, "zmq_context:[%d]-[%d]-[%d]", ctx_opts->app_threads, ctx_opts->io_threads, ctx_opts->poll);
plist_key_len += 1;
if (zend_hash_find(&EG(persistent_list), plist_key, plist_key_len, (void *)&le_p) == SUCCESS) {
- if (le_p->type == php_zeromq_context_list_entry()) {
+ if (le_p->type == php_zmq_context_list_entry()) {
efree(plist_key);
- return (php_zeromq_context *) le_p->ptr;
+ return (php_zmq_context *) le_p->ptr;
}
}
}
- ctx = php_zeromq_context_new(ctx_opts);
+ ctx = php_zmq_context_new(ctx_opts);
if (ctx_opts->is_persistent) {
- le.type = php_zeromq_context_list_entry();
+ le.type = php_zmq_context_list_entry();
le.ptr = ctx;
if (zend_hash_update(&EG(persistent_list), (char *)plist_key, plist_key_len, (void *)&le, sizeof(le), NULL) == FAILURE) {
@@ -142,14 +142,14 @@ static php_zeromq_context *php_zeromq_context_get(php_zeromq_context_opts *ctx_o
}
/* }}} */
-/* {{{ static php_zeromq_socket *php_zeromq_socket_new(php_zeromq_socket_opts *socket_opts, php_zeromq_context_opts *ctx_opts TSRMLS_DC)
- Create a new zeromq socket
+/* {{{ static php_zmq_socket *php_zmq_socket_new(php_zmq_socket_opts *socket_opts, php_zmq_context_opts *ctx_opts TSRMLS_DC)
+ Create a new zmq socket
*/
-static php_zeromq_socket *php_zeromq_socket_new(php_zeromq_socket_opts *socket_opts, php_zeromq_context_opts *ctx_opts TSRMLS_DC)
+static php_zmq_socket *php_zmq_socket_new(php_zmq_socket_opts *socket_opts, php_zmq_context_opts *ctx_opts TSRMLS_DC)
{
- php_zeromq_socket *zmq_sock = pecalloc(1, sizeof(php_zeromq_socket), socket_opts->is_persistent);
+ php_zmq_socket *zmq_sock = pecalloc(1, sizeof(php_zmq_socket), socket_opts->is_persistent);
- zmq_sock->ctx = php_zeromq_context_get(ctx_opts TSRMLS_CC);
+ zmq_sock->ctx = php_zmq_context_get(ctx_opts TSRMLS_CC);
zmq_sock->socket = zmq_socket(zmq_sock->ctx->context, socket_opts->type);
if (!zmq_sock->socket) {
@@ -167,12 +167,12 @@ static php_zeromq_socket *php_zeromq_socket_new(php_zeromq_socket_opts *socket_o
}
/* }}} */
-/* {{{ static php_zeromq_socket *php_zeromq_socket_get(php_zeromq_socket_opts *socket_opts, php_zeromq_context_opts *ctx_opts TSRMLS_DC)
+/* {{{ static php_zmq_socket *php_zmq_socket_get(php_zmq_socket_opts *socket_opts, php_zmq_context_opts *ctx_opts TSRMLS_DC)
Tries to get context from plist and allocates a new context if context does not exist
*/
-static php_zeromq_socket *php_zeromq_socket_get(php_zeromq_socket_opts *socket_opts, php_zeromq_context_opts *ctx_opts TSRMLS_DC)
+static php_zmq_socket *php_zmq_socket_get(php_zmq_socket_opts *socket_opts, php_zmq_context_opts *ctx_opts TSRMLS_DC)
{
- php_zeromq_socket *zmq_sock_p;
+ php_zmq_socket *zmq_sock_p;
char *plist_key;
int plist_key_len;
@@ -183,22 +183,22 @@ static php_zeromq_socket *php_zeromq_socket_get(php_zeromq_socket_opts *socket_o
if (socket_opts->is_persistent) {
zend_rsrc_list_entry *le = NULL;
- plist_key_len = spprintf(&plist_key, 0, "zeromq_socket:[%d]-[%s]", socket_opts->type, socket_opts->p_id);
+ plist_key_len = spprintf(&plist_key, 0, "zmq_socket:[%d]-[%s]", socket_opts->type, socket_opts->p_id);
plist_key_len += 1;
if (zend_hash_find(&EG(persistent_list), plist_key, plist_key_len, (void *)&le) == SUCCESS) {
- if (le->type == php_zeromq_socket_list_entry()) {
+ if (le->type == php_zmq_socket_list_entry()) {
efree(plist_key);
- return (php_zeromq_socket *) le->ptr;
+ return (php_zmq_socket *) le->ptr;
}
}
}
- zmq_sock_p = php_zeromq_socket_new(socket_opts, ctx_opts TSRMLS_CC);
+ zmq_sock_p = php_zmq_socket_new(socket_opts, ctx_opts TSRMLS_CC);
if (socket_opts->is_persistent) {
zend_rsrc_list_entry le;
- le.type = php_zeromq_socket_list_entry();
+ le.type = php_zmq_socket_list_entry();
le.ptr = zmq_sock_p;
if (zend_hash_update(&EG(persistent_list), (char *)plist_key, plist_key_len, (void *)&le, sizeof(le), NULL) == FAILURE) {
@@ -210,10 +210,10 @@ static php_zeromq_socket *php_zeromq_socket_get(php_zeromq_socket_opts *socket_o
}
/* }}} */
-/* {{{ static void php_zeromq_socket_destroy(php_zeromq_socket *zmq_sock)
+/* {{{ static void php_zmq_socket_destroy(php_zmq_socket *zmq_sock)
Destroy the socket (note: does not touch context)
*/
-static void php_zeromq_socket_destroy(php_zeromq_socket *zmq_sock)
+static void php_zmq_socket_destroy(php_zmq_socket *zmq_sock)
{
zend_hash_destroy(&(zmq_sock->connect));
zend_hash_destroy(&(zmq_sock->bind));
@@ -227,14 +227,14 @@ static void php_zeromq_socket_destroy(php_zeromq_socket *zmq_sock)
}
/* }}} */
-/* -- START ZeroMQ --- */
+/* -- START ZMQ --- */
-/* {{{ ZeroMQ ZeroMQ::__construct(integer $type[, string $persistent_id = null])
- Build a new ZeroMQ object
+/* {{{ ZMQ ZMQ::__construct(integer $type[, string $persistent_id = null])
+ Build a new ZMQ object
*/
-PHP_METHOD(zeromq, __construct)
+PHP_METHOD(zmq, __construct)
{
- php_zeromq_object *intern;
+ php_zmq_object *intern;
long type;
char *p_id = NULL;
int p_id_len = 0;
@@ -243,7 +243,7 @@ PHP_METHOD(zeromq, __construct)
return;
}
- intern = PHP_ZEROMQ_OBJECT;
+ intern = PHP_ZMQ_OBJECT;
intern->socket_opts.type = type;
if (p_id && p_id_len > 0) {
@@ -253,12 +253,12 @@ PHP_METHOD(zeromq, __construct)
}
/* }}} */
-/* {{{ ZeroMQ ZeroMQ::send(string $message[, integer $flags = 0])
+/* {{{ ZMQ ZMQ::send(string $message[, integer $flags = 0])
Send a message
*/
-PHP_METHOD(zeromq, send)
+PHP_METHOD(zmq, send)
{
- php_zeromq_object *intern;
+ php_zmq_object *intern;
char *message_param;
zmq_msg_t message;
@@ -269,15 +269,15 @@ PHP_METHOD(zeromq, send)
return;
}
- intern = PHP_ZEROMQ_OBJECT;
+ intern = PHP_ZMQ_OBJECT;
if (!intern->zms) {
- zend_throw_exception(php_zeromq_poll_exception_sc_entry, "The socket has not been initialized yet", 1 TSRMLS_CC);
+ zend_throw_exception(php_zmq_poll_exception_sc_entry, "The socket has not been initialized yet", 1 TSRMLS_CC);
return;
}
if (zmq_msg_init_size(&message, message_param_len) != 0) {
- zend_throw_exception_ex(php_zeromq_exception_sc_entry, errno TSRMLS_CC, "Failed to initialize message structure: %s", zmq_strerror(errno));
+ zend_throw_exception_ex(php_zmq_exception_sc_entry, errno TSRMLS_CC, "Failed to initialize message structure: %s", zmq_strerror(errno));
return;
}
memcpy(zmq_msg_data(&message), message_param, message_param_len);
@@ -286,41 +286,41 @@ PHP_METHOD(zeromq, send)
zmq_msg_close(&message);
if (rc != 0) {
- zend_throw_exception_ex(php_zeromq_exception_sc_entry, errno TSRMLS_CC, "Failed to send message: %s", zmq_strerror(errno));
+ zend_throw_exception_ex(php_zmq_exception_sc_entry, errno TSRMLS_CC, "Failed to send message: %s", zmq_strerror(errno));
return;
}
- ZEROMQ_RETURN_THIS;
+ ZMQ_RETURN_THIS;
}
/* }}} */
-/* {{{ string ZeroMQ::recv([integer $flags = 0])
+/* {{{ string ZMQ::recv([integer $flags = 0])
Receive a message
*/
-PHP_METHOD(zeromq, recv)
+PHP_METHOD(zmq, recv)
{
- php_zeromq_object *intern;
+ php_zmq_object *intern;
zmq_msg_t message;
long flags = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) {
return;
}
- intern = PHP_ZEROMQ_OBJECT;
+ intern = PHP_ZMQ_OBJECT;
if (!intern->zms) {
- zend_throw_exception(php_zeromq_poll_exception_sc_entry, "The socket has not been initialized yet", 1 TSRMLS_CC);
+ zend_throw_exception(php_zmq_poll_exception_sc_entry, "The socket has not been initialized yet", 1 TSRMLS_CC);
return;
}
if (zmq_msg_init(&message) != 0) {
- zend_throw_exception_ex(php_zeromq_exception_sc_entry, errno TSRMLS_CC, "Failed to initialize message structure: %s", zmq_strerror(errno));
+ zend_throw_exception_ex(php_zmq_exception_sc_entry, errno TSRMLS_CC, "Failed to initialize message structure: %s", zmq_strerror(errno));
return;
}
if (zmq_recv(intern->zms->socket, &message, flags) != 0) {
zmq_msg_close(&message);
- zend_throw_exception_ex(php_zeromq_exception_sc_entry, errno TSRMLS_CC, "Failed to receive message: %s", zmq_strerror(errno));
+ zend_throw_exception_ex(php_zmq_exception_sc_entry, errno TSRMLS_CC, "Failed to receive message: %s", zmq_strerror(errno));
return;
}
@@ -330,56 +330,56 @@ PHP_METHOD(zeromq, recv)
}
/* }}} */
-/* {{{ ZeroMQ ZeroMQ::setContextOptions(integer $app_threads, integer $io_threads[, boolean $poll = false])
+/* {{{ ZMQ ZMQ::setContextOptions(integer $app_threads, integer $io_threads[, boolean $poll = false])
Set options for the internal context
*/
-PHP_METHOD(zeromq, setcontextoptions)
+PHP_METHOD(zmq, setcontextoptions)
{
- php_zeromq_object *intern;
+ php_zmq_object *intern;
long app_threads, io_threads;
zend_bool poll = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll|b", &app_threads, &io_threads, &poll) == FAILURE) {
return;
}
- intern = PHP_ZEROMQ_OBJECT;
+ intern = PHP_ZMQ_OBJECT;
if (intern->zms) {
- zend_throw_exception(php_zeromq_exception_sc_entry, "Context options must be set before connect, bind or setSockOpt", 1 TSRMLS_CC);
+ zend_throw_exception(php_zmq_exception_sc_entry, "Context options must be set before connect, bind or setSockOpt", 1 TSRMLS_CC);
return;
}
if (app_threads <= 0) {
- zend_throw_exception_ex(php_zeromq_exception_sc_entry, 33 TSRMLS_CC, "The first argument must be greater than zero, %ld given", app_threads);
+ zend_throw_exception_ex(php_zmq_exception_sc_entry, 33 TSRMLS_CC, "The first argument must be greater than zero, %ld given", app_threads);
return;
}
if (io_threads <= 0) {
- zend_throw_exception_ex(php_zeromq_exception_sc_entry, 34 TSRMLS_CC, "The second argument must greater than zero, %ld given", app_threads);
+ zend_throw_exception_ex(php_zmq_exception_sc_entry, 34 TSRMLS_CC, "The second argument must greater than zero, %ld given", app_threads);
return;
}
/* Socket is created on-demand in connect / bind */
intern->ctx_opts.app_threads = app_threads;
intern->ctx_opts.io_threads = io_threads;
intern->ctx_opts.poll = poll;
- ZEROMQ_RETURN_THIS;
+ ZMQ_RETURN_THIS;
}
/* }}} */
-/** {{{ array ZeroMQ::getContextOptions()
+/** {{{ array ZMQ::getContextOptions()
Returns the amount of app and io threads in the internal context
*/
-PHP_METHOD(zeromq, getcontextoptions)
+PHP_METHOD(zmq, getcontextoptions)
{
- php_zeromq_object *intern;
+ php_zmq_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
- intern = PHP_ZEROMQ_OBJECT;
+ intern = PHP_ZMQ_OBJECT;
array_init(return_value);
/*
@@ -392,18 +392,18 @@ PHP_METHOD(zeromq, getcontextoptions)
}
/* }}} */
-/** {{{ string ZeroMQ::getPersistentId()
+/** {{{ string ZMQ::getPersistentId()
Returns the persistent id of the object
*/
-PHP_METHOD(zeromq, getpersistentid)
+PHP_METHOD(zmq, getpersistentid)
{
- php_zeromq_object *intern;
+ php_zmq_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
- intern = PHP_ZEROMQ_OBJECT;
+ intern = PHP_ZMQ_OBJECT;
if (intern->socket_opts.p_id) {
/* Return the id */
@@ -413,12 +413,12 @@ PHP_METHOD(zeromq, getpersistentid)
}
/* }}} */
-/* {{{ ZeroMQ ZeroMQ::bind(string $dsn[, boolean $force = false])
+/* {{{ ZMQ ZMQ::bind(string $dsn[, boolean $force = false])
Bind the socket to an endpoint
*/
-PHP_METHOD(zeromq, bind)
+PHP_METHOD(zmq, bind)
{
- php_zeromq_object *intern;
+ php_zmq_object *intern;
char *dsn;
int dsn_len;
zend_bool force = 0;
@@ -428,34 +428,34 @@ PHP_METHOD(zeromq, bind)
return;
}
- intern = PHP_ZEROMQ_OBJECT;
+ intern = PHP_ZMQ_OBJECT;
if (!intern->zms) {
/* Socket is persisted only if context is persistent */
- intern->zms = php_zeromq_socket_get(&(intern->socket_opts), &(intern->ctx_opts) TSRMLS_CC);
+ intern->zms = php_zmq_socket_get(&(intern->socket_opts), &(intern->ctx_opts) TSRMLS_CC);
}
/* already connected ? */
if (!force && zend_hash_exists(&(intern->zms->bind), dsn, dsn_len + 1)) {
- ZEROMQ_RETURN_THIS;
+ ZMQ_RETURN_THIS;
}
if (zmq_bind(intern->zms->socket, dsn) != 0) {
- zend_throw_exception_ex(php_zeromq_exception_sc_entry, errno TSRMLS_CC, "Failed to bind the ZeroMQ: %s", zmq_strerror(errno));
+ zend_throw_exception_ex(php_zmq_exception_sc_entry, errno TSRMLS_CC, "Failed to bind the ZMQ: %s", zmq_strerror(errno));
return;
}
zend_hash_add(&(intern->zms->bind), dsn, dsn_len + 1, (void *)&dummy, sizeof(void *), NULL);
- ZEROMQ_RETURN_THIS;
+ ZMQ_RETURN_THIS;
}
/* }}} */
-/* {{{ ZeroMQ ZeroMQ::connect(string $dsn[, boolean $force = false])
+/* {{{ ZMQ ZMQ::connect(string $dsn[, boolean $force = false])
Connect the socket to an endpoint
*/
-PHP_METHOD(zeromq, connect)
+PHP_METHOD(zmq, connect)
{
- php_zeromq_object *intern;
+ php_zmq_object *intern;
char *dsn;
int dsn_len;
zend_bool force = 0;
@@ -465,30 +465,30 @@ PHP_METHOD(zeromq, connect)
return;
}
- intern = PHP_ZEROMQ_OBJECT;
+ intern = PHP_ZMQ_OBJECT;
if (!intern->zms) {
/* Socket is persisted only if context is persistent */
- intern->zms = php_zeromq_socket_get(&(intern->socket_opts), &(intern->ctx_opts) TSRMLS_CC);
+ intern->zms = php_zmq_socket_get(&(intern->socket_opts), &(intern->ctx_opts) TSRMLS_CC);
}
/* already connected ? */
if (!force && zend_hash_exists(&(intern->zms->connect), dsn, dsn_len + 1)) {
- ZEROMQ_RETURN_THIS;
+ ZMQ_RETURN_THIS;
}
if (zmq_connect(intern->zms->socket, dsn) != 0) {
- zend_throw_exception_ex(php_zeromq_exception_sc_entry, errno TSRMLS_CC, "Failed to connect the ZeroMQ: %s", zmq_strerror(errno));
+ zend_throw_exception_ex(php_zmq_exception_sc_entry, errno TSRMLS_CC, "Failed to connect the ZMQ: %s", zmq_strerror(errno));
return;
}
zend_hash_add(&(intern->zms->connect), dsn, dsn_len + 1, (void *)&dummy, sizeof(void *), NULL);
- ZEROMQ_RETURN_THIS;
+ ZMQ_RETURN_THIS;
}
/* }}} */
-/* {{{ static int php_zeromq_get_keys(zval **ppzval TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) */
-static int php_zeromq_get_keys(zval **ppzval TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
+/* {{{ static int php_zmq_get_keys(zval **ppzval TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) */
+static int php_zmq_get_keys(zval **ppzval TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
{
zval *retval;
@@ -509,19 +509,19 @@ static int php_zeromq_get_keys(zval **ppzval TSRMLS_DC, int num_args, va_list ar
}
/* }}} */
-/* {{{ array ZeroMQ::getEndpoints()
+/* {{{ array ZMQ::getEndpoints()
Returns endpoints where this socket is connected/bound to. Contains two keys ('bind', 'connect')
*/
-PHP_METHOD(zeromq, getendpoints)
+PHP_METHOD(zmq, getendpoints)
{
- php_zeromq_object *intern;
+ php_zmq_object *intern;
zval *connect, *bind;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
- intern = PHP_ZEROMQ_OBJECT;
+ intern = PHP_ZMQ_OBJECT;
array_init(return_value);
MAKE_STD_ZVAL(connect);
@@ -536,39 +536,39 @@ PHP_METHOD(zeromq, getendpoints)
return; /* No endpoints */
}
- zend_hash_apply_with_arguments(&(intern->zms->connect) TSRMLS_CC, (apply_func_args_t) php_zeromq_get_keys, 1, connect);
- zend_hash_apply_with_arguments(&(intern->zms->bind) TSRMLS_CC, (apply_func_args_t) php_zeromq_get_keys, 1, bind);
+ zend_hash_apply_with_arguments(&(intern->zms->connect) TSRMLS_CC, (apply_func_args_t) php_zmq_get_keys, 1, connect);
+ zend_hash_apply_with_arguments(&(intern->zms->bind) TSRMLS_CC, (apply_func_args_t) php_zmq_get_keys, 1, bind);
add_assoc_zval(return_value, "connect", connect);
add_assoc_zval(return_value, "bind", bind);
return;
}
/* }}} */
-/* {{{ integer ZeroMQ::getSocketType()
+/* {{{ integer ZMQ::getSocketType()
Returns the socket type
*/
-PHP_METHOD(zeromq, getsockettype)
+PHP_METHOD(zmq, getsockettype)
{
- php_zeromq_object *intern;
+ php_zmq_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
return;
}
- intern = PHP_ZEROMQ_OBJECT;
+ intern = PHP_ZMQ_OBJECT;
/* intern->type should always match intern->zms->type */
RETURN_LONG(intern->socket_opts.type);
}
/* }}} */
-/* {{{ ZeroMQ ZeroMQ::setSockOpt(integer $SOCKOPT, mixed $value)
+/* {{{ ZMQ ZMQ::setSockOpt(integer $SOCKOPT, mixed $value)
Set a socket option
*/
-PHP_METHOD(zeromq, setsockopt)
+PHP_METHOD(zmq, setsockopt)
{
- php_zeromq_object *intern;
+ php_zmq_object *intern;
long key;
zval *pz_value;
int status;
@@ -577,11 +577,11 @@ PHP_METHOD(zeromq, setsockopt)
return;
}
- intern = PHP_ZEROMQ_OBJECT;
+ intern = PHP_ZMQ_OBJECT;
if (!intern->zms) {
/* Socket is persisted only if context is persistent */
- intern->zms = php_zeromq_socket_get(&(intern->socket_opts), &(intern->ctx_opts) TSRMLS_CC);
+ intern->zms = php_zmq_socket_get(&(intern->socket_opts), &(intern->ctx_opts) TSRMLS_CC);
}
switch (key) {
@@ -617,7 +617,7 @@ PHP_METHOD(zeromq, setsockopt)
convert_to_long(pz_value);
if (Z_LVAL_P(pz_value) < 0) {
- zend_throw_exception(php_zeromq_exception_sc_entry, "The option value must be a positive integer", 1 TSRMLS_CC);
+ zend_throw_exception(php_zmq_exception_sc_entry, "The option value must be a positive integer", 1 TSRMLS_CC);
return;
}
value = (uint64_t) Z_LVAL_P(pz_value);
@@ -627,38 +627,38 @@ PHP_METHOD(zeromq, setsockopt)
default:
{
- zend_throw_exception(php_zeromq_exception_sc_entry, "Unknown option key", 1 TSRMLS_CC);
+ zend_throw_exception(php_zmq_exception_sc_entry, "Unknown option key", 1 TSRMLS_CC);
return;
}
break;
}
if (status != 0) {
- zend_throw_exception_ex(php_zeromq_exception_sc_entry, errno TSRMLS_CC, "Failed to set socket option: %s", zmq_strerror(errno));
+ zend_throw_exception_ex(php_zmq_exception_sc_entry, errno TSRMLS_CC, "Failed to set socket option: %s", zmq_strerror(errno));
return;
}
- ZEROMQ_RETURN_THIS;
+ ZMQ_RETURN_THIS;
}
/* }}} */
#ifdef HAVE_ZMQ_GETSOCKOPT
-/* {{{ mixed ZeroMQ::getSockOpt()
+/* {{{ mixed ZMQ::getSockOpt()
Get a socket option
*/
-PHP_METHOD(zeromq, getsockopt)
+PHP_METHOD(zmq, getsockopt)
{
- php_zeromq_object *intern;
+ php_zmq_object *intern;
long key;
size_t value_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &key) == FAILURE) {
return;
}
- intern = PHP_ZEROMQ_OBJECT;
+ intern = PHP_ZMQ_OBJECT;
if (!intern->zms) {
- zend_throw_exception(php_zeromq_exception_sc_entry, "The socket has not been initialized yet", 1 TSRMLS_CC);
+ zend_throw_exception(php_zmq_exception_sc_entry, "The socket has not been initialized yet", 1 TSRMLS_CC);
return;
}
@@ -672,7 +672,7 @@ PHP_METHOD(zeromq, getsockopt)
int64_t value;
value_len = sizeof(int64_t);
if (zmq_getsockopt (intern->zms->socket, (int) key, &value, &value_len) != 0) {
- zend_throw_exception_ex(php_zeromq_exception_sc_entry, errno TSRMLS_CC, "Failed to get the option value: %s", zmq_strerror(errno));
+ zend_throw_exception_ex(php_zmq_exception_sc_entry, errno TSRMLS_CC, "Failed to get the option value: %s", zmq_strerror(errno));
return;
}
RETURN_LONG(value);
@@ -685,7 +685,7 @@ PHP_METHOD(zeromq, getsockopt)
unsigned char *value = NULL;
do {
- value_len = PHP_ZEROMQ_BUF_SIZE * i++;
+ value_len = PHP_ZMQ_BUF_SIZE * i++;
value = erealloc(value, value_len);
rc = zmq_getsockopt (intern->zms->socket, (int) key, value, &value_len);
} while (rc == -1 && errno == EINVAL);
@@ -705,7 +705,7 @@ PHP_METHOD(zeromq, getsockopt)
uint64_t value;
value = sizeof(uint64_t);
if (zmq_getsockopt (intern->zms->socket, (int) key, &value, &value_len) != 0) {
- zend_throw_exception_ex(php_zeromq_exception_sc_entry, errno TSRMLS_CC, "Failed to get the option value: %s", zmq_strerror(errno));
+ zend_throw_exception_ex(php_zmq_exception_sc_entry, errno TSRMLS_CC, "Failed to get the option value: %s", zmq_strerror(errno));
return;
}
RETURN_LONG(value);
@@ -714,13 +714,13 @@ PHP_METHOD(zeromq, getsockopt)
case ZMQ_SUBSCRIBE:
case ZMQ_UNSUBSCRIBE:
- zend_throw_exception(php_zeromq_exception_sc_entry, "Retrieving SOCKOPT_SUBSCRIBE and SOCKOPT_UNSUBSCRIBE is not support", 1 TSRMLS_CC);
+ zend_throw_exception(php_zmq_exception_sc_entry, "Retrieving SOCKOPT_SUBSCRIBE and SOCKOPT_UNSUBSCRIBE is not support", 1 TSRMLS_CC);
return;
break;
default:
{
- zend_throw_exception(php_zeromq_exception_sc_entry, "Unknown option key", 1 TSRMLS_CC);
+ zend_throw_exception(php_zmq_exception_sc_entry, "Unknown option key", 1 TSRMLS_CC);
return;
}
break;
@@ -729,38 +729,38 @@ PHP_METHOD(zeromq, getsockopt)
/* }}} */
#endif
-/* -- END ZeroMQ --- */
+/* -- END ZMQ --- */
-/* -- START ZeroMQPoll --- */
+/* -- START ZMQPoll --- */
-/* {{{ ZeroMQPoll ZeroMQPoll::add(ZeroMQ $object, integer $events)
- Add a ZeroMQ object into the pollset
+/* {{{ ZMQPoll ZMQPoll::add(ZMQ $object, integer $events)
+ Add a ZMQ object into the pollset
*/
-PHP_METHOD(zeromqpoll, add)
+PHP_METHOD(zmqpoll, add)
{
- php_zeromq_poll_object *intern;
- php_zeromq_object *item;
+ php_zmq_poll_object *intern;
+ php_zmq_object *item;
zval *object;
long type;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ol", &object, php_zeromq_sc_entry, &type) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ol", &object, php_zmq_sc_entry, &type) == FAILURE) {
return;
}
- item = (php_zeromq_object *)zend_object_store_get_object(object TSRMLS_CC);
+ item = (php_zmq_object *)zend_object_store_get_object(object TSRMLS_CC);
if (!item->zms) {
- zend_throw_exception(php_zeromq_poll_exception_sc_entry, "The socket has not been initialized yet", 1 TSRMLS_CC);
+ zend_throw_exception(php_zmq_poll_exception_sc_entry, "The socket has not been initialized yet", 1 TSRMLS_CC);
return;
}
if (!item->ctx_opts.poll) {
- zend_throw_exception(php_zeromq_poll_exception_sc_entry, "The socket has not been initialized with polling", 1 TSRMLS_CC);
+ zend_throw_exception(php_zmq_poll_exception_sc_entry, "The socket has not been initialized with polling", 1 TSRMLS_CC);
return;
}
- intern = PHP_ZEROMQ_POLL_OBJECT;
+ intern = PHP_ZMQ_POLL_OBJECT;
intern->items = erealloc(intern->items, (intern->num_items + 1) * sizeof(zmq_pollitem_t));
intern->objects = erealloc(intern->objects, (intern->num_items + 1) * sizeof(zval *));
@@ -770,16 +770,16 @@ PHP_METHOD(zeromqpoll, add)
intern->objects[intern->num_items++] = object;
zend_objects_store_add_ref(object TSRMLS_CC);
- ZEROMQ_RETURN_THIS;
+ ZMQ_RETURN_THIS;
}
/* }}} */
-/* {{{ integer ZeroMQPoll::poll(array &$readable, array &$writable[, integer $timeout = -1])
+/* {{{ integer ZMQPoll::poll(array &$readable, array &$writable[, integer $timeout = -1])
Poll the sockets
*/
-PHP_METHOD(zeromqpoll, poll)
+PHP_METHOD(zmqpoll, poll)
{
- php_zeromq_poll_object *intern;
+ php_zmq_poll_object *intern;
zval *r_array, *w_array;
long timeout = -1;
@@ -791,10 +791,10 @@ PHP_METHOD(zeromqpoll, poll)
return;
}
- intern = PHP_ZEROMQ_POLL_OBJECT;
+ intern = PHP_ZMQ_POLL_OBJECT;
if (intern->num_items == 0) {
- zend_throw_exception(php_zeromq_poll_exception_sc_entry, "No sockets assigned to the ZeroMQPoll", 1 TSRMLS_CC);
+ zend_throw_exception(php_zmq_poll_exception_sc_entry, "No sockets assigned to the ZMQPoll", 1 TSRMLS_CC);
return;
}
@@ -815,7 +815,7 @@ PHP_METHOD(zeromqpoll, poll)
rc = zmq_poll(intern->items, intern->num_items, timeout);
if (rc == -1) {
- zend_throw_exception_ex(php_zeromq_poll_exception_sc_entry, errno TSRMLS_CC, "Poll failed: %s", zmq_strerror(errno));
+ zend_throw_exception_ex(php_zmq_poll_exception_sc_entry, errno TSRMLS_CC, "Poll failed: %s", zmq_strerror(errno));
return;
}
@@ -842,97 +842,97 @@ PHP_METHOD(zeromqpoll, poll)
}
/* }}} */
-/* -- END ZeroMQPoll */
+/* -- END ZMQPoll */
-ZEND_BEGIN_ARG_INFO_EX(zeromq_construct_args, 0, 0, 2)
+ZEND_BEGIN_ARG_INFO_EX(zmq_construct_args, 0, 0, 2)
ZEND_ARG_INFO(0, type)
ZEND_ARG_INFO(0, dsn)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(zeromq_bind_args, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(zmq_bind_args, 0, 0, 1)
ZEND_ARG_INFO(0, dsn)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(zeromq_connect_args, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(zmq_connect_args, 0, 0, 1)
ZEND_ARG_INFO(0, dsn)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(zeromq_setsockopt_args, 0, 0, 2)
+ZEND_BEGIN_ARG_INFO_EX(zmq_setsockopt_args, 0, 0, 2)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(zeromq_getcontextoptions_args, 0, 0, 0)
+ZEND_BEGIN_ARG_INFO_EX(zmq_getcontextoptions_args, 0, 0, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(zeromq_setcontextoptions_args, 0, 0, 2)
+ZEND_BEGIN_ARG_INFO_EX(zmq_setcontextoptions_args, 0, 0, 2)
ZEND_ARG_INFO(0, app_threads)
ZEND_ARG_INFO(0, io_threads)
ZEND_ARG_INFO(0, poll)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(zeromq_getendpoints_args, 0, 0, 0)
+ZEND_BEGIN_ARG_INFO_EX(zmq_getendpoints_args, 0, 0, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(zeromq_getsockettype_args, 0, 0, 0)
+ZEND_BEGIN_ARG_INFO_EX(zmq_getsockettype_args, 0, 0, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(zeromq_send_args, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(zmq_send_args, 0, 0, 1)
ZEND_ARG_INFO(0, message)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(zeromq_recv_args, 0, 0, 0)
+ZEND_BEGIN_ARG_INFO_EX(zmq_recv_args, 0, 0, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(zeromq_getpersistentid_args, 0, 0, 0)
+ZEND_BEGIN_ARG_INFO_EX(zmq_getpersistentid_args, 0, 0, 0)
ZEND_END_ARG_INFO()
#ifdef HAVE_ZMQ_GETSOCKOPT
-ZEND_BEGIN_ARG_INFO_EX(zeromq_getsockopt_args, 0, 0, 0)
+ZEND_BEGIN_ARG_INFO_EX(zmq_getsockopt_args, 0, 0, 0)
ZEND_END_ARG_INFO()
#endif
-static function_entry php_zeromq_class_methods[] = {
- PHP_ME(zeromq, __construct, zeromq_construct_args, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
- PHP_ME(zeromq, send, zeromq_send_args, ZEND_ACC_PUBLIC)
- PHP_ME(zeromq, recv, zeromq_recv_args, ZEND_ACC_PUBLIC)
- PHP_ME(zeromq, bind, zeromq_bind_args, ZEND_ACC_PUBLIC)
- PHP_ME(zeromq, connect, zeromq_connect_args, ZEND_ACC_PUBLIC)
- PHP_ME(zeromq, setsockopt, zeromq_setsockopt_args, ZEND_ACC_PUBLIC)
- PHP_ME(zeromq, getcontextoptions, zeromq_getcontextoptions_args, ZEND_ACC_PUBLIC)
- PHP_ME(zeromq, setcontextoptions, zeromq_setcontextoptions_args, ZEND_ACC_PUBLIC)
- PHP_ME(zeromq, getendpoints, zeromq_getendpoints_args, ZEND_ACC_PUBLIC)
- PHP_ME(zeromq, getsockettype, zeromq_getsockettype_args, ZEND_ACC_PUBLIC)
- PHP_ME(zeromq, getpersistentid, zeromq_getpersistentid_args, ZEND_ACC_PUBLIC)
+static function_entry php_zmq_class_methods[] = {
+ PHP_ME(zmq, __construct, zmq_construct_args, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
+ PHP_ME(zmq, send, zmq_send_args, ZEND_ACC_PUBLIC)
+ PHP_ME(zmq, recv, zmq_recv_args, ZEND_ACC_PUBLIC)
+ PHP_ME(zmq, bind, zmq_bind_args, ZEND_ACC_PUBLIC)
+ PHP_ME(zmq, connect, zmq_connect_args, ZEND_ACC_PUBLIC)
+ PHP_ME(zmq, setsockopt, zmq_setsockopt_args, ZEND_ACC_PUBLIC)
+ PHP_ME(zmq, getcontextoptions, zmq_getcontextoptions_args, ZEND_ACC_PUBLIC)
+ PHP_ME(zmq, setcontextoptions, zmq_setcontextoptions_args, ZEND_ACC_PUBLIC)
+ PHP_ME(zmq, getendpoints, zmq_getendpoints_args, ZEND_ACC_PUBLIC)
+ PHP_ME(zmq, getsockettype, zmq_getsockettype_args, ZEND_ACC_PUBLIC)
+ PHP_ME(zmq, getpersistentid, zmq_getpersistentid_args, ZEND_ACC_PUBLIC)
#ifdef HAVE_ZMQ_GETSOCKOPT
- PHP_ME(zeromq, getsockopt, zeromq_getsockopt_args, ZEND_ACC_PUBLIC)
+ PHP_ME(zmq, getsockopt, zmq_getsockopt_args, ZEND_ACC_PUBLIC)
#endif
{NULL, NULL, NULL}
};
-ZEND_BEGIN_ARG_INFO_EX(zeromq_poll_add_args, 0, 0, 2)
- ZEND_ARG_OBJ_INFO(0, ZeroMQ, ZeroMQ, 0)
+ZEND_BEGIN_ARG_INFO_EX(zmq_poll_add_args, 0, 0, 2)
+ ZEND_ARG_OBJ_INFO(0, ZMQ, ZMQ, 0)
ZEND_ARG_INFO(0, type)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(zeromq_poll_poll_args, 0, 0, 2)
+ZEND_BEGIN_ARG_INFO_EX(zmq_poll_poll_args, 0, 0, 2)
ZEND_ARG_INFO(0, readable)
ZEND_ARG_INFO(0, writable)
ZEND_END_ARG_INFO()
-static function_entry php_zeromq_poll_class_methods[] = {
- PHP_ME(zeromqpoll, add, zeromq_poll_add_args, ZEND_ACC_PUBLIC)
- PHP_ME(zeromqpoll, poll, zeromq_poll_poll_args, ZEND_ACC_PUBLIC)
+static function_entry php_zmq_poll_class_methods[] = {
+ PHP_ME(zmqpoll, add, zmq_poll_add_args, ZEND_ACC_PUBLIC)
+ PHP_ME(zmqpoll, poll, zmq_poll_poll_args, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
-zend_function_entry zeromq_functions[] = {
+zend_function_entry zmq_functions[] = {
{NULL, NULL, NULL}
};
-static void php_zeromq_object_free_storage(void *object TSRMLS_DC)
+static void php_zmq_object_free_storage(void *object TSRMLS_DC)
{
- php_zeromq_object *intern = (php_zeromq_object *)object;
+ php_zmq_object *intern = (php_zmq_object *)object;
if (!intern) {
return;
@@ -944,18 +944,18 @@ static void php_zeromq_object_free_storage(void *object TSRMLS_DC)
if (intern->zms && !intern->zms->opts.is_persistent) {
if (intern->zms->ctx && !intern->zms->ctx->opts.is_persistent) {
- php_zeromq_context_destroy(intern->zms->ctx);
+ php_zmq_context_destroy(intern->zms->ctx);
}
- php_zeromq_socket_destroy(intern->zms);
+ php_zmq_socket_destroy(intern->zms);
}
zend_object_std_dtor(&intern->zo TSRMLS_CC);
efree(intern);
}
-static void php_zeromq_poll_object_free_storage(void *object TSRMLS_DC)
+static void php_zmq_poll_object_free_storage(void *object TSRMLS_DC)
{
- php_zeromq_poll_object *intern = (php_zeromq_poll_object *)object;
+ php_zmq_poll_object *intern = (php_zmq_poll_object *)object;
if (!intern) {
return;
@@ -975,14 +975,14 @@ static void php_zeromq_poll_object_free_storage(void *object TSRMLS_DC)
efree(intern);
}
-static zend_object_value php_zeromq_object_new_ex(zend_class_entry *class_type, php_zeromq_object **ptr TSRMLS_DC)
+static zend_object_value php_zmq_object_new_ex(zend_class_entry *class_type, php_zmq_object **ptr TSRMLS_DC)
{
zval *tmp;
zend_object_value retval;
- php_zeromq_object *intern;
+ php_zmq_object *intern;
/* Allocate memory for it */
- intern = (php_zeromq_object *) emalloc(sizeof(php_zeromq_object));
+ intern = (php_zmq_object *) emalloc(sizeof(php_zmq_object));
memset(&intern->zo, 0, sizeof(zend_object));
intern->zms = NULL;
@@ -995,7 +995,7 @@ static zend_object_value php_zeromq_object_new_ex(zend_class_entry *class_type,
intern->ctx_opts.app_threads = 1;
intern->ctx_opts.io_threads = 1;
intern->ctx_opts.poll = 0;
- intern->ctx_opts.is_persistent = ZEROMQ_G(persist_context);
+ intern->ctx_opts.is_persistent = ZMQ_G(persist_context);
if (ptr) {
*ptr = intern;
@@ -1004,19 +1004,19 @@ static zend_object_value php_zeromq_object_new_ex(zend_class_entry *class_type,
zend_object_std_init(&intern->zo, class_type TSRMLS_CC);
zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref,(void *) &tmp, sizeof(zval *));
- retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t) php_zeromq_object_free_storage, NULL TSRMLS_CC);
- retval.handlers = (zend_object_handlers *) &zeromq_object_handlers;
+ retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t) php_zmq_object_free_storage, NULL TSRMLS_CC);
+ retval.handlers = (zend_object_handlers *) &zmq_object_handlers;
return retval;
}
-static zend_object_value php_zeromq_poll_object_new_ex(zend_class_entry *class_type, php_zeromq_poll_object **ptr TSRMLS_DC)
+static zend_object_value php_zmq_poll_object_new_ex(zend_class_entry *class_type, php_zmq_poll_object **ptr TSRMLS_DC)
{
zval *tmp;
zend_object_value retval;
- php_zeromq_poll_object *intern;
+ php_zmq_poll_object *intern;
/* Allocate memory for it */
- intern = (php_zeromq_poll_object *) emalloc(sizeof(php_zeromq_poll_object));
+ intern = (php_zmq_poll_object *) emalloc(sizeof(php_zmq_poll_object));
memset(&intern->zo, 0, sizeof(zend_object));
intern->items = NULL;
@@ -1030,123 +1030,123 @@ static zend_object_value php_zeromq_poll_object_new_ex(zend_class_entry *class_t
zend_object_std_init(&intern->zo, class_type TSRMLS_CC);
zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref,(void *) &tmp, sizeof(zval *));
- retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t) php_zeromq_poll_object_free_storage, NULL TSRMLS_CC);
- retval.handlers = (zend_object_handlers *) &zeromq_poll_object_handlers;
+ retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t) php_zmq_poll_object_free_storage, NULL TSRMLS_CC);
+ retval.handlers = (zend_object_handlers *) &zmq_poll_object_handlers;
return retval;
}
-static zend_object_value php_zeromq_object_new(zend_class_entry *class_type TSRMLS_DC)
+static zend_object_value php_zmq_object_new(zend_class_entry *class_type TSRMLS_DC)
{
- return php_zeromq_object_new_ex(class_type, NULL TSRMLS_CC);
+ return php_zmq_object_new_ex(class_type, NULL TSRMLS_CC);
}
-static zend_object_value php_zeromq_poll_object_new(zend_class_entry *class_type TSRMLS_DC)
+static zend_object_value php_zmq_poll_object_new(zend_class_entry *class_type TSRMLS_DC)
{
- return php_zeromq_poll_object_new_ex(class_type, NULL TSRMLS_CC);
+ return php_zmq_poll_object_new_ex(class_type, NULL TSRMLS_CC);
}
-ZEND_RSRC_DTOR_FUNC(php_zeromq_socket_dtor)
+ZEND_RSRC_DTOR_FUNC(php_zmq_socket_dtor)
{
if (rsrc->ptr) {
- php_zeromq_socket *zms = (php_zeromq_socket *)rsrc->ptr;
- php_zeromq_socket_destroy(zms);
+ php_zmq_socket *zms = (php_zmq_socket *)rsrc->ptr;
+ php_zmq_socket_destroy(zms);
rsrc->ptr = NULL;
}
}
-ZEND_RSRC_DTOR_FUNC(php_zeromq_context_dtor)
+ZEND_RSRC_DTOR_FUNC(php_zmq_context_dtor)
{
if (rsrc->ptr) {
- php_zeromq_context *ctx = (php_zeromq_context *)rsrc->ptr;
- php_zeromq_context_destroy(ctx);
+ php_zmq_context *ctx = (php_zmq_context *)rsrc->ptr;
+ php_zmq_context_destroy(ctx);
rsrc->ptr = NULL;
}
}
PHP_INI_BEGIN()
- STD_PHP_INI_ENTRY("zeromq.persist_context", "1", PHP_INI_SYSTEM, OnUpdateBool, persist_context, zend_zeromq_globals, zeromq_globals)
+ STD_PHP_INI_ENTRY("zmq.persist_context", "1", PHP_INI_SYSTEM, OnUpdateBool, persist_context, zend_php_zmq_globals, php_zmq_globals)
PHP_INI_END()
-static void php_zeromq_init_globals(zend_zeromq_globals *zeromq_globals)
+static void php_zmq_init_globals(zend_php_zmq_globals *zmq_globals)
{
- zeromq_globals->persist_context = 1;
+ zmq_globals->persist_context = 1;
}
-PHP_MINIT_FUNCTION(zeromq)
+PHP_MINIT_FUNCTION(zmq)
{
zend_class_entry ce;
- ZEND_INIT_MODULE_GLOBALS(zeromq, php_zeromq_init_globals, NULL);
+ ZEND_INIT_MODULE_GLOBALS(php_zmq, php_zmq_init_globals, NULL);
REGISTER_INI_ENTRIES();
- le_zeromq_socket = zend_register_list_destructors_ex(NULL, php_zeromq_socket_dtor, "ZeroMQ persistent socket", module_number);
- le_zeromq_context = zend_register_list_destructors_ex(NULL, php_zeromq_context_dtor, "ZeroMQ persistent context", module_number);
+ le_zmq_socket = zend_register_list_destructors_ex(NULL, php_zmq_socket_dtor, "ZMQ persistent socket", module_number);
+ le_zmq_context = zend_register_list_destructors_ex(NULL, php_zmq_context_dtor, "ZMQ persistent context", module_number);
- memcpy(&zeromq_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
- memcpy(&zeromq_poll_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ memcpy(&zmq_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ memcpy(&zmq_poll_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
- INIT_CLASS_ENTRY(ce, "ZeroMQ", php_zeromq_class_methods);
- ce.create_object = php_zeromq_object_new;
- zeromq_object_handlers.clone_obj = NULL;
- php_zeromq_sc_entry = zend_register_internal_class(&ce TSRMLS_CC);
+ INIT_CLASS_ENTRY(ce, "ZMQ", php_zmq_class_methods);
+ ce.create_object = php_zmq_object_new;
+ zmq_object_handlers.clone_obj = NULL;
+ php_zmq_sc_entry = zend_register_internal_class(&ce TSRMLS_CC);
- INIT_CLASS_ENTRY(ce, "ZeroMQPoll", php_zeromq_poll_class_methods);
- ce.create_object = php_zeromq_poll_object_new;
- zeromq_poll_object_handlers.clone_obj = NULL;
- php_zeromq_poll_sc_entry = zend_register_internal_class(&ce TSRMLS_CC);
+ INIT_CLASS_ENTRY(ce, "ZMQPoll", php_zmq_poll_class_methods);
+ ce.create_object = php_zmq_poll_object_new;
+ zmq_poll_object_handlers.clone_obj = NULL;
+ php_zmq_poll_sc_entry = zend_register_internal_class(&ce TSRMLS_CC);
- INIT_CLASS_ENTRY(ce, "ZeroMQException", NULL);
- php_zeromq_exception_sc_entry = zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC);
- php_zeromq_exception_sc_entry->ce_flags |= ZEND_ACC_FINAL;
+ INIT_CLASS_ENTRY(ce, "ZMQException", NULL);
+ php_zmq_exception_sc_entry = zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC);
+ php_zmq_exception_sc_entry->ce_flags |= ZEND_ACC_FINAL;
- INIT_CLASS_ENTRY(ce, "ZeroMQPollException", NULL);
- php_zeromq_poll_exception_sc_entry = zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC);
- php_zeromq_poll_exception_sc_entry->ce_flags |= ZEND_ACC_FINAL;
+ INIT_CLASS_ENTRY(ce, "ZMQPollException", NULL);
+ php_zmq_poll_exception_sc_entry = zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC);
+ php_zmq_poll_exception_sc_entry->ce_flags |= ZEND_ACC_FINAL;
-#define PHP_ZEROMQ_REGISTER_CONST_LONG(const_name, value) \
- zend_declare_class_constant_long(php_zeromq_sc_entry, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC);
+#define PHP_ZMQ_REGISTER_CONST_LONG(const_name, value) \
+ zend_declare_class_constant_long(php_zmq_sc_entry, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC);
/* Socket constants */
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKET_P2P", ZMQ_P2P);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKET_PUB", ZMQ_PUB);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKET_SUB", ZMQ_SUB);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKET_REQ", ZMQ_REQ);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKET_REP", ZMQ_REP);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKET_XREQ", ZMQ_XREQ);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKET_XREP", ZMQ_XREP);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKET_UPSTREAM", ZMQ_UPSTREAM);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKET_DOWNSTREAM", ZMQ_DOWNSTREAM);
-
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKOPT_HWM", ZMQ_HWM);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKOPT_LWM", ZMQ_LWM);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKOPT_SWAP", ZMQ_SWAP);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKOPT_AFFINITY", ZMQ_AFFINITY);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKOPT_IDENTITY", ZMQ_IDENTITY);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKOPT_SUBSCRIBE", ZMQ_SUBSCRIBE);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKOPT_UNSUBSCRIBE", ZMQ_UNSUBSCRIBE);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKOPT_RATE", ZMQ_RATE);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKOPT_RECOVERY_IVL", ZMQ_RECOVERY_IVL);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKOPT_MCAST_LOOP", ZMQ_MCAST_LOOP);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKOPT_SNDBUF", ZMQ_SNDBUF);
- PHP_ZEROMQ_REGISTER_CONST_LONG("SOCKOPT_RCVBUF", ZMQ_RCVBUF);
-
- PHP_ZEROMQ_REGISTER_CONST_LONG("POLL_IN", ZMQ_POLLIN);
- PHP_ZEROMQ_REGISTER_CONST_LONG("POLL_OUT", ZMQ_POLLOUT);
-
- PHP_ZEROMQ_REGISTER_CONST_LONG("MODE_NOBLOCK", ZMQ_NOBLOCK);
-
-#undef PHP_ZEROMQ_REGISTER_CONST_LONG
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKET_P2P", ZMQ_P2P);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKET_PUB", ZMQ_PUB);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKET_SUB", ZMQ_SUB);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKET_REQ", ZMQ_REQ);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKET_REP", ZMQ_REP);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKET_XREQ", ZMQ_XREQ);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKET_XREP", ZMQ_XREP);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKET_UPSTREAM", ZMQ_UPSTREAM);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKET_DOWNSTREAM", ZMQ_DOWNSTREAM);
+
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKOPT_HWM", ZMQ_HWM);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKOPT_LWM", ZMQ_LWM);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKOPT_SWAP", ZMQ_SWAP);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKOPT_AFFINITY", ZMQ_AFFINITY);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKOPT_IDENTITY", ZMQ_IDENTITY);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKOPT_SUBSCRIBE", ZMQ_SUBSCRIBE);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKOPT_UNSUBSCRIBE", ZMQ_UNSUBSCRIBE);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKOPT_RATE", ZMQ_RATE);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKOPT_RECOVERY_IVL", ZMQ_RECOVERY_IVL);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKOPT_MCAST_LOOP", ZMQ_MCAST_LOOP);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKOPT_SNDBUF", ZMQ_SNDBUF);
+ PHP_ZMQ_REGISTER_CONST_LONG("SOCKOPT_RCVBUF", ZMQ_RCVBUF);
+
+ PHP_ZMQ_REGISTER_CONST_LONG("POLL_IN", ZMQ_POLLIN);
+ PHP_ZMQ_REGISTER_CONST_LONG("POLL_OUT", ZMQ_POLLOUT);
+
+ PHP_ZMQ_REGISTER_CONST_LONG("MODE_NOBLOCK", ZMQ_NOBLOCK);
+
+#undef PHP_ZMQ_REGISTER_CONST_LONG
return SUCCESS;
}
-PHP_MSHUTDOWN_FUNCTION(zeromq)
+PHP_MSHUTDOWN_FUNCTION(zmq)
{
UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
-PHP_MINFO_FUNCTION(zeromq)
+PHP_MINFO_FUNCTION(zmq)
{
char *version;
int major = 0, minor = 0, patch = 0;
@@ -1156,8 +1156,8 @@ PHP_MINFO_FUNCTION(zeromq)
php_info_print_table_start();
- php_info_print_table_header(2, "ZeroMQ extension", "enabled");
- php_info_print_table_row(2, "ZeroMQ extension version", PHP_ZEROMQ_EXTVER);
+ php_info_print_table_header(2, "ZMQ extension", "enabled");
+ php_info_print_table_row(2, "ZMQ extension version", PHP_ZMQ_EXTVER);
php_info_print_table_row(2, "libzmq version", version);
php_info_print_table_end();
@@ -1166,20 +1166,20 @@ PHP_MINFO_FUNCTION(zeromq)
DISPLAY_INI_ENTRIES();
}
-zend_module_entry zeromq_module_entry =
+zend_module_entry zmq_module_entry =
{
STANDARD_MODULE_HEADER,
- PHP_ZEROMQ_EXTNAME,
- zeromq_functions, /* Functions */
- PHP_MINIT(zeromq), /* MINIT */
- PHP_MSHUTDOWN(zeromq), /* MSHUTDOWN */
+ PHP_ZMQ_EXTNAME,
+ zmq_functions, /* Functions */
+ PHP_MINIT(zmq), /* MINIT */
+ PHP_MSHUTDOWN(zmq), /* MSHUTDOWN */
NULL, /* RINIT */
NULL, /* RSHUTDOWN */
- PHP_MINFO(zeromq), /* MINFO */
- PHP_ZEROMQ_EXTVER, /* version */
+ PHP_MINFO(zmq), /* MINFO */
+ PHP_ZMQ_EXTVER, /* version */
STANDARD_MODULE_PROPERTIES
};
-#ifdef COMPILE_DL_ZEROMQ
-ZEND_GET_MODULE(zeromq)
-#endif /* COMPILE_DL_ZEROMQ */
+#ifdef COMPILE_DL_ZMQ
+ZEND_GET_MODULE(zmq)
+#endif /* COMPILE_DL_ZMQ */
View
16 zeromq.spec → zmq.spec
@@ -2,25 +2,25 @@
%define version @PACKAGE_VERSION@
%define release 1
-Name: php-zeromq
+Name: php-zmq
Version: %{version}
Release: %{release}%{?dist}
Packager: Mikko Koppanen <mkoppanen@php.net>
Summary: PHP 0MQ extension
License: BSD License
Group: Web/Applications
URL: http://github.com/mkoppanen/php-zeromq
-Source: zeromq-%{version}.tgz
+Source: zmq-%{version}.tgz
Prefix: %{_prefix}
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root
-BuildRequires: php-devel, make, gcc, /usr/bin/phpize, zeromq-devel >= 2.0.7
-Requires: zeromq >= 2.0.7
+BuildRequires: php-devel, make, gcc, /usr/bin/phpize, zmq-devel >= 2.0.7
+Requires: zmq >= 2.0.7
%description
PHP extension for 0MQ messaging system
%prep
-%setup -q -n zeromq-%{version}
+%setup -q -n zmq-%{version}
%build
/usr/bin/phpize && %configure && %{__make} %{?_smp_mflags}
@@ -35,14 +35,14 @@ PHP extension for 0MQ messaging system
%{__mkdir} -p %{buildroot}/etc/php.d
# Preliminary extension ini
-echo "extension=zeromq.so" > %{buildroot}/%{_sysconfdir}/php.d/zeromq.ini
+echo "extension=zmq.so" > %{buildroot}/%{_sysconfdir}/php.d/zmq.ini
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
%files
-%{_libdir}/php/modules/zeromq.so
-%{_sysconfdir}/php.d/zeromq.ini
+%{_libdir}/php/modules/zmq.so
+%{_sysconfdir}/php.d/zmq.ini
%changelog
* Thu Apr 8 2010 Mikko Koppanen <mkoppanen@php.net>

0 comments on commit 2826eaf

Please sign in to comment.
Something went wrong with that request. Please try again.