├── .gitattributes ├── CREDITS ├── mqseries.dsp ├── examples ├── mqing.php ├── test2.php ├── conn.php ├── test1.php ├── open.php ├── subTopic.php ├── pubTopic.php ├── get.php ├── put.php ├── mput.php ├── mtest.php ├── mqclient.php ├── connx.php ├── test.php ├── msgid.php ├── msgidput.php └── transaction.php ├── Makefile.private ├── README ├── LICENSE ├── config.m4 ├── php_mqseries.h ├── package.xml ├── mqseries_helper.c └── mqseries.c /.gitattributes: -------------------------------------------------------------------------------- 1 | mqseries.c ident 2 | -------------------------------------------------------------------------------- /CREDITS: -------------------------------------------------------------------------------- 1 | JAWA Management Software GmbH http://www.jawa.at -------------------------------------------------------------------------------- /mqseries.dsp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/php/pecl-networking-mqseries/master/mqseries.dsp -------------------------------------------------------------------------------- /examples/mqing.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/php/pecl-networking-mqseries/master/examples/mqing.php -------------------------------------------------------------------------------- /Makefile.private: -------------------------------------------------------------------------------- 1 | cvsclean: 2 | @for i in `find . -name .cvsignore`; do \ 3 | (cd `dirname $$i` 2>/dev/null && rm -rf `cat .cvsignore` *.o *.a .libs || true); \ 4 | done 5 | -------------------------------------------------------------------------------- /examples/test2.php: -------------------------------------------------------------------------------- 1 | "; 15 | ?> -------------------------------------------------------------------------------- /examples/conn.php: -------------------------------------------------------------------------------- 1 | \n", $comp_code, $reason, mqseries_strerror($reason)); 18 | exit; 19 | } 20 | 21 | mqseries_disc($conn, $comp_code, $reason); 22 | if ($comp_code !== MQSERIES_MQCC_OK) { 23 | printf("disc CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 24 | } 25 | 26 | echo "done.
"; 27 | ?> -------------------------------------------------------------------------------- /examples/test1.php: -------------------------------------------------------------------------------- 1 | MQSERIES_MQCNO_VERSION_2, 14 | 'Options' => MQSERIES_MQCNO_STANDARD_BINDING, 15 | 'MQCD' => array('ChannelName' => 'D800MQ.CLIENT', 16 | 'ConnectionName' => 'localhost', 17 | 'TransportType' => MQSERIES_MQXPT_TCP) 18 | ); 19 | 20 | mqseries_connx('D800MQ', 21 | &$mqcno, 22 | &$conn, 23 | &$comp_code, 24 | &$reason); 25 | 26 | /* 27 | if ($comp_code !== MQSERIES_MQCC_OK) { 28 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 29 | exit; 30 | } 31 | 32 | 33 | echo "done.
"; 34 | */ 35 | ?> -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | MQSERIES 2 | 3 | 4 | COMPILATION 5 | ----------- 6 | 7 | To compile the extension in your PHP, do as follows: 8 | 9 | - Uncompress the tarball 10 | - Run phpize 11 | - Run ./configure (for 64-bit you can use --with-libdir=lib64) 12 | - Run make. 13 | - Either load the extension dynamically into your scripts (with dl()) or add 14 | an extension= entry for it in your php.ini 15 | 16 | NOTE 17 | ---- 18 | By default the MQ Client Interface library is used. When building in a server only environment change te config.m4 file. 19 | 20 | USAGE 21 | ----- 22 | 23 | See the PHP scripts in the examples directory for an example of this 24 | library's usage 25 | 26 | 27 | REPORTING BUGS 28 | -------------- 29 | 30 | THIS EXTENSION IS HIGHLY EXPERIMENTAL (read: untested and unsupported). Please 31 | report all bugs and send all request/suggestions/quips/complaints to the 32 | PECL website 33 | -------------------------------------------------------------------------------- /examples/open.php: -------------------------------------------------------------------------------- 1 | MQSERIES_MQCNO_VERSION_2, 14 | 'Options' => MQSERIES_MQCNO_STANDARD_BINDING, 15 | 'MQCD' => array('ChannelName' => 'D800MQ.CLIENT', 16 | 'ConnectionName' => 'localhost', 17 | 'TransportType' => MQSERIES_MQXPT_TCP) 18 | ); 19 | 20 | mqseries_connx('D800MQ', 21 | &$mqcno, 22 | &$conn, 23 | &$comp_code, 24 | &$reason); 25 | if ($comp_code !== MQSERIES_MQCC_OK) { 26 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 27 | exit; 28 | } 29 | $mqods = array('ObjectName' => 'TESTQ', 'ObjectQMgrName' => 'D800MQ'); 30 | mqseries_open( 31 | $conn, 32 | &$mqods, 33 | MQSERIES_MQOO_INPUT_AS_Q_DEF | MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT, 34 | &$obj, 35 | &$comp_code, 36 | &$reason); 37 | if ($comp_code !== MQSERIES_MQCC_OK) { 38 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 39 | exit; 40 | } 41 | 42 | 43 | mqseries_close($conn, $obj, MQSERIES_MQCO_NONE, &$comp_code, &$reason); 44 | if ($comp_code !== MQSERIES_MQCC_OK) { 45 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 46 | } 47 | mqseries_disc($conn, &$comp_code, &$reason); 48 | if ($comp_code !== MQSERIES_MQCC_OK) { 49 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 50 | } 51 | 52 | echo "done.
"; 53 | ?> -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2003, JAWA Management Software GmbH http://www.jawa.at 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. The names of the authors may not be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 25 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | This code cannot simply be copied and put under the GNU Public License or 28 | any other GPL-like (LGPL, GPL2) License. 29 | -------------------------------------------------------------------------------- /config.m4: -------------------------------------------------------------------------------- 1 | dnl $Id$ 2 | dnl config.m4 for extension mqseries 3 | 4 | PHP_ARG_WITH(mqseries, for mqseries support, 5 | [ --with-mqseries Include mqseries support]) 6 | 7 | if test "$PHP_MQSERIES" != "no"; then 8 | dnl Write more examples of tests here... 9 | 10 | dnl # --with-mqseries -> check with-path 11 | SEARCH_PATH="/usr/local /usr /opt /opt/mqm" 12 | SEARCH_FOR="/inc/cmqcfc.h" 13 | if test -r $PHP_MQSERIES/; then 14 | MQSERIES_DIR=$PHP_MQSERIES 15 | else # search default path list 16 | AC_MSG_CHECKING([for mqseries files in default path]) 17 | for i in $SEARCH_PATH ; do 18 | if test -r $i/$SEARCH_FOR; then 19 | MQSERIES_DIR=$i 20 | AC_MSG_RESULT(found in $i) 21 | fi 22 | done 23 | fi 24 | 25 | if test -z "$MQSERIES_DIR"; then 26 | AC_MSG_RESULT([not found]) 27 | AC_MSG_ERROR([Please reinstall the mqseries distribution]) 28 | fi 29 | 30 | dnl # --with-mqseries -> add include path 31 | PHP_ADD_INCLUDE($MQSERIES_DIR/inc) 32 | 33 | dnl # --with-mqseries -> chech for lib and symbol presence 34 | # when using server only 35 | #LIBNAME=mqm # use this when connecting directly to the server 36 | LIBNAME=mqic # use this when connecting via the mqic (client) libraries. 37 | LIBSYMBOL=MQCONN 38 | 39 | PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, 40 | [ 41 | PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $MQSERIES_DIR/$PHP_LIBDIR, MQSERIES_SHARED_LIBADD) 42 | AC_DEFINE(HAVE_MQSERIESLIB,1,[ Define to 1 if you have mqseries lib >= 7.0]) 43 | ],[ 44 | AC_MSG_ERROR([wrong mqseries lib version or lib not found (use --with-libdir=lib64 for 64-bit) ]) 45 | ],[ 46 | -L$MQSERIES_DIR/$PHP_LIBDIR 47 | ]) 48 | 49 | dnl # --with-mqseries -> Check for lib version 50 | PHP_CHECK_LIBRARY($LIBNAME, MQSUB, 51 | [ 52 | AC_DEFINE(HAVE_MQSERIESLIB_V7,1,['Define to 1 if you have mqseries lib >= 7.0']) 53 | ],[ 54 | AC_MSG_RESULT('No support for pubsub') 55 | ],[ 56 | -L$MQSERIES_DIR/$PHP_LIBDIR 57 | ]) 58 | 59 | PHP_SUBST(MQSERIES_SHARED_LIBADD) 60 | 61 | PHP_NEW_EXTENSION(mqseries, mqseries.c mqseries_helper.c, $ext_shared) 62 | fi 63 | -------------------------------------------------------------------------------- /examples/subTopic.php: -------------------------------------------------------------------------------- 1 | MQSERIES_MQCNO_VERSION_2, 13 | 'Options' => MQSERIES_MQCNO_STANDARD_BINDING | 64, 14 | 'MQCD' => array( 15 | 'ChannelName' => $cfg['ESB_CHANNEL'], 16 | 'ConnectionName' => $cfg['ESB_ADDRESS'], 17 | 'TransportType' => MQSERIES_MQXPT_TCP 18 | ) 19 | ); 20 | 21 | mqseries_connx($cfg['ESB_QUEUE_MANAGER'], $connectionOptions, $connection, $completionCode, $reason); 22 | if ($completionCode !== MQSERIES_MQCC_OK) { 23 | die("Connx CompCode : {$completionCode} Reason : {$reason} Text : " . mqseries_strerror($reason)); 24 | } 25 | 26 | $subDesc = array( 27 | // 'ObjectName' => $cfg['ESB_QUEUE_NAME'], 28 | 'ObjectString' => $cfg['ESB_TOPIC_STRING'], 29 | 'Options' => MQSERIES_MQSO_CREATE | MQSERIES_MQSO_MANAGED | MQSERIES_MQSO_NON_DURABLE | MQSERIES_MQSO_FAIL_IF_QUIESCING, 30 | ); 31 | 32 | mqseries_sub($connection, $subDesc, $queue, $sub, $completionCode, $reason); 33 | if ($completionCode !== MQSERIES_MQCC_OK) { 34 | die("Connx CompCode : {$completionCode} Reason : {$reason} Text : " . mqseries_strerror($reason)); 35 | } 36 | 37 | $gmo = array( 38 | 'Options' => MQSERIES_MQGMO_WAIT, 39 | 'WaitInterval' => 10000, 40 | ); 41 | 42 | function inquireQname($connection, $queue, &$qname) 43 | { 44 | mqseries_inq($connection, $queue, 1, array(MQSERIES_MQCA_Q_MGR_NAME), 0, $int_attr, 48, $char_attr, $completionCode, $reason); 45 | if ($completionCode !== MQSERIES_MQCC_OK) { 46 | printf("MQINQ failed with Condition code %d and Reason %d\n", $completionCode, $reason); 47 | $qname = 'unknown queue'; 48 | } 49 | return; 50 | } 51 | 52 | inquireQname($connection, $queue, $qname); 53 | echo 'WAITING ', PHP_EOL; 54 | do { 55 | $messageFilter = array( 56 | ); 57 | $bytesLength = 10; 58 | mqseries_get($connection, $queue, $messageFilter, $gmo, $bytesLength, $messageContent, $data_length, $completionCode, $reason); 59 | var_dump($messageContent, $data_length);die(); 60 | } while($completionCode !== MQSERIES_MQCC_OK); 61 | 62 | die('FIN'); 63 | -------------------------------------------------------------------------------- /examples/pubTopic.php: -------------------------------------------------------------------------------- 1 | MQSERIES_MQCNO_VERSION_2, 13 | 'Options' => MQSERIES_MQCNO_STANDARD_BINDING | 64, 14 | 'MQCD' => array( 15 | 'ChannelName' => $cfg['ESB_CHANNEL'], 16 | 'ConnectionName' => $cfg['ESB_ADDRESS'], 17 | 'TransportType' => MQSERIES_MQXPT_TCP 18 | ) 19 | ); 20 | 21 | mqseries_connx($cfg['ESB_QUEUE_MANAGER'], $connectionOptions, $connection, $completionCode, $reason); 22 | if ($completionCode !== MQSERIES_MQCC_OK) { 23 | die("Connx CompCode : {$completionCode} Reason : {$reason} Text : " . mqseries_strerror($reason)); 24 | } 25 | 26 | $objDesc = array( 27 | 'Version' => MQSERIES_MQOD_VERSION_4, 28 | 'ObjectType' => MQSERIES_MQOT_TOPIC, 29 | // 'ObjectName' => $cfg['ESB_QUEUE_NAME'], 30 | 'ObjectString' => $cfg['ESB_TOPIC_STRING'], 31 | ); 32 | mqseries_open($connection, $objDesc, MQSERIES_MQOO_OUTPUT | MQSERIES_MQOO_FAIL_IF_QUIESCING, $queue, $completionCode, $reason); 33 | if ($completionCode !== MQSERIES_MQCC_OK) { 34 | die("Connx CompCode : {$completionCode} Reason : {$reason} Text : " . mqseries_strerror($reason)); 35 | } 36 | var_dump($objDesc); 37 | 38 | $md = array( 39 | 'Version' => MQSERIES_MQMD_VERSION_2, 40 | 'Format' => MQSERIES_MQFMT_STRING, 41 | 'CodedCharSetId' => 1208, 42 | ); 43 | 44 | $pmo = array( 45 | 'Options' => MQSERIES_MQPMO_FAIL_IF_QUIESCING 46 | ); 47 | mqseries_put($connection, $queue, $md, $pmo, 'Hello world', $completionCode, $reason); 48 | if ($completionCode !== MQSERIES_MQCC_OK) { 49 | die("Connx CompCode : {$completionCode} Reason : {$reason} Text : " . mqseries_strerror($reason)); 50 | } 51 | 52 | mqseries_close($connection, $queue, MQSERIES_MQCO_NONE, $completionCode, $reason); 53 | if ($completionCode !== MQSERIES_MQCC_OK) { 54 | die("Connx CompCode : {$completionCode} Reason : {$reason} Text : " . mqseries_strerror($reason)); 55 | } 56 | 57 | mqseries_disc($connection, $completionCode, $reason); 58 | if ($completionCode !== MQSERIES_MQCC_OK) { 59 | die("Connx CompCode : {$completionCode} Reason : {$reason} Text : " . mqseries_strerror($reason)); 60 | } 61 | 62 | die('FIN'); 63 | -------------------------------------------------------------------------------- /examples/get.php: -------------------------------------------------------------------------------- 1 | 35 | */ 36 | 37 | if(!extension_loaded('mqseries')) { 38 | if (preg_match('/windows/i', getenv('OS'))) { 39 | dl('php_mqseries.dll'); 40 | } else { 41 | if (!dl('mqseries.so')) exit; 42 | } 43 | } 44 | 45 | 46 | $mqcno = array( 47 | 'Version' => MQSERIES_MQCNO_VERSION_2, 48 | 'Options' => MQSERIES_MQCNO_STANDARD_BINDING, 49 | 'MQCD' => array('ChannelName' => 'MQNX9420.CLIENT', 50 | 'ConnectionName' => 'localhost', 51 | 'TransportType' => MQSERIES_MQXPT_TCP) 52 | ); 53 | 54 | mqseries_connx('MQNX9420', $mqcno, $conn, $comp_code,$reason); 55 | if ($comp_code !== MQSERIES_MQCC_OK) { 56 | printf("CONNX CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 57 | exit; 58 | } 59 | 60 | $mqods = array('ObjectName' => 'TESTQ', 'ObjectQMgrName' => 'MQNX9420'); 61 | mqseries_open( 62 | $conn, 63 | $mqods, 64 | MQSERIES_MQOO_INPUT_AS_Q_DEF | MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT, 65 | $obj, 66 | $comp_code, 67 | $reason); 68 | if ($comp_code !== MQSERIES_MQCC_OK) { 69 | printf("OPEN CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 70 | exit; 71 | } 72 | 73 | $mdg = array(); 74 | $gmo = array('Options' => MQSERIES_MQGMO_FAIL_IF_QUIESCING | MQSERIES_MQGMO_WAIT, 'WaitInterval' => 3000); 75 | mqseries_get( 76 | $conn, $obj, 77 | $mdg, 78 | $gmo, 79 | 255, 80 | $msg, 81 | $data_length, 82 | $comp_code, 83 | $reason); 84 | 85 | if ($comp_code !== MQSERIES_MQCC_OK) { 86 | printf("GET CompCode:%d Reason:%d Text:%s
", $comp_code, $reason, mqseries_strerror($reason)); 87 | } 88 | 89 | echo $msg."
"; 90 | 91 | mqseries_close($conn, $obj, MQSERIES_MQCO_NONE, $comp_code, $reason); 92 | if ($comp_code !== MQSERIES_MQCC_OK) { 93 | printf("CLOSE CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 94 | } 95 | mqseries_disc($conn, $comp_code, $reason); 96 | if ($comp_code !== MQSERIES_MQCC_OK) { 97 | printf("DISC CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 98 | } 99 | 100 | ?> -------------------------------------------------------------------------------- /examples/put.php: -------------------------------------------------------------------------------- 1 | 35 | */ 36 | 37 | if(!extension_loaded('mqseries')) { 38 | if (preg_match('/windows/i', getenv('OS'))) { 39 | dl('php_mqseries.dll'); 40 | } else { 41 | if (!dl('mqseries.so')) exit; 42 | } 43 | } 44 | 45 | 46 | $mqcno = array( 47 | 'Version' => MQSERIES_MQCNO_VERSION_2, 48 | 'Options' => MQSERIES_MQCNO_STANDARD_BINDING, 49 | 'MQCD' => array('ChannelName' => 'MQNX9420.CLIENT', 50 | 'ConnectionName' => 'localhost', 51 | 'TransportType' => MQSERIES_MQXPT_TCP) 52 | ); 53 | 54 | mqseries_connx('MQNX9420', $mqcno, $conn, $comp_code, $reason); 55 | if ($comp_code !== MQSERIES_MQCC_OK) { 56 | printf("CONNX CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 57 | exit; 58 | } 59 | $mqods = array('ObjectName' => 'TESTQ', 'ObjectQMgrName' => 'MQNX9420'); 60 | mqseries_open( 61 | $conn, 62 | $mqods, 63 | MQSERIES_MQOO_INPUT_AS_Q_DEF | MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT, 64 | $obj, 65 | $comp_code, 66 | $reason); 67 | if ($comp_code !== MQSERIES_MQCC_OK) { 68 | printf("OPEN CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 69 | exit; 70 | } 71 | 72 | $md = array( 73 | 'Version' => MQSERIES_MQMD_VERSION_1, 74 | 'Expiry' => MQSERIES_MQEI_UNLIMITED, 75 | 'Report' => MQSERIES_MQRO_NONE, 76 | 'MsgType' => MQSERIES_MQMT_DATAGRAM, 77 | 'Format' => MQSERIES_MQFMT_STRING, 78 | 'Priority' => 1, 79 | 'Persistence' => MQSERIES_MQPER_PERSISTENT); 80 | 81 | $pmo = array('Options' => MQSERIES_MQPMO_NEW_MSG_ID); 82 | mqseries_put( 83 | $conn, 84 | $obj, 85 | $md, 86 | $pmo, 87 | 'Ping', 88 | $comp_code, 89 | $reason); 90 | 91 | if ($comp_code !== MQSERIES_MQCC_OK) { 92 | printf("PUT CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 93 | } 94 | 95 | mqseries_close($conn, $obj, MQSERIES_MQCO_NONE, $comp_code, $reason); 96 | if ($comp_code !== MQSERIES_MQCC_OK) { 97 | printf("CLOSE CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 98 | } 99 | mqseries_disc($conn, $comp_code, $reason); 100 | if ($comp_code !== MQSERIES_MQCC_OK) { 101 | printf("DISC CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 102 | } 103 | 104 | echo "done.
"; 105 | ?> -------------------------------------------------------------------------------- /examples/mput.php: -------------------------------------------------------------------------------- 1 | 35 | */ 36 | 37 | if(!extension_loaded('mqseries')) { 38 | if (preg_match('/windows/i', getenv('OS'))) { 39 | dl('php_mqseries.dll'); 40 | } else { 41 | if (!dl('mqseries.so')) exit; 42 | } 43 | } 44 | 45 | 46 | $mqcno = array( 47 | 'Version' => MQSERIES_MQCNO_VERSION_2, 48 | 'Options' => MQSERIES_MQCNO_STANDARD_BINDING, 49 | 'MQCD' => array('ChannelName' => 'D800MQ.CLIENT', 50 | 'ConnectionName' => 'localhost', 51 | 'TransportType' => MQSERIES_MQXPT_TCP) 52 | ); 53 | 54 | mqseries_connx('D800MQ', 55 | &$mqcno, 56 | &$conn, 57 | &$comp_code, 58 | &$reason); 59 | if ($comp_code !== MQSERIES_MQCC_OK) { 60 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 61 | exit; 62 | } 63 | $mqods = array('ObjectName' => 'TESTQ', 'ObjectQMgrName' => 'D800MQ'); 64 | mqseries_open( 65 | $conn, 66 | &$mqods, 67 | MQSERIES_MQOO_INPUT_AS_Q_DEF | MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT, 68 | &$obj, 69 | &$comp_code, 70 | &$reason); 71 | if ($comp_code !== MQSERIES_MQCC_OK) { 72 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 73 | exit; 74 | } 75 | 76 | $md = array( 77 | 'Version' => MQSERIES_MQMD_VERSION_1, 78 | 'Expiry' => MQSERIES_MQEI_UNLIMITED, 79 | 'Report' => MQSERIES_MQRO_NONE, 80 | 'MsgType' => MQSERIES_MQMT_DATAGRAM, 81 | 'Format' => MQSERIES_MQFMT_STRING, 82 | 'Priority' => 1, 83 | 'Persistence' => MQSERIES_MQPER_PERSISTENT); 84 | 85 | $pmo = array('Options' => MQSERIES_MQPMO_NEW_MSG_ID); 86 | 87 | for ($i = 1; $i <= 10; $i++) { 88 | 89 | mqseries_put( 90 | $conn, 91 | $obj, 92 | &$md, 93 | &$pmo, 94 | 'Ping', 95 | &$comp_code, 96 | &$reason); 97 | 98 | 99 | if ($comp_code !== MQSERIES_MQCC_OK) { 100 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 101 | } 102 | 103 | } 104 | /* 105 | mqseries_close($conn, $obj, MQSERIES_MQCO_NONE, &$comp_code, &$reason); 106 | if ($comp_code !== MQSERIES_MQCC_OK) { 107 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 108 | } 109 | mqseries_disc($conn, &$comp_code, &$reason); 110 | if ($comp_code !== MQSERIES_MQCC_OK) { 111 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 112 | } 113 | */ 114 | 115 | echo "done.
"; 116 | ?> -------------------------------------------------------------------------------- /examples/mtest.php: -------------------------------------------------------------------------------- 1 | 35 | */ 36 | 37 | if(!extension_loaded('mqseries')) { 38 | if (preg_match('/windows/i', getenv('OS'))) { 39 | dl('php_mqseries.dll'); 40 | } else { 41 | if (!dl('mqseries.so')) exit; 42 | } 43 | } 44 | 45 | for ($i = 1; $i <= 10000; $i++) { 46 | 47 | $mqcno = array( 48 | 'Version' => MQSERIES_MQCNO_VERSION_2, 49 | 'Options' => MQSERIES_MQCNO_STANDARD_BINDING, 50 | 'MQCD' => array('ChannelName' => 'D800MQ.CLIENT', 51 | 'ConnectionName' => 'localhost', 52 | 'TransportType' => MQSERIES_MQXPT_TCP) 53 | ); 54 | 55 | mqseries_connx('D800MQ', 56 | &$mqcno, 57 | &$conn, 58 | &$comp_code, 59 | &$reason); 60 | if ($comp_code !== MQSERIES_MQCC_OK) { 61 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 62 | exit; 63 | } 64 | $mqods = array('ObjectName' => 'TESTQ', 'ObjectQMgrName' => 'D800MQ'); 65 | mqseries_open( 66 | $conn, 67 | &$mqods, 68 | MQSERIES_MQOO_INPUT_AS_Q_DEF | MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT, 69 | &$obj, 70 | &$comp_code, 71 | &$reason); 72 | if ($comp_code !== MQSERIES_MQCC_OK) { 73 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 74 | exit; 75 | } 76 | 77 | $md = array( 78 | 'Version' => MQSERIES_MQMD_VERSION_1, 79 | 'Expiry' => MQSERIES_MQEI_UNLIMITED, 80 | 'Report' => MQSERIES_MQRO_NONE, 81 | 'MsgType' => MQSERIES_MQMT_DATAGRAM, 82 | 'Format' => MQSERIES_MQFMT_STRING, 83 | 'Priority' => 1, 84 | 'Persistence' => MQSERIES_MQPER_PERSISTENT); 85 | 86 | $pmo = array('Options' => MQSERIES_MQPMO_NEW_MSG_ID); 87 | 88 | 89 | mqseries_put( 90 | $conn, 91 | $obj, 92 | &$md, 93 | &$pmo, 94 | 'Ping', 95 | &$comp_code, 96 | &$reason); 97 | 98 | 99 | if ($comp_code !== MQSERIES_MQCC_OK) { 100 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 101 | } 102 | 103 | 104 | mqseries_close($conn, $obj, MQSERIES_MQCO_NONE, &$comp_code, &$reason); 105 | if ($comp_code !== MQSERIES_MQCC_OK) { 106 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 107 | } 108 | mqseries_disc($conn, &$comp_code, &$reason); 109 | if ($comp_code !== MQSERIES_MQCC_OK) { 110 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 111 | } 112 | 113 | } 114 | 115 | echo "done.
"; 116 | ?> -------------------------------------------------------------------------------- /examples/mqclient.php: -------------------------------------------------------------------------------- 1 | 35 | */ 36 | 37 | if(!extension_loaded('mqseries')) { 38 | if (preg_match('/windows/i', getenv('OS'))) { 39 | dl('php_mqseries.dll'); 40 | } else { 41 | if (!dl('mqseries.so')) exit; 42 | } 43 | } 44 | 45 | $functions = get_extension_funcs('mqseries'); 46 | echo "Functions available in the test extension:
\n"; 47 | foreach($functions as $func) echo $func . "
\n"; 48 | 49 | // // 50 | //export MQSERVER=S_donald/TCP/donald 51 | 52 | echo 'mqseries_conn '; 53 | $conn = mqseries_conn('QM_donald'); 54 | if (is_resource($conn)) { 55 | echo "mqseries_conn ok $conn\n"; 56 | } else { 57 | printf("CompCode:%d Reason:%d Text:%s\n", $conn['comp_code'], $conn['reason'], mqseries_strerror($conn['reason'])); 58 | exit; 59 | } 60 | 61 | echo 'mqseries_open '; 62 | $obj = mqseries_open( 63 | $conn, 64 | array('ObjectName' => 'sft.qpf.sam', 'ObjectQMgrName' => 'QM_donald'), 65 | MQSERIES_MQOO_INPUT_AS_Q_DEF | MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT); 66 | if (is_resource($obj)) { 67 | echo "mqseries_open ok $obj\n"; 68 | } else { 69 | $err = mqseries_error($conn); 70 | printf("CompCode:%d Reason:%d Text:%s\n", $err['comp_code'], $err['reason'], mqseries_strerror($err['reason'])); 71 | exit; 72 | } 73 | 74 | echo 'mqseries_put '; 75 | $msg = mqseries_put( 76 | $conn, $obj, 77 | array( 78 | 'StrucId' => MQSERIES_MQMD_STRUC_ID, 79 | 'Version' => MQSERIES_MQMD_VERSION_1, 80 | 'Expiry' => MQSERIES_MQEI_UNLIMITED, 81 | 'Report' => MQSERIES_MQRO_NONE, 82 | 'MsgType' => MQSERIES_MQMT_DATAGRAM, 83 | 'Format' => MQSERIES_MQFMT_STRING, 84 | 'Priority' => 1, 85 | 'Persistence' => MQSERIES_MQPER_PERSISTENT 86 | ), 87 | array( 88 | 'Version' => MQSERIES_MQPMO_VERSION_1, 89 | 'Options' => MQSERIES_MQPMO_SYNCPOINT, 90 | 'StrucId' => MQSERIES_MQPMO_STRUC_ID 91 | ), 92 | 'Hallo alter fuchs'); 93 | if ($msg === false) { 94 | $err = mqseries_error($conn); 95 | printf("CompCode:%d Reason:%d Text:%s\n", $err['comp_code'], $err['reason'], mqseries_strerror($err['reason'])); 96 | } else { 97 | echo "ok\n"; 98 | } 99 | 100 | echo 'mqseries_get '; 101 | $msg = mqseries_get( 102 | $conn, $obj, 103 | array(), 104 | array( 105 | 'Options' => MQSERIES_MQGMO_FAIL_IF_QUIESCING | MQSERIES_MQGMO_SYNCPOINT | MQSERIES_MQGMO_WAIT, 106 | 'WaitInterval' => MQSERIES_MQWI_UNLIMITED), 107 | 65535); 108 | if ($msg === false) { 109 | $err = mqseries_error($conn); 110 | printf("CompCode:%d Reason:%d Text:%s\n", $err['comp_code'], $err['reason'], mqseries_strerror($err['reason'])); 111 | } else { 112 | echo "$msg\n"; 113 | } 114 | 115 | mqseries_close($obj); 116 | mqseries_disc($conn); 117 | 118 | ?> 119 | -------------------------------------------------------------------------------- /examples/connx.php: -------------------------------------------------------------------------------- 1 | 35 | */ 36 | 37 | if(!extension_loaded('mqseries')) { 38 | if (preg_match('/windows/i', getenv('OS'))) { 39 | dl('php_mqseries.dll'); 40 | } else { 41 | if (!dl('mqseries.so')) exit; 42 | } 43 | } 44 | 45 | $mqcno = array( 46 | 'Version' => MQSERIES_MQCNO_VERSION_2, 47 | 'Options' => MQSERIES_MQCNO_STANDARD_BINDING, 48 | 'MQCD' => array('ChannelName' => 'MQNX9420.CLIENT', 49 | 'ConnectionName' => 'localhost', 50 | 'TransportType' => MQSERIES_MQXPT_TCP) 51 | ); 52 | 53 | mqseries_connx('MQNX9420', $mqcno, $conn, $comp_code,$reason); 54 | if ($comp_code !== MQSERIES_MQCC_OK) { 55 | printf("Connx CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 56 | exit; 57 | } 58 | 59 | 60 | $mqods = array('ObjectType' => MQSERIES_MQOT_Q_MGR); 61 | mqseries_open($conn, $mqods, MQSERIES_MQOO_INQUIRE | MQSERIES_MQOO_FAIL_IF_QUIESCING, 62 | $obj, $comp_code, $reason); 63 | if ($comp_code !== MQSERIES_MQCC_OK) { 64 | printf("Open CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 65 | exit; 66 | } 67 | 68 | $mqods = array('ObjectName' => 'TESTQ', 'ObjectQMgrName' => 'MQNX9420'); 69 | mqseries_open( 70 | $conn, 71 | $mqods, 72 | MQSERIES_MQOO_INQUIRE | MQSERIES_MQOO_INPUT_AS_Q_DEF | MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT, 73 | $obj_snd, 74 | $comp_code, 75 | $reason); 76 | if ($comp_code !== MQSERIES_MQCC_OK) { 77 | printf("Open CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 78 | exit; 79 | } 80 | 81 | 82 | $int_attr = array(); 83 | $char_attr = ""; 84 | 85 | mqseries_inq($conn, $obj, 1, array(MQSERIES_MQCA_Q_MGR_NAME), 0, $int_attr, 48, $char_attr, $comp_code, $reason); 86 | 87 | if ($comp_code !== MQSERIES_MQCC_OK) { 88 | printf("INQ CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 89 | } else { 90 | echo "INQ QManager name result ".$char_attr."
\n"; 91 | } 92 | 93 | mqseries_inq($conn, $obj_snd, 2, array(MQSERIES_MQCA_Q_NAME,MQSERIES_MQIA_MAX_Q_DEPTH), 1, $int_attr, 48, $char_attr, $comp_code, $reason); 94 | 95 | if ($comp_code !== MQSERIES_MQCC_OK) { 96 | printf("INQ CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 97 | } else { 98 | echo "INQ TESTQ result
qname=".$char_attr."
max queue depth=".$int_attr[0]."
"; 99 | } 100 | 101 | 102 | mqseries_close($conn, $obj, MQSERIES_MQCO_NONE, $comp_code, $reason); 103 | if ($comp_code !== MQSERIES_MQCC_OK) { 104 | printf("CLOSE CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 105 | } 106 | mqseries_disc($conn, $comp_code, $reason); 107 | if ($comp_code !== MQSERIES_MQCC_OK) { 108 | printf("DISC CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 109 | } 110 | 111 | ?> -------------------------------------------------------------------------------- /examples/test.php: -------------------------------------------------------------------------------- 1 | 35 | */ 36 | 37 | if(!extension_loaded('mqseries')) { 38 | if (preg_match('/windows/i', getenv('OS'))) { 39 | dl('php_mqseries.dll'); 40 | } else { 41 | if (!dl('mqseries.so')) exit; 42 | } 43 | } 44 | 45 | 46 | $mqcno = array( 47 | 'Version' => MQSERIES_MQCNO_VERSION_2, 48 | 'Options' => MQSERIES_MQCNO_STANDARD_BINDING, 49 | 'MQCD' => array('ChannelName' => 'D800MQ.CLIENT', 50 | 'ConnectionName' => 'localhost', 51 | 'TransportType' => MQSERIES_MQXPT_TCP) 52 | ); 53 | 54 | mqseries_connx('D800MQ', 55 | &$mqcno, 56 | &$conn, 57 | &$comp_code, 58 | &$reason); 59 | if ($comp_code !== MQSERIES_MQCC_OK) { 60 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 61 | exit; 62 | } 63 | $mqods = array('ObjectName' => 'ACCOUNTING', 'ObjectQMgrName' => 'D800MQ'); 64 | mqseries_open( 65 | $conn, 66 | &$mqods, 67 | MQSERIES_MQOO_INPUT_AS_Q_DEF | MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT, 68 | &$obj, 69 | &$comp_code, 70 | &$reason); 71 | if ($comp_code !== MQSERIES_MQCC_OK) { 72 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 73 | exit; 74 | } 75 | 76 | $md = array( 77 | 'Version' => MQSERIES_MQMD_VERSION_1, 78 | 'Expiry' => MQSERIES_MQEI_UNLIMITED, 79 | 'Report' => MQSERIES_MQRO_NONE, 80 | 'MsgType' => MQSERIES_MQMT_DATAGRAM, 81 | 'Format' => MQSERIES_MQFMT_STRING, 82 | 'Priority' => 1, 83 | 'Persistence' => MQSERIES_MQPER_PERSISTENT); 84 | $pmo = array('Options' => MQSERIES_MQPMO_NEW_MSG_ID); 85 | 86 | $msg = ''. 87 | ''. 88 | '0'. 89 | ''. 90 | 'AKW REGNR. 444.134.565'. 91 | 'AKW REGNR. 444.134.565 1E. KW. 2005 KINDERBIJSLAG AKW VESTIGING NIJMEGEN P'. 92 | ''. 93 | 'VZ'. 94 | 'Verzamelgiro'. 95 | ''. 96 | ''. 97 | '4501847'. 98 | ''. 99 | ''. 100 | '10.0'. 101 | ''. 102 | ''; 103 | 104 | mqseries_put( 105 | $conn, 106 | $obj, 107 | &$md, 108 | &$pmo, 109 | 'verwerkTransactie'.$msg.'', 110 | &$comp_code, 111 | &$reason); 112 | 113 | if ($comp_code !== MQSERIES_MQCC_OK) { 114 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 115 | } 116 | 117 | echo "md ="; 118 | print_r($md); 119 | echo "

"; 120 | echo "pmo="; 121 | print_r($pmo); 122 | echo "

"; 123 | 124 | mqseries_close($conn, $obj, MQSERIES_MQCO_NONE, &$comp_code, &$reason); 125 | if ($comp_code !== MQSERIES_MQCC_OK) { 126 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 127 | } 128 | mqseries_disc($conn, &$comp_code, &$reason); 129 | if ($comp_code !== MQSERIES_MQCC_OK) { 130 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 131 | } 132 | echo "done.
"; 133 | ?> 134 | -------------------------------------------------------------------------------- /php_mqseries.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2003, JAWA Management Software GmbH http://www.jawa.at 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 3. The names of the authors may not be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | This code cannot simply be copied and put under the GNU Public License or 29 | any other GPL-like (LGPL, GPL2) License. 30 | 31 | $Id$ 32 | 33 | Author: Michael Bretterklieber 34 | philippe Tjon A Hen 35 | Pierrick Charron 36 | */ 37 | 38 | #ifndef PHP_MQSERIES_H 39 | #define PHP_MQSERIES_H 40 | 41 | #include "cmqc.h" /* MQI */ 42 | #include "cmqcfc.h" /* PCF */ 43 | #include "cmqbc.h" /* MQAI */ 44 | #include "cmqxc.h" /* MQCD */ 45 | 46 | #define phpext_mqseries_ptr &mqseries_module_entry 47 | 48 | #define PHP_MQSERIES_VERSION "0.15.0" 49 | 50 | #ifdef PHP_WIN32 51 | #define PHP_MQSERIES_API __declspec(dllexport) 52 | #else 53 | #define PHP_MQSERIES_API 54 | #endif 55 | 56 | #ifdef ZTS 57 | #include "TSRM.h" 58 | #endif 59 | 60 | extern zend_module_entry mqseries_module_entry; 61 | 62 | typedef struct { 63 | int id; 64 | MQHCONN conn; 65 | } mqseries_descriptor; 66 | extern int le_mqseries_conn; 67 | #define PHP_MQSERIES_DESCRIPTOR_RES_NAME "mqseries_conn" 68 | 69 | typedef struct { 70 | int id; 71 | MQHOBJ obj; 72 | MQHCONN *conn; 73 | } mqseries_obj; 74 | extern int le_mqseries_obj; 75 | #define PHP_MQSERIES_OBJ_RES_NAME "mqseries_obj" 76 | 77 | typedef struct { 78 | int id; 79 | PMQBYTE bytes; 80 | } mqseries_bytes; 81 | extern int le_mqseries_bytes; 82 | #define PHP_MQSERIES_BYTES_RES_NAME "mqseries_bytes" 83 | 84 | /* {{{ Helper */ 85 | void _mqseries_set_mqcno_from_array(zval *, PMQCNO, PMQCD, PMQSCO, PMQAIR, PMQCHAR); 86 | 87 | void _mqseries_set_mqpmo_from_array(zval *, PMQPMO); 88 | void _mqseries_set_array_from_mqpmo(zval *, PMQPMO); 89 | 90 | void _mqseries_set_mqmd_from_array(zval *, PMQMD); 91 | void _mqseries_set_array_from_mqmd(zval *, PMQMD); 92 | 93 | void _mqseries_set_mqod_from_array(zval *, PMQOD); 94 | void _mqseries_set_array_from_mqod(zval *, PMQOD); 95 | 96 | void _mqseries_set_mqgmo_from_array(zval *, PMQGMO); 97 | void _mqseries_set_array_from_mqgmo(zval *, PMQGMO); 98 | 99 | void _mqseries_set_mqbo_from_array(zval *, PMQBO); 100 | 101 | #ifdef HAVE_MQSERIESLIB_V7 102 | 103 | void _mqseries_set_mqsd_from_array(zval *, PMQSD); 104 | void _mqseries_set_array_from_mqsd(zval *, PMQSD); 105 | 106 | void _mqseries_set_mqsts_from_array(zval *, PMQSTS); 107 | void _mqseries_set_array_from_mqsts(zval *, PMQSTS); 108 | 109 | #endif /* HAVE_MQSERIESLIB_V7 */ 110 | /* }}} */ 111 | 112 | PHP_MINIT_FUNCTION(mqseries); 113 | PHP_MSHUTDOWN_FUNCTION(mqseries); 114 | PHP_RINIT_FUNCTION(mqseries); 115 | PHP_RSHUTDOWN_FUNCTION(mqseries); 116 | PHP_MINFO_FUNCTION(mqseries); 117 | 118 | PHP_FUNCTION(mqseries_back); 119 | PHP_FUNCTION(mqseries_begin); 120 | PHP_FUNCTION(mqseries_close); 121 | PHP_FUNCTION(mqseries_cmit); 122 | PHP_FUNCTION(mqseries_conn); 123 | PHP_FUNCTION(mqseries_connx); 124 | PHP_FUNCTION(mqseries_disc); 125 | PHP_FUNCTION(mqseries_get); 126 | PHP_FUNCTION(mqseries_inq); 127 | PHP_FUNCTION(mqseries_open); 128 | PHP_FUNCTION(mqseries_put); 129 | PHP_FUNCTION(mqseries_put1); 130 | PHP_FUNCTION(mqseries_set); 131 | PHP_FUNCTION(mqseries_error); 132 | PHP_FUNCTION(mqseries_strerror); 133 | PHP_FUNCTION(mqseries_bytes_val); 134 | 135 | #ifdef HAVE_MQSERIESLIB_V7 136 | // PHP_FUNCTION(mqseries_bufmh); 137 | // PHP_FUNCTION(mqseries_cb); 138 | // PHP_FUNCTION(mqseries_cb_function); 139 | // PHP_FUNCTION(mqseries_crtmh); 140 | // PHP_FUNCTION(mqseries_ctl); 141 | // PHP_FUNCTION(mqseries_dltmh); 142 | // PHP_FUNCTION(mqseries_dltmp); 143 | // PHP_FUNCTION(mqseries_inqmp); 144 | // PHP_FUNCTION(mqseries_mhbuf); 145 | // PHP_FUNCTION(mqseries_setmp); 146 | PHP_FUNCTION(mqseries_stat); 147 | PHP_FUNCTION(mqseries_sub); 148 | // PHP_FUNCTION(mqseries_subrq); 149 | #endif /* HAVE_MQSERIESLIB_V7 */ 150 | 151 | #ifdef ZTS 152 | #define MQSERIES_G(v) TSRMG(mqseries_globals_id, zend_mqseries_globals *, v) 153 | #else 154 | #define MQSERIES_G(v) (mqseries_globals.v) 155 | #endif 156 | 157 | #endif /* PHP_MQSERIES_H */ 158 | 159 | /* 160 | * Local variables: 161 | * tab-width: 4 162 | * c-basic-offset: 4 163 | * indent-tabs-mode: t 164 | * End: 165 | */ 166 | -------------------------------------------------------------------------------- /examples/msgid.php: -------------------------------------------------------------------------------- 1 | 35 | */ 36 | 37 | if(!extension_loaded('mqseries')) { 38 | if (preg_match('/windows/i', getenv('OS'))) { 39 | dl('php_mqseries.dll'); 40 | } else { 41 | if (!dl('mqseries.so')) exit; 42 | } 43 | } 44 | 45 | 46 | echo 'mqseries_connx D800MQ
'; 47 | $mqcno = array( 48 | 'Version' => MQSERIES_MQCNO_VERSION_2, 49 | 'Options' => MQSERIES_MQCNO_STANDARD_BINDING, 50 | 'MQCD' => array('ChannelName' => 'D800MQ.CLIENT', 51 | 'ConnectionName' => 'localhost', 52 | 'TransportType' => MQSERIES_MQXPT_TCP) 53 | ); 54 | 55 | mqseries_connx('D800MQ', 56 | &$mqcno, 57 | &$conn, 58 | &$comp_code, 59 | &$reason); 60 | if ($comp_code !== MQSERIES_MQCC_OK) { 61 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 62 | exit; 63 | } 64 | echo 'mqcno
'; 65 | print_r($mqcno); 66 | echo "

"; 67 | 68 | echo 'mqseries_open sendQ
'; 69 | $mqods = array('ObjectName' => 'TESTQ', 'ObjectQMgrName' => 'D800MQ'); 70 | mqseries_open( 71 | $conn, 72 | &$mqods, 73 | MQSERIES_MQOO_INPUT_AS_Q_DEF | MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT, 74 | &$obj_snd, 75 | &$comp_code, 76 | &$reason); 77 | if ($comp_code !== MQSERIES_MQCC_OK) { 78 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 79 | exit; 80 | } 81 | 82 | echo 'mqod send
'; 83 | print_r($mqods); 84 | echo "

"; 85 | 86 | echo 'mqseries_open receiveQ
'; 87 | $mqodr = array('ObjectName' => 'RCVQ', 'ObjectQMgrName' => 'D800MQ'); 88 | 89 | mqseries_open( 90 | $conn, 91 | &$mqodr, 92 | MQSERIES_MQOO_INPUT_AS_Q_DEF | MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT, 93 | &$obj_rcv, 94 | &$comp_code, 95 | &$reason); 96 | if ($comp_code !== MQSERIES_MQCC_OK) { 97 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 98 | exit; 99 | } 100 | echo 'mqod receive
'; 101 | print_r($mqodr); 102 | echo "

"; 103 | 104 | 105 | echo 'mqseries_put
'; 106 | 107 | $md = array( 108 | 'Version' => MQSERIES_MQMD_VERSION_1, 109 | 'Expiry' => MQSERIES_MQEI_UNLIMITED, 110 | 'Report' => MQSERIES_MQRO_NONE, 111 | 'MsgType' => MQSERIES_MQMT_DATAGRAM, 112 | 'Format' => MQSERIES_MQFMT_STRING, 113 | 'Priority' => 1, 114 | 'Persistence' => MQSERIES_MQPER_PERSISTENT, 115 | 'ReplyToQ' => 'RCVQ'); 116 | $pmo = array('Options' => MQSERIES_MQPMO_NEW_MSG_ID); 117 | mqseries_put( 118 | $conn, 119 | $obj_snd, 120 | &$md, 121 | &$pmo, 122 | 'Ping', 123 | &$comp_code, 124 | &$reason); 125 | 126 | if ($comp_code !== MQSERIES_MQCC_OK) { 127 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 128 | } 129 | echo 'mqmd put
'; 130 | print_r($md); 131 | echo "

"; 132 | echo 'mqpmo put
'; 133 | print_r($pmo); 134 | echo "

"; 135 | 136 | echo 'mqseries_get
'; 137 | $mdg = array("CorrelId" => $md["MsgId"]); 138 | $gmo = array('Options' => MQSERIES_MQGMO_FAIL_IF_QUIESCING | MQSERIES_MQGMO_WAIT | MQSERIES_MQGMO_CONVERT, 139 | 'WaitInterval' => 3000); 140 | 141 | mqseries_get( 142 | $conn, $obj_rcv, 143 | &$mdg, 144 | &$gmo, 145 | 255, 146 | &$msg, 147 | &$data_length, 148 | &$comp_code, 149 | &$reason); 150 | 151 | if ($comp_code !== MQSERIES_MQCC_OK) { 152 | printf("CompCode:%d Reason:%d Text:%s
", $comp_code, $reason, mqseries_strerror($reason)); 153 | } 154 | echo 'mqmd get
'; 155 | print_r($mdg); 156 | echo "

"; 157 | echo 'mqgmo
'; 158 | print_r($gmo); 159 | echo "

"; 160 | 161 | echo "received=".$msg."
"; 162 | 163 | echo 'mqseries_close
'; 164 | mqseries_close($conn, $obj_snd, MQSERIES_MQCO_NONE, &$comp_code, &$reason); 165 | if ($comp_code !== MQSERIES_MQCC_OK) { 166 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 167 | } 168 | mqseries_close($conn, $obj_rcv, MQSERIES_MQCO_NONE, &$comp_code, &$reason); 169 | if ($comp_code !== MQSERIES_MQCC_OK) { 170 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 171 | } 172 | echo 'mqseries_disc
'; 173 | mqseries_disc($conn, &$comp_code, &$reason); 174 | if ($comp_code !== MQSERIES_MQCC_OK) { 175 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 176 | } 177 | 178 | ?> 179 | -------------------------------------------------------------------------------- /examples/msgidput.php: -------------------------------------------------------------------------------- 1 | 35 | */ 36 | 37 | if(!extension_loaded('mqseries')) { 38 | if (preg_match('/windows/i', getenv('OS'))) { 39 | dl('php_mqseries.dll'); 40 | } else { 41 | if (!dl('mqseries.so')) exit; 42 | } 43 | } 44 | 45 | 46 | echo 'mqseries_connx D800MQ
'; 47 | $mqcno = array( 48 | 'Version' => MQSERIES_MQCNO_VERSION_2, 49 | 'Options' => MQSERIES_MQCNO_STANDARD_BINDING, 50 | 'MQCD' => array('ChannelName' => 'D800MQ.CLIENT', 51 | 'ConnectionName' => 'localhost', 52 | 'TransportType' => MQSERIES_MQXPT_TCP) 53 | ); 54 | 55 | mqseries_connx('D800MQ', 56 | &$mqcno, 57 | &$conn, 58 | &$comp_code, 59 | &$reason); 60 | if ($comp_code !== MQSERIES_MQCC_OK) { 61 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 62 | exit; 63 | } 64 | echo 'mqcno
'; 65 | print_r($mqcno); 66 | echo "

"; 67 | 68 | echo 'mqseries_open sendQ
'; 69 | $mqods = array('ObjectName' => 'TESTQ', 'ObjectQMgrName' => 'D800MQ'); 70 | mqseries_open( 71 | $conn, 72 | &$mqods, 73 | MQSERIES_MQOO_INPUT_AS_Q_DEF | MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT, 74 | &$obj_snd, 75 | &$comp_code, 76 | &$reason); 77 | if ($comp_code !== MQSERIES_MQCC_OK) { 78 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 79 | exit; 80 | } 81 | 82 | echo 'mqod send
'; 83 | print_r($mqods); 84 | echo "

"; 85 | 86 | echo 'mqseries_open receiveQ
'; 87 | $mqodr = array('ObjectName' => 'RCVQ', 'ObjectQMgrName' => 'D800MQ'); 88 | 89 | mqseries_open( 90 | $conn, 91 | &$mqodr, 92 | MQSERIES_MQOO_INPUT_AS_Q_DEF | MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT, 93 | &$obj_rcv, 94 | &$comp_code, 95 | &$reason); 96 | if ($comp_code !== MQSERIES_MQCC_OK) { 97 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 98 | exit; 99 | } 100 | echo 'mqod receive
'; 101 | print_r($mqodr); 102 | echo "

"; 103 | 104 | 105 | echo 'mqseries_put
'; 106 | 107 | $md = array( 108 | 'Version' => MQSERIES_MQMD_VERSION_1, 109 | 'Expiry' => MQSERIES_MQEI_UNLIMITED, 110 | 'Report' => MQSERIES_MQRO_NONE, 111 | 'MsgType' => MQSERIES_MQMT_DATAGRAM, 112 | 'Format' => MQSERIES_MQFMT_STRING, 113 | 'Priority' => 1, 114 | 'Persistence' => MQSERIES_MQPER_PERSISTENT, 115 | 'ReplyToQ' => 'RCVQ', 116 | 'MsgId' => 'MyGeneratedId'); 117 | $pmo = array(); 118 | mqseries_put( 119 | $conn, 120 | $obj_snd, 121 | &$md, 122 | &$pmo, 123 | 'Ping', 124 | &$comp_code, 125 | &$reason); 126 | 127 | if ($comp_code !== MQSERIES_MQCC_OK) { 128 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 129 | } 130 | echo 'mqmd put
'; 131 | print_r($md); 132 | echo "

"; 133 | echo 'mqpmo put
'; 134 | print_r($pmo); 135 | echo "

"; 136 | 137 | echo 'mqseries_get
'; 138 | $mdg = array("CorrelId" => $md["MsgId"]); 139 | $gmo = array('Options' => MQSERIES_MQGMO_FAIL_IF_QUIESCING | MQSERIES_MQGMO_WAIT | MQSERIES_MQGMO_CONVERT, 140 | 'WaitInterval' => 3000); 141 | 142 | mqseries_get( 143 | $conn, $obj_rcv, 144 | &$mdg, 145 | &$gmo, 146 | 255, 147 | &$msg, 148 | &$data_length, 149 | &$comp_code, 150 | &$reason); 151 | 152 | if ($comp_code !== MQSERIES_MQCC_OK) { 153 | printf("CompCode:%d Reason:%d Text:%s
", $comp_code, $reason, mqseries_strerror($reason)); 154 | } 155 | echo 'mqmd get
'; 156 | print_r($mdg); 157 | echo "

"; 158 | echo 'mqgmo
'; 159 | print_r($gmo); 160 | echo "

"; 161 | 162 | echo "received=".$msg."
"; 163 | 164 | echo 'mqseries_close
'; 165 | mqseries_close($conn, $obj_snd, MQSERIES_MQCO_NONE, &$comp_code, &$reason); 166 | if ($comp_code !== MQSERIES_MQCC_OK) { 167 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 168 | } 169 | mqseries_close($conn, $obj_rcv, MQSERIES_MQCO_NONE, &$comp_code, &$reason); 170 | if ($comp_code !== MQSERIES_MQCC_OK) { 171 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 172 | } 173 | echo 'mqseries_disc
'; 174 | mqseries_disc($conn, &$comp_code, &$reason); 175 | if ($comp_code !== MQSERIES_MQCC_OK) { 176 | printf("CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 177 | } 178 | 179 | ?> 180 | -------------------------------------------------------------------------------- /examples/transaction.php: -------------------------------------------------------------------------------- 1 | 35 | */ 36 | 37 | if(!extension_loaded('mqseries')) { 38 | if (preg_match('/windows/i', getenv('OS'))) { 39 | dl('php_mqseries.dll'); 40 | } else { 41 | if (!dl('mqseries.so')) exit; 42 | } 43 | } 44 | 45 | /* 46 | 47 | Make sure you have a server connection. Transactions will not work for client env only 48 | 49 | */ 50 | 51 | mqseries_conn('', 52 | &$conn, 53 | &$comp_code, 54 | &$reason); 55 | if ($comp_code !== MQSERIES_MQCC_OK) { 56 | printf("conn CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 57 | exit; 58 | } 59 | $mqods = array('ObjectName' => 'TESTQ'); 60 | mqseries_open( 61 | $conn, 62 | &$mqods, 63 | MQSERIES_MQOO_INPUT_AS_Q_DEF | MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT, 64 | &$obj, 65 | &$comp_code, 66 | &$reason); 67 | if ($comp_code !== MQSERIES_MQCC_OK) { 68 | printf("open CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 69 | exit; 70 | } 71 | 72 | /* begin transaction */ 73 | $mqbo = array(); 74 | mqseries_begin( $conn, 75 | &$mqbo, 76 | &$comp_code, 77 | &$reason); 78 | if ($comp_code !== MQSERIES_MQCC_OK) { 79 | /* reason code 2121 is a warning */ 80 | if ($reason !== 2121) { 81 | printf("begin CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 82 | } 83 | } 84 | 85 | 86 | $md = array( 87 | 'Version' => MQSERIES_MQMD_VERSION_1, 88 | 'Expiry' => MQSERIES_MQEI_UNLIMITED, 89 | 'Report' => MQSERIES_MQRO_NONE, 90 | 'MsgType' => MQSERIES_MQMT_DATAGRAM, 91 | 'Format' => MQSERIES_MQFMT_STRING, 92 | 'Priority' => 1, 93 | 'Persistence' => MQSERIES_MQPER_PERSISTENT); 94 | 95 | $pmo = array('Options' => MQSERIES_MQPMO_NEW_MSG_ID|MQSERIES_MQPMO_SYNCPOINT); 96 | 97 | /* Sending multiple messages */ 98 | mqseries_put( 99 | $conn, 100 | $obj, 101 | &$md, 102 | &$pmo, 103 | 'Ping', 104 | &$comp_code, 105 | &$reason); 106 | 107 | if ($comp_code !== MQSERIES_MQCC_OK) { 108 | printf("put CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 109 | } 110 | 111 | $md = array( 112 | 'Version' => MQSERIES_MQMD_VERSION_1, 113 | 'Expiry' => MQSERIES_MQEI_UNLIMITED, 114 | 'Report' => MQSERIES_MQRO_NONE, 115 | 'MsgType' => MQSERIES_MQMT_DATAGRAM, 116 | 'Format' => MQSERIES_MQFMT_STRING, 117 | 'Priority' => 1, 118 | 'Persistence' => MQSERIES_MQPER_PERSISTENT); 119 | 120 | $pmo = array('Options' => MQSERIES_MQPMO_NEW_MSG_ID|MQSERIES_MQPMO_SYNCPOINT); 121 | mqseries_put( 122 | $conn, 123 | $obj, 124 | &$md, 125 | &$pmo, 126 | 'Ping', 127 | &$comp_code, 128 | &$reason); 129 | 130 | if ($comp_code !== MQSERIES_MQCC_OK) { 131 | printf("put CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 132 | } 133 | 134 | $md = array( 135 | 'Version' => MQSERIES_MQMD_VERSION_1, 136 | 'Expiry' => MQSERIES_MQEI_UNLIMITED, 137 | 'Report' => MQSERIES_MQRO_NONE, 138 | 'MsgType' => MQSERIES_MQMT_DATAGRAM, 139 | 'Format' => MQSERIES_MQFMT_STRING, 140 | 'Priority' => 1, 141 | 'Persistence' => MQSERIES_MQPER_PERSISTENT); 142 | 143 | $pmo = array('Options' => MQSERIES_MQPMO_NEW_MSG_ID|MQSERIES_MQPMO_SYNCPOINT); 144 | mqseries_put( 145 | $conn, 146 | $obj, 147 | &$md, 148 | &$pmo, 149 | 'Ping', 150 | &$comp_code, 151 | &$reason); 152 | 153 | if ($comp_code !== MQSERIES_MQCC_OK) { 154 | printf("put CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 155 | } 156 | 157 | /* 158 | Commit transaction, this should release the three puts 159 | */ 160 | mqseries_cmit( $conn, 161 | &$comp_code, 162 | &$reason); 163 | 164 | if ($comp_code !== MQSERIES_MQCC_OK) { 165 | printf("cmit CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 166 | } 167 | 168 | /* 169 | Backout transaction, eg rollback no messages will be send 170 | mqseries_back( $conn, 171 | &$comp_code, 172 | &$reason); 173 | 174 | if ($comp_code !== MQSERIES_MQCC_OK) { 175 | printf("cmit CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 176 | } 177 | */ 178 | 179 | mqseries_close($conn, $obj, MQSERIES_MQCO_NONE, &$comp_code, &$reason); 180 | if ($comp_code !== MQSERIES_MQCC_OK) { 181 | printf("close CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 182 | } 183 | mqseries_disc($conn, &$comp_code, &$reason); 184 | if ($comp_code !== MQSERIES_MQCC_OK) { 185 | printf("disc CompCode:%d Reason:%d Text:%s
\n", $comp_code, $reason, mqseries_strerror($reason)); 186 | } 187 | 188 | echo "done.
"; 189 | ?> -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | mqseries 4 | pecl.php.net 5 | mqseries client library 6 | This package provides support for IBM Websphere MQ (MQSeries). 7 | 8 | 9 | Michael Bretterklieber 10 | mbretter 11 | mbretter@jawa.at 12 | no 13 | 14 | 15 | Philippe Tjon A Hen 16 | philippe 17 | philippe@tjonahen.nl 18 | no 19 | 20 | 21 | Pierrick Charron 22 | pierrick 23 | pierrick@php.net 24 | yes 25 | 26 | 2017-07-14 27 | 28 | 29 | 0.15.0 30 | 0.15.0 31 | 32 | 33 | beta 34 | beta 35 | 36 | BSD 37 | 38 | - PHP7 compliance. 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 4.0.0 77 | 78 | 79 | 1.4.0b1 80 | 81 | 82 | 83 | mqseries 84 | 85 | 86 | 87 | 88 | 0.15.0 89 | 0.15.0 90 | 91 | 92 | beta 93 | beta 94 | 95 | 2017-07-14 96 | BSD 97 | 98 | - PHP7 compliance. 99 | 100 | 101 | 102 | 103 | 0.14.1 104 | 0.14.1 105 | 106 | 107 | beta 108 | beta 109 | 110 | 2014-12-05 111 | BSD 112 | 113 | - Fixed bug #63563. (Segfault when using lib64) 114 | 115 | 116 | 117 | 118 | 0.14.0 119 | 0.14.0 120 | 121 | 122 | beta 123 | beta 124 | 125 | 2014-03-05 126 | BSD 127 | 128 | - Add support for the MQFMT_MD_EXTENSION Format to remove the MQMDE from the message. (Pierrick) 129 | - Add support for the SSLCipherSpec and OCSPResponderURL. (Dieter Devlieghere, Pierrick) 130 | - Update all implemented mqseries_* functions to expose WebSphere v7 parameters (Pierrick) 131 | - Add mqseries_sub and mqseries_stat functions from WebSphere v7 (Pierrick) 132 | 133 | 134 | 135 | 136 | 0.13.0 137 | 0.13.0 138 | 139 | 140 | beta 141 | beta 142 | 143 | 2012-08-31 144 | BSD 145 | 146 | - Add the mqseries_bytes_val() function. (Pierrick) 147 | - Add support for msg_desc->GroupId. (Pierrick) 148 | - Add Version support within the msg_desc support. (Pierrick) 149 | 150 | 151 | 152 | 153 | 0.12.0 154 | 0.12.0 155 | 156 | 157 | beta 158 | beta 159 | 160 | 2012-05-26 161 | BSD 162 | 163 | - Add the possibility to use --with-libdir to compile the extension in 64-bit 164 | - PHP5.3 and PHP5.4 Compatibilty 165 | - Fixed bug #59577. (mqseries_strerror causes server to drop connection) 166 | - Fixed several memory leaks 167 | - Fixed several function signatures 168 | - Fixed segfault when non array variables are passed in array parameters 169 | - Fixed segfault when unexpected variables are in options array 170 | - Removed compilation warnings 171 | 172 | 173 | 174 | 175 | 0.11.0 176 | 0.11.0 177 | 178 | 179 | alpha 180 | alpha 181 | 182 | 2008-01-19 183 | BSD 184 | Fixed php function calling deprication warnings. 185 | tested agains MQ6. Fixed some ZTS issues while compiling. 186 | 187 | 188 | 189 | 0.10.0 190 | 0.10.0 191 | 192 | 193 | alpha 194 | alpha 195 | 196 | 2006-04-20 197 | BSD 198 | Made some changes to the config.m4 configuration file. 199 | It shoud now be possible to build the extention without the MQ Client libraries. 200 | This would enable the transaction posibilities of MQ. 201 | The MQBegin, MQCMit and MQBack function wil now work. 202 | Check the README file for additional build instructions. 203 | 204 | 205 | 206 | 207 | 0.9.0 208 | 0.9.0 209 | 210 | 211 | alpha 212 | alpha 213 | 214 | 2006-04-16 215 | BSD 216 | mostly bug fixes, especially the msgId and correlId 217 | 218 | 219 | 220 | 221 | 0.8.0 222 | 0.8.0 223 | 224 | 225 | alpha 226 | alpha 227 | 228 | 2005-04-07 229 | BSD 230 | Added some extra mqseries implementation. (mqconnx and mqput1) 231 | Changed all signatures. Each method now mimics the actual MQSeries api. 232 | 233 | 234 | 235 | 236 | 0.7.0 237 | 0.7.0 238 | 239 | 240 | alpha 241 | alpha 242 | 243 | 2003-05-15 244 | BSD 245 | - Release 0.7.0 246 | - Initial Release 247 | 248 | 249 | 250 | 251 | -------------------------------------------------------------------------------- /mqseries_helper.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2003, JAWA Management Software GmbH http://www.jawa.at 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 3. The names of the authors may not be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | This code cannot simply be copied and put under the GNU Public License or 29 | any other GPL-like (LGPL, GPL2) License. 30 | 31 | $Id: 6aecc573e7cfc52d5b8f0da9c097cd80767d515a $ 32 | 33 | Author: Michael Bretterklieber 34 | Philippe Tjon A Hen 35 | Pierrick Charron 36 | 37 | */ 38 | 39 | #ifdef HAVE_CONFIG_H 40 | #include "config.h" 41 | #endif 42 | 43 | #include "php.h" 44 | #include "ext/standard/info.h" 45 | #include "php_mqseries.h" 46 | 47 | /* {{{ Macros */ 48 | #define MQSERIES_UNSUPPRTED_VERSION(n,s) \ 49 | zend_error(E_WARNING, #n "_VERSION_%d not supported, using " #n "_VERSION_%d instead", s->Version, n ## _CURRENT_VERSION) 50 | 51 | #define MQSERIES_SETOPT_LONG(s,m) \ 52 | do { \ 53 | if ((tmp = zend_hash_str_find(ht, #m, sizeof(#m)-1)) != NULL) {\ 54 | convert_to_long(tmp); \ 55 | s->m = Z_LVAL_P(tmp); \ 56 | } \ 57 | } while(0) 58 | 59 | #define MQSERIES_SETOPT_STRING(s,m) \ 60 | do { \ 61 | if ((tmp = zend_hash_str_find(ht, #m, sizeof(#m)-1)) != NULL && \ 62 | Z_TYPE_P(tmp) == IS_STRING) { \ 63 | strncpy(s->m, Z_STRVAL_P(tmp), sizeof(s->m)); \ 64 | } \ 65 | } while(0) 66 | 67 | #define MQSERIES_SETOPT_CHAR(s, m) \ 68 | do { \ 69 | if ((tmp = zend_hash_str_find(ht, #m, sizeof(#m)-1)) != NULL && \ 70 | Z_TYPE_P(tmp) == IS_STRING && Z_STRLEN_P(tmp) > 0) { \ 71 | s->m = Z_STRVAL_P(tmp)[0]; \ 72 | } \ 73 | } while(0) 74 | 75 | #define MQSERIES_SETOPT_RESBYTES(s,m) \ 76 | do { \ 77 | if ((tmp = zend_hash_str_find(ht, #m, sizeof(#m)-1)) != NULL) { \ 78 | if (Z_TYPE_P(tmp) == IS_RESOURCE) { \ 79 | mqseries_bytes *mqbytes = (mqseries_bytes *) zend_fetch_resource(Z_RES_P(tmp), PHP_MQSERIES_BYTES_RES_NAME, le_mqseries_bytes); \ 80 | if (mqbytes != NULL) { \ 81 | memcpy(s->m, mqbytes->bytes, sizeof(s->m)); \ 82 | } \ 83 | } else if (Z_TYPE_P(tmp) != IS_NULL) { \ 84 | convert_to_string(tmp); \ 85 | char *tmp_val = Z_STRVAL_P(tmp); \ 86 | size_t i; \ 87 | for (i = 0; i < sizeof(s->m); i++) s->m[i] = tmp_val[i]; \ 88 | } \ 89 | } \ 90 | } while(0) 91 | 92 | #define MQSERIES_SETOPT_PTR(s,m) \ 93 | do { \ 94 | if ((tmp = zend_hash_str_find(ht, #m, sizeof(#m)-1)) != NULL) {\ 95 | zend_error(E_WARNING, "'%s' is not yet supported.", #m); \ 96 | } \ 97 | } while(0) 98 | 99 | #define MQSERIES_SETOPT_CHARV(s,m) \ 100 | do { \ 101 | if ((tmp = zend_hash_str_find(ht, #m, sizeof(#m)-1)) != NULL && \ 102 | Z_TYPE_P(tmp) == IS_STRING) { \ 103 | s->m.VSPtr = Z_STRVAL_P(tmp); \ 104 | s->m.VSOffset = 0; \ 105 | s->m.VSLength = Z_STRLEN_P(tmp); \ 106 | s->m.VSBufSize = Z_STRLEN_P(tmp) + 1; \ 107 | } \ 108 | } while(0) 109 | 110 | #define MQSERIES_SETOPT_HOBJ(s,m) \ 111 | do { \ 112 | if ((tmp = zend_hash_str_find(ht, #m, sizeof(#m)-1)) != NULL && \ 113 | Z_TYPE_P(tmp) == IS_RESOURCE) { \ 114 | mqseries_obj *mqobj = (mqseries_obj *) zend_fetch_resource(Z_RES_P(tmp), PHP_MQSERIES_OBJ_RES_NAME, le_mqseries_obj); \ 115 | if (mqobj != NULL) { \ 116 | s->m = mqobj->obj; \ 117 | } \ 118 | } \ 119 | } while(0) 120 | 121 | #define MQSERIES_ADD_ASSOC_LONG(s, m) \ 122 | add_assoc_long(array, #m, s->m) 123 | 124 | #define MQSERIES_ADD_ASSOC_STRING(s, m) \ 125 | do { \ 126 | if (s->m != NULL && strlen(s->m) > 0) { \ 127 | add_assoc_stringl(array, #m, s->m, sizeof(s->m)); \ 128 | } \ 129 | } while(0) 130 | 131 | #define MQSERIES_ADD_ASSOC_RESOURCE(s, m) \ 132 | do { \ 133 | zval *ref = create_mqseries_bytes_resource(s->m, sizeof(s->m)); \ 134 | add_assoc_zval(array, #m, ref); \ 135 | efree(ref); \ 136 | } while(0) 137 | 138 | #define MQSERIES_ADD_ASSOC_CHARV(s, m) \ 139 | do { \ 140 | if (s->m.VSPtr != NULL && s->m.VSLength > 0) { \ 141 | add_assoc_stringl(array, #m, (char *) s->m.VSPtr, s->m.VSLength); \ 142 | } \ 143 | } while(0) 144 | 145 | #define MQSERIES_ADD_ASSOC_CHAR(s, m) \ 146 | do { \ 147 | char str[2]; \ 148 | sprintf(str, "%c", s->m); \ 149 | add_assoc_string(array, #m, str); \ 150 | } while(0) 151 | 152 | /* }}} */ 153 | 154 | /* {{{ create_mqseries_bytes_resource 155 | * makes an mqseries_bytes reference, needed when returning message and correlation id's 156 | */ 157 | static zval* create_mqseries_bytes_resource(PMQBYTE bytes, size_t size) 158 | { 159 | mqseries_bytes *pBytes; 160 | 161 | zval *z_bytes; 162 | 163 | z_bytes = (zval *) emalloc(sizeof(zval)); 164 | 165 | pBytes = (mqseries_bytes *) emalloc(sizeof(mqseries_bytes)); 166 | pBytes->bytes = (PMQBYTE) emalloc(size*sizeof(MQBYTE)); 167 | memcpy(pBytes->bytes, bytes, size); 168 | 169 | ZVAL_RES(z_bytes, zend_register_resource(pBytes, le_mqseries_bytes)); 170 | pBytes->id = Z_RES_P(z_bytes)->handle; 171 | 172 | return z_bytes; 173 | } 174 | /* }}} */ 175 | 176 | /******************************************************************************/ 177 | /* Following are methods to make structs from arrays and vice verse */ 178 | /* TODO Check if all fields are specified (hopefully the MQ API will not */ 179 | /* change verry soon as we have to do this all over again). 'zucht'. */ 180 | /******************************************************************************/ 181 | 182 | static void _mqseries_set_authentication_information_record_from_array(zval *array, PMQAIR authentication_information_record, PMQCHAR LDAPUserName) /* {{{ */ 183 | { 184 | HashTable *ht = Z_ARRVAL_P(array); 185 | 186 | zval *tmp; 187 | 188 | MQSERIES_SETOPT_LONG(authentication_information_record, Version); 189 | MQSERIES_SETOPT_LONG(authentication_information_record, AuthInfoType); 190 | MQSERIES_SETOPT_STRING(authentication_information_record, AuthInfoConnName); 191 | MQSERIES_SETOPT_STRING(authentication_information_record, LDAPPassword); 192 | MQSERIES_SETOPT_STRING(authentication_information_record, OCSPResponderURL); 193 | 194 | if ((tmp = zend_hash_str_find(ht, "LDAPUserName", sizeof("LDAPUserName")-1)) != NULL && 195 | Z_TYPE_P(tmp) == IS_STRING) { 196 | strncpy(LDAPUserName, Z_STRVAL_P(tmp), sizeof(LDAPUserName)); 197 | authentication_information_record->LDAPUserNamePtr = LDAPUserName; 198 | authentication_information_record->LDAPUserNameLength = strlen(LDAPUserName); 199 | } 200 | } 201 | /* }}} */ 202 | 203 | static void _mqseries_set_ssl_configuration_from_array(zval *array, PMQSCO ssl_configuration, PMQAIR authentication_information_record, PMQCHAR LDAPUserName) /* {{{ */ 204 | { 205 | HashTable *ht = Z_ARRVAL_P(array); 206 | zval *tmp; 207 | 208 | MQSERIES_SETOPT_LONG(ssl_configuration, Version); 209 | MQSERIES_SETOPT_STRING(ssl_configuration, KeyRepository); 210 | MQSERIES_SETOPT_STRING(ssl_configuration, CryptoHardware); 211 | 212 | if ((tmp = zend_hash_str_find(ht, "MQAIR", sizeof("MQAIR")-1)) != NULL && 213 | Z_TYPE_P(tmp) == IS_ARRAY) { 214 | _mqseries_set_authentication_information_record_from_array(tmp, authentication_information_record, LDAPUserName); 215 | ssl_configuration->AuthInfoRecCount = 1; 216 | ssl_configuration->AuthInfoRecPtr = authentication_information_record; 217 | } 218 | } 219 | /* }}} */ 220 | 221 | static void _mqseries_set_channel_definition_from_array(zval *array, PMQCD channel_definition) /* {{{ */ 222 | { 223 | HashTable *ht = Z_ARRVAL_P(array); 224 | zval *tmp; 225 | 226 | MQSERIES_SETOPT_LONG(channel_definition, Version); 227 | 228 | switch (channel_definition->Version) { 229 | default: 230 | MQSERIES_UNSUPPRTED_VERSION(MQCD, channel_definition); 231 | 232 | #ifdef MQCD_VERSION_10 233 | case MQCD_VERSION_10: 234 | MQSERIES_SETOPT_LONG(channel_definition, BatchDataLimit); 235 | MQSERIES_SETOPT_LONG(channel_definition, UseDLQ); 236 | MQSERIES_SETOPT_LONG(channel_definition, DefReconnect); 237 | // no break intentional 238 | #endif /* MQCD_VERSION_10 */ 239 | 240 | #ifdef MQCD_VERSION_9 241 | case MQCD_VERSION_9: 242 | MQSERIES_SETOPT_LONG(channel_definition, SharingConversations); 243 | MQSERIES_SETOPT_LONG(channel_definition, PropertyControl); 244 | MQSERIES_SETOPT_LONG(channel_definition, MaxInstances); 245 | MQSERIES_SETOPT_LONG(channel_definition, MaxInstancesPerClient); 246 | MQSERIES_SETOPT_LONG(channel_definition, ClientChannelWeight); 247 | MQSERIES_SETOPT_LONG(channel_definition, ConnectionAffinity); 248 | // no break intentional 249 | #endif /* MQCD_VERSION_9 */ 250 | 251 | #ifdef MQCD_VERSION_8 252 | case MQCD_VERSION_8: 253 | // HdrCompList 254 | // MsgCompList 255 | MQSERIES_SETOPT_LONG(channel_definition, CLWLChannelRank); 256 | MQSERIES_SETOPT_LONG(channel_definition, CLWLChannelPriority); 257 | MQSERIES_SETOPT_LONG(channel_definition, CLWLChannelWeight); 258 | MQSERIES_SETOPT_LONG(channel_definition, ChannelMonitoring); 259 | MQSERIES_SETOPT_LONG(channel_definition, ChannelStatistics); 260 | // no break intentional 261 | #endif /* MQCD_VERSION_8 */ 262 | 263 | #ifdef MQCD_VERSION_7 264 | case MQCD_VERSION_7: 265 | MQSERIES_SETOPT_STRING(channel_definition, SSLCipherSpec); 266 | MQSERIES_SETOPT_PTR(channel_definition, SSLPeerNamePtr); 267 | MQSERIES_SETOPT_LONG(channel_definition, SSLPeerNameLength); 268 | MQSERIES_SETOPT_LONG(channel_definition, SSLClientAuth); 269 | MQSERIES_SETOPT_LONG(channel_definition, KeepAliveInterval); 270 | MQSERIES_SETOPT_STRING(channel_definition, LocalAddress); 271 | MQSERIES_SETOPT_LONG(channel_definition, BatchHeartbeat); 272 | // no break intentional 273 | #endif /* MQCD_VERSION_7 */ 274 | 275 | #ifdef MQCD_VERSION_6 276 | case MQCD_VERSION_6: 277 | MQSERIES_SETOPT_LONG(channel_definition, LongMCAUserIdLength); 278 | MQSERIES_SETOPT_LONG(channel_definition, LongRemoteUserIdLength); 279 | MQSERIES_SETOPT_PTR(channel_definition, LongMCAUserIdPtr); 280 | MQSERIES_SETOPT_PTR(channel_definition, LongRemoteUserIdPtr); 281 | MQSERIES_SETOPT_RESBYTES(channel_definition, MCASecurityId); 282 | MQSERIES_SETOPT_RESBYTES(channel_definition, RemoteSecurityId); 283 | // no break intentional 284 | #endif /* MQCD_VERSION_6 */ 285 | 286 | #ifdef MQCD_VERSION_5 287 | case MQCD_VERSION_5: 288 | MQSERIES_SETOPT_PTR(channel_definition, ClusterPtr); 289 | MQSERIES_SETOPT_LONG(channel_definition, ClustersDefined); 290 | MQSERIES_SETOPT_LONG(channel_definition, NetworkPriority); 291 | // no break intentional 292 | #endif /* MQCD_VERSION_5 */ 293 | 294 | #ifdef MQCD_VERSION_4 295 | case MQCD_VERSION_4: 296 | MQSERIES_SETOPT_LONG(channel_definition, HeartbeatInterval); 297 | MQSERIES_SETOPT_LONG(channel_definition, BatchInterval); 298 | MQSERIES_SETOPT_LONG(channel_definition, NonPersistentMsgSpeed); 299 | MQSERIES_SETOPT_LONG(channel_definition, StrucLength); 300 | MQSERIES_SETOPT_LONG(channel_definition, ExitNameLength); 301 | MQSERIES_SETOPT_LONG(channel_definition, ExitDataLength); 302 | MQSERIES_SETOPT_LONG(channel_definition, MsgExitsDefined); 303 | MQSERIES_SETOPT_LONG(channel_definition, SendExitsDefined); 304 | MQSERIES_SETOPT_LONG(channel_definition, ReceiveExitsDefined); 305 | MQSERIES_SETOPT_PTR(channel_definition, MsgExitPtr); 306 | MQSERIES_SETOPT_PTR(channel_definition, MsgUserDataPtr); 307 | MQSERIES_SETOPT_PTR(channel_definition, SendExitPtr); 308 | MQSERIES_SETOPT_PTR(channel_definition, SendUserDataPtr); 309 | MQSERIES_SETOPT_PTR(channel_definition, ReceiveExitPtr); 310 | MQSERIES_SETOPT_PTR(channel_definition, ReceiveUserDataPtr); 311 | // no break intentional 312 | #endif /* MQCD_VERSION_4 */ 313 | 314 | #ifdef MQCD_VERSION_3 315 | case MQCD_VERSION_3: 316 | MQSERIES_SETOPT_STRING(channel_definition, MsgRetryExit); 317 | MQSERIES_SETOPT_STRING(channel_definition, MsgRetryUserData); 318 | MQSERIES_SETOPT_LONG(channel_definition, MsgRetryCount); 319 | MQSERIES_SETOPT_LONG(channel_definition, MsgRetryInterval); 320 | // no break intentional 321 | #endif /* MQCD_VERSION_3 */ 322 | 323 | #ifdef MQCD_VERSION_2 324 | case MQCD_VERSION_2: 325 | MQSERIES_SETOPT_STRING(channel_definition, UserIdentifier); 326 | MQSERIES_SETOPT_STRING(channel_definition, Password); 327 | MQSERIES_SETOPT_STRING(channel_definition, MCAUserIdentifier); 328 | MQSERIES_SETOPT_LONG(channel_definition, MCAType); 329 | MQSERIES_SETOPT_STRING(channel_definition, ConnectionName); 330 | MQSERIES_SETOPT_STRING(channel_definition, RemoteUserIdentifier); 331 | MQSERIES_SETOPT_STRING(channel_definition, RemotePassword); 332 | // no break intentional 333 | #endif /* MQCD_VERSION_2 */ 334 | 335 | #ifdef MQCD_VERSION_1 336 | case MQCD_VERSION_1: 337 | MQSERIES_SETOPT_STRING(channel_definition, ChannelName); 338 | MQSERIES_SETOPT_LONG(channel_definition, ChannelType); 339 | MQSERIES_SETOPT_LONG(channel_definition, TransportType); 340 | MQSERIES_SETOPT_STRING(channel_definition, Desc); 341 | MQSERIES_SETOPT_STRING(channel_definition, QMgrName); 342 | MQSERIES_SETOPT_STRING(channel_definition, XmitQName); 343 | MQSERIES_SETOPT_STRING(channel_definition, ShortConnectionName); 344 | MQSERIES_SETOPT_STRING(channel_definition, MCAName); 345 | MQSERIES_SETOPT_STRING(channel_definition, ModeName); 346 | MQSERIES_SETOPT_STRING(channel_definition, TpName); 347 | MQSERIES_SETOPT_LONG(channel_definition, BatchSize); 348 | MQSERIES_SETOPT_LONG(channel_definition, DiscInterval); 349 | MQSERIES_SETOPT_LONG(channel_definition, ShortRetryCount); 350 | MQSERIES_SETOPT_LONG(channel_definition, ShortRetryInterval); 351 | MQSERIES_SETOPT_LONG(channel_definition, LongRetryCount); 352 | MQSERIES_SETOPT_LONG(channel_definition, LongRetryInterval); 353 | MQSERIES_SETOPT_STRING(channel_definition, SecurityExit); 354 | MQSERIES_SETOPT_STRING(channel_definition, MsgExit); 355 | MQSERIES_SETOPT_STRING(channel_definition, SendExit); 356 | MQSERIES_SETOPT_STRING(channel_definition, ReceiveExit); 357 | MQSERIES_SETOPT_LONG(channel_definition, SeqNumberWrap); 358 | MQSERIES_SETOPT_LONG(channel_definition, MaxMsgLength); 359 | MQSERIES_SETOPT_LONG(channel_definition, PutAuthority); 360 | MQSERIES_SETOPT_LONG(channel_definition, DataConversion); 361 | MQSERIES_SETOPT_STRING(channel_definition, SecurityUserData); 362 | MQSERIES_SETOPT_STRING(channel_definition, MsgUserData); 363 | MQSERIES_SETOPT_STRING(channel_definition, SendUserData); 364 | MQSERIES_SETOPT_STRING(channel_definition, ReceiveUserData); 365 | // no break intentional 366 | #endif /* MQCD_VERSION_1 */ 367 | } 368 | } 369 | /* }}} */ 370 | 371 | void _mqseries_set_mqcno_from_array(zval *array, PMQCNO connect_opts, PMQCD channel_definition, PMQSCO ssl_configuration, PMQAIR authentication_information_record, PMQCHAR LDAPUserName) /* {{{ */ 372 | { 373 | HashTable *ht = Z_ARRVAL_P(array); 374 | zval *tmp; 375 | 376 | MQSERIES_SETOPT_LONG(connect_opts, Options); 377 | MQSERIES_SETOPT_LONG(connect_opts, Version); 378 | 379 | if ((tmp = zend_hash_str_find(ht, "MQCD", sizeof("MQCD")-1)) != NULL && 380 | Z_TYPE_P(tmp) == IS_ARRAY) { 381 | _mqseries_set_channel_definition_from_array(tmp, channel_definition); 382 | connect_opts->ClientConnPtr = channel_definition; 383 | } 384 | 385 | if ((tmp = zend_hash_str_find(ht, "MQSCO", sizeof("MQSCO")-1)) != NULL && 386 | Z_TYPE_P(tmp) == IS_ARRAY) { 387 | _mqseries_set_ssl_configuration_from_array(tmp, ssl_configuration, authentication_information_record, LDAPUserName); 388 | connect_opts->SSLConfigPtr = ssl_configuration; 389 | } 390 | } 391 | /* }}} */ 392 | 393 | void _mqseries_set_mqpmo_from_array(zval *array, PMQPMO put_msg_opts) /* {{{ */ 394 | { 395 | HashTable *ht = Z_ARRVAL_P(array); 396 | zval *tmp; 397 | 398 | MQSERIES_SETOPT_LONG(put_msg_opts, Version); 399 | 400 | switch (put_msg_opts->Version) { 401 | default: 402 | MQSERIES_UNSUPPRTED_VERSION(MQPMO, put_msg_opts); 403 | 404 | #ifdef MQPMO_VERSION_3 405 | case MQPMO_VERSION_3: 406 | // MQHMSG OriginalMsgHandle; 407 | // MQHMSG NewMsgHandle; 408 | MQSERIES_SETOPT_LONG(put_msg_opts, Action); 409 | MQSERIES_SETOPT_LONG(put_msg_opts, PubLevel); 410 | // no break intentional 411 | #endif /* MQPMO_VERSION_3 */ 412 | 413 | #ifdef MQPMO_VERSION_2 414 | case MQPMO_VERSION_2: 415 | MQSERIES_SETOPT_LONG(put_msg_opts, RecsPresent); 416 | MQSERIES_SETOPT_LONG(put_msg_opts, PutMsgRecFields); 417 | MQSERIES_SETOPT_LONG(put_msg_opts, PutMsgRecOffset); 418 | MQSERIES_SETOPT_LONG(put_msg_opts, ResponseRecOffset); 419 | MQSERIES_SETOPT_PTR(put_msg_opts, PutMsgRecPtr); 420 | MQSERIES_SETOPT_PTR(put_msg_opts, ResponseRecPtr); 421 | // no break intentional 422 | #endif /* MQPMO_VERSION_2 */ 423 | 424 | #ifdef MQPMO_VERSION_1 425 | case MQPMO_VERSION_1: 426 | MQSERIES_SETOPT_LONG(put_msg_opts, Options); 427 | MQSERIES_SETOPT_LONG(put_msg_opts, Timeout); 428 | MQSERIES_SETOPT_HOBJ(put_msg_opts, Context); 429 | MQSERIES_SETOPT_LONG(put_msg_opts, KnownDestCount); 430 | MQSERIES_SETOPT_LONG(put_msg_opts, UnknownDestCount); 431 | MQSERIES_SETOPT_LONG(put_msg_opts, InvalidDestCount); 432 | MQSERIES_SETOPT_STRING(put_msg_opts, ResolvedQName); 433 | MQSERIES_SETOPT_STRING(put_msg_opts, ResolvedQMgrName); 434 | // no break intentional 435 | #endif /* MQPMO_VERSION_1 */ 436 | } 437 | } 438 | /* }}} */ 439 | 440 | void _mqseries_set_array_from_mqpmo(zval *array, PMQPMO put_msg_opts) { /* {{{ */ 441 | zval_dtor(array); 442 | array_init(array); 443 | 444 | switch (put_msg_opts->Version) { 445 | default: 446 | MQSERIES_UNSUPPRTED_VERSION(MQPMO, put_msg_opts); 447 | 448 | #ifdef MQPMO_VERSION_3 449 | case MQPMO_VERSION_3: 450 | // MQHMSG OriginalMsgHandle; 451 | // MQHMSG NewMsgHandle; 452 | MQSERIES_ADD_ASSOC_LONG(put_msg_opts, Action); 453 | MQSERIES_ADD_ASSOC_LONG(put_msg_opts, PubLevel); 454 | // no break intentional 455 | #endif /* MQPMO_VERSION_3 */ 456 | 457 | #ifdef MQPMO_VERSION_2 458 | case MQPMO_VERSION_2: 459 | MQSERIES_ADD_ASSOC_LONG(put_msg_opts, RecsPresent); 460 | MQSERIES_ADD_ASSOC_LONG(put_msg_opts, PutMsgRecFields); 461 | MQSERIES_ADD_ASSOC_LONG(put_msg_opts, PutMsgRecOffset); 462 | MQSERIES_ADD_ASSOC_LONG(put_msg_opts, ResponseRecOffset); 463 | // MQSERIES_SETOPT_PTR(put_msg_opts, PutMsgRecPtr); 464 | // MQSERIES_SETOPT_PTR(put_msg_opts, ResponseRecPtr); 465 | // no break intentional 466 | #endif /* MQPMO_VERSION_2 */ 467 | 468 | #ifdef MQPMO_VERSION_1 469 | case MQPMO_VERSION_1: 470 | MQSERIES_ADD_ASSOC_LONG(put_msg_opts, Version); 471 | MQSERIES_ADD_ASSOC_LONG(put_msg_opts, Timeout); 472 | // MQHOBJ Context 473 | MQSERIES_ADD_ASSOC_LONG(put_msg_opts, KnownDestCount); 474 | MQSERIES_ADD_ASSOC_LONG(put_msg_opts, UnknownDestCount); 475 | MQSERIES_ADD_ASSOC_LONG(put_msg_opts, InvalidDestCount); 476 | MQSERIES_ADD_ASSOC_STRING(put_msg_opts, ResolvedQName); 477 | MQSERIES_ADD_ASSOC_STRING(put_msg_opts, ResolvedQMgrName); 478 | // no break intentional 479 | #endif /* MQPMO_VERSION_1 */ 480 | } 481 | } 482 | /* }}} */ 483 | 484 | void _mqseries_set_mqmd_from_array(zval *array, PMQMD msg_desc) /* {{{ */ 485 | { 486 | HashTable *ht = Z_ARRVAL_P(array); 487 | zval *tmp; 488 | 489 | MQSERIES_SETOPT_LONG(msg_desc, Version); 490 | switch (msg_desc->Version) { 491 | default: 492 | MQSERIES_UNSUPPRTED_VERSION(MQMD, msg_desc); 493 | 494 | #ifdef MQMD_VERSION_2 495 | case MQMD_VERSION_2: 496 | MQSERIES_SETOPT_RESBYTES(msg_desc, GroupId); 497 | MQSERIES_SETOPT_LONG(msg_desc, MsgSeqNumber); 498 | MQSERIES_SETOPT_LONG(msg_desc, Offset); 499 | MQSERIES_SETOPT_LONG(msg_desc, MsgFlags); 500 | MQSERIES_SETOPT_LONG(msg_desc, OriginalLength); 501 | // no break intentional 502 | #endif /* MQMD_VERSION_2 */ 503 | 504 | #ifdef MQMD_VERSION_1 505 | case MQMD_VERSION_1: 506 | MQSERIES_SETOPT_LONG(msg_desc, Report); 507 | MQSERIES_SETOPT_LONG(msg_desc, MsgType); 508 | MQSERIES_SETOPT_LONG(msg_desc, Expiry); 509 | MQSERIES_SETOPT_LONG(msg_desc, Feedback); 510 | MQSERIES_SETOPT_LONG(msg_desc, Encoding); 511 | MQSERIES_SETOPT_LONG(msg_desc, CodedCharSetId); 512 | MQSERIES_SETOPT_STRING(msg_desc, Format); 513 | MQSERIES_SETOPT_LONG(msg_desc, Priority); 514 | MQSERIES_SETOPT_LONG(msg_desc, Persistence); 515 | MQSERIES_SETOPT_RESBYTES(msg_desc, MsgId); 516 | MQSERIES_SETOPT_RESBYTES(msg_desc, CorrelId); 517 | MQSERIES_SETOPT_LONG(msg_desc, BackoutCount); 518 | MQSERIES_SETOPT_STRING(msg_desc, ReplyToQ); 519 | MQSERIES_SETOPT_STRING(msg_desc, ReplyToQMgr); 520 | MQSERIES_SETOPT_STRING(msg_desc, UserIdentifier); 521 | MQSERIES_SETOPT_RESBYTES(msg_desc, AccountingToken); 522 | MQSERIES_SETOPT_STRING(msg_desc, ApplIdentityData); 523 | MQSERIES_SETOPT_LONG(msg_desc, PutApplType); 524 | MQSERIES_SETOPT_STRING(msg_desc, PutApplName); 525 | MQSERIES_SETOPT_STRING(msg_desc, PutDate); 526 | MQSERIES_SETOPT_STRING(msg_desc, PutTime); 527 | MQSERIES_SETOPT_STRING(msg_desc, ApplOriginData); 528 | // no break intentional 529 | #endif /* MQMD_VERSION_1 */ 530 | } 531 | } 532 | /* }}} */ 533 | 534 | void _mqseries_set_array_from_mqmd(zval *array, PMQMD msg_desc) /* {{{ */ 535 | { 536 | zval_dtor(array); 537 | array_init(array); 538 | 539 | switch (msg_desc->Version) { 540 | default: 541 | MQSERIES_UNSUPPRTED_VERSION(MQMD, msg_desc); 542 | 543 | #ifdef MQMD_VERSION_2 544 | case MQMD_VERSION_2: 545 | MQSERIES_ADD_ASSOC_RESOURCE(msg_desc, GroupId); 546 | MQSERIES_ADD_ASSOC_LONG(msg_desc, MsgSeqNumber); 547 | MQSERIES_ADD_ASSOC_LONG(msg_desc, Offset); 548 | MQSERIES_ADD_ASSOC_LONG(msg_desc, MsgFlags); 549 | MQSERIES_ADD_ASSOC_LONG(msg_desc, OriginalLength); 550 | #endif /* MQMD_VERSION_2 */ 551 | 552 | #ifdef MQMD_VERSION_1 553 | case MQMD_VERSION_1: 554 | MQSERIES_ADD_ASSOC_LONG(msg_desc, Version); 555 | MQSERIES_ADD_ASSOC_LONG(msg_desc, Report); 556 | MQSERIES_ADD_ASSOC_LONG(msg_desc, MsgType); 557 | MQSERIES_ADD_ASSOC_LONG(msg_desc, Expiry); 558 | MQSERIES_ADD_ASSOC_LONG(msg_desc, Feedback); 559 | MQSERIES_ADD_ASSOC_LONG(msg_desc, Encoding); 560 | MQSERIES_ADD_ASSOC_LONG(msg_desc, CodedCharSetId); 561 | MQSERIES_ADD_ASSOC_STRING(msg_desc, Format); 562 | MQSERIES_ADD_ASSOC_LONG(msg_desc, Priority); 563 | MQSERIES_ADD_ASSOC_LONG(msg_desc, Persistence); 564 | MQSERIES_ADD_ASSOC_RESOURCE(msg_desc, MsgId); 565 | MQSERIES_ADD_ASSOC_RESOURCE(msg_desc, CorrelId); 566 | MQSERIES_ADD_ASSOC_LONG(msg_desc, BackoutCount); 567 | MQSERIES_ADD_ASSOC_STRING(msg_desc, ReplyToQ); 568 | MQSERIES_ADD_ASSOC_STRING(msg_desc, ReplyToQMgr); 569 | MQSERIES_ADD_ASSOC_STRING(msg_desc, UserIdentifier); 570 | MQSERIES_ADD_ASSOC_RESOURCE(msg_desc, AccountingToken); 571 | MQSERIES_ADD_ASSOC_STRING(msg_desc, ApplIdentityData); 572 | MQSERIES_ADD_ASSOC_LONG(msg_desc, PutApplType); 573 | MQSERIES_ADD_ASSOC_STRING(msg_desc, PutApplName); 574 | MQSERIES_ADD_ASSOC_STRING(msg_desc, PutDate); 575 | MQSERIES_ADD_ASSOC_STRING(msg_desc, PutTime); 576 | MQSERIES_ADD_ASSOC_STRING(msg_desc, ApplOriginData); 577 | #endif /* MQMD_VERSION_1 */ 578 | } 579 | } 580 | /* }}} */ 581 | 582 | void _mqseries_set_mqod_from_array(zval *array, PMQOD obj_desc) /* {{{ */ 583 | { 584 | HashTable *ht = Z_ARRVAL_P(array); 585 | zval *tmp; 586 | 587 | MQSERIES_SETOPT_LONG(obj_desc, Version); 588 | switch (obj_desc->Version) { 589 | default: 590 | MQSERIES_UNSUPPRTED_VERSION(MQOD, obj_desc); 591 | 592 | #ifdef MQOD_VERSION_4 593 | case MQOD_VERSION_4: 594 | MQSERIES_SETOPT_CHARV(obj_desc, ObjectString); 595 | MQSERIES_SETOPT_CHARV(obj_desc, SelectionString); 596 | MQSERIES_SETOPT_CHARV(obj_desc, ResObjectString); 597 | MQSERIES_SETOPT_LONG(obj_desc, ResolvedType); 598 | #endif /* MQOD_VERSION_4 */ 599 | 600 | #ifdef MQOD_VERSION_3 601 | case MQOD_VERSION_3: 602 | MQSERIES_SETOPT_RESBYTES(obj_desc, AlternateSecurityId); 603 | MQSERIES_SETOPT_STRING(obj_desc, ResolvedQName); 604 | MQSERIES_SETOPT_STRING(obj_desc, ResolvedQMgrName); 605 | #endif /* MQOD_VERSION_3 */ 606 | 607 | #ifdef MQOD_VERSION_2 608 | case MQOD_VERSION_2: 609 | MQSERIES_SETOPT_LONG(obj_desc, RecsPresent); 610 | MQSERIES_SETOPT_LONG(obj_desc, KnownDestCount); 611 | MQSERIES_SETOPT_LONG(obj_desc, UnknownDestCount); 612 | MQSERIES_SETOPT_LONG(obj_desc, InvalidDestCount); 613 | MQSERIES_SETOPT_LONG(obj_desc, ObjectRecOffset); 614 | MQSERIES_SETOPT_LONG(obj_desc, ResponseRecOffset); 615 | MQSERIES_SETOPT_PTR(obj_desc, ObjectRecPtr); 616 | MQSERIES_SETOPT_PTR(obj_desc, ResponseRecPtr); 617 | #endif /* MQOD_VERSION_2 */ 618 | 619 | #ifdef MQOD_VERSION_1 620 | case MQOD_VERSION_1: 621 | MQSERIES_SETOPT_LONG(obj_desc, ObjectType); 622 | MQSERIES_SETOPT_STRING(obj_desc, ObjectName); 623 | MQSERIES_SETOPT_STRING(obj_desc, ObjectQMgrName); 624 | MQSERIES_SETOPT_STRING(obj_desc, DynamicQName); 625 | MQSERIES_SETOPT_STRING(obj_desc, AlternateUserId); 626 | break; 627 | #endif /* MQOD_VERSION_1 */ 628 | } 629 | } 630 | /* }}} */ 631 | 632 | void _mqseries_set_array_from_mqod(zval *array, PMQOD obj_desc) /* {{{ */ 633 | { 634 | zval_dtor(array); 635 | array_init(array); 636 | 637 | switch(obj_desc->Version) { 638 | default: 639 | MQSERIES_UNSUPPRTED_VERSION(MQOD, obj_desc); 640 | 641 | #ifdef MQOD_VERSION_4 642 | case MQOD_VERSION_4: 643 | MQSERIES_ADD_ASSOC_CHARV(obj_desc, ObjectString); 644 | MQSERIES_ADD_ASSOC_CHARV(obj_desc, SelectionString); 645 | MQSERIES_ADD_ASSOC_CHARV(obj_desc, ResObjectString); 646 | MQSERIES_ADD_ASSOC_LONG(obj_desc, ResolvedType); 647 | #endif /* MQOD_VERSION_4 */ 648 | 649 | #ifdef MQOD_VERSION_3 650 | case MQOD_VERSION_3: 651 | MQSERIES_ADD_ASSOC_RESOURCE(obj_desc, AlternateSecurityId); 652 | MQSERIES_ADD_ASSOC_STRING(obj_desc, ResolvedQName); 653 | MQSERIES_ADD_ASSOC_STRING(obj_desc, ResolvedQMgrName); 654 | #endif /* MQOD_VERSION_3 */ 655 | 656 | #ifdef MQOD_VERSION_2 657 | case MQOD_VERSION_2: 658 | MQSERIES_ADD_ASSOC_LONG(obj_desc, RecsPresent); 659 | MQSERIES_ADD_ASSOC_LONG(obj_desc, KnownDestCount); 660 | MQSERIES_ADD_ASSOC_LONG(obj_desc, UnknownDestCount); 661 | MQSERIES_ADD_ASSOC_LONG(obj_desc, InvalidDestCount); 662 | MQSERIES_ADD_ASSOC_LONG(obj_desc, ObjectRecOffset); 663 | MQSERIES_ADD_ASSOC_LONG(obj_desc, ResponseRecOffset); 664 | // MQPTR ObjectRecPtr; 665 | // MQPTR ResponseRecPtr; 666 | #endif /* MQOD_VERSION_2 */ 667 | 668 | case MQOD_VERSION_1: 669 | MQSERIES_ADD_ASSOC_LONG(obj_desc, Version); 670 | MQSERIES_ADD_ASSOC_LONG(obj_desc, ObjectType); 671 | MQSERIES_ADD_ASSOC_STRING(obj_desc, ObjectName); 672 | MQSERIES_ADD_ASSOC_STRING(obj_desc, ObjectQMgrName); 673 | MQSERIES_ADD_ASSOC_STRING(obj_desc, DynamicQName); 674 | MQSERIES_ADD_ASSOC_STRING(obj_desc, AlternateUserId); 675 | break; 676 | 677 | } 678 | } 679 | /* }}} */ 680 | 681 | void _mqseries_set_mqgmo_from_array(zval *array, PMQGMO get_msg_opts) /* {{{ */ 682 | { 683 | HashTable *ht = Z_ARRVAL_P(array); 684 | zval *tmp; 685 | 686 | MQSERIES_SETOPT_LONG(get_msg_opts, Version); 687 | switch (get_msg_opts->Version) { 688 | default: 689 | MQSERIES_UNSUPPRTED_VERSION(MQGMO, get_msg_opts); 690 | 691 | #ifdef MQGMO_VERSION_4 692 | case MQGMO_VERSION_4: 693 | // MQHMSG MsgHandle; 694 | MQSERIES_SETOPT_LONG(get_msg_opts, Reserved2); 695 | // no break intentional 696 | #endif /* MQGMO_VERSION_4 */ 697 | 698 | #ifdef MQGMO_VERSION_3 699 | case MQGMO_VERSION_3: 700 | MQSERIES_SETOPT_LONG(get_msg_opts, ReturnedLength); 701 | MQSERIES_SETOPT_RESBYTES(get_msg_opts, MsgToken); 702 | // no break intentional 703 | #endif /* MQGMO_VERSION_3 */ 704 | 705 | #ifdef MQGMO_VERSION_2 706 | case MQGMO_VERSION_2: 707 | MQSERIES_SETOPT_LONG(get_msg_opts, MatchOptions); 708 | MQSERIES_SETOPT_CHAR(get_msg_opts, GroupStatus); 709 | MQSERIES_SETOPT_CHAR(get_msg_opts, SegmentStatus); 710 | MQSERIES_SETOPT_CHAR(get_msg_opts, Segmentation); 711 | MQSERIES_SETOPT_CHAR(get_msg_opts, Reserved1); 712 | // no break intentional 713 | #endif /* MQGMO_VERSION_2 */ 714 | 715 | #ifdef MQGMO_VERSION_1 716 | case MQGMO_VERSION_1: 717 | MQSERIES_SETOPT_LONG(get_msg_opts, Options); 718 | MQSERIES_SETOPT_LONG(get_msg_opts, WaitInterval); 719 | MQSERIES_SETOPT_LONG(get_msg_opts, Signal1); 720 | MQSERIES_SETOPT_LONG(get_msg_opts, Signal2); 721 | MQSERIES_SETOPT_STRING(get_msg_opts, ResolvedQName); 722 | // no break intentional 723 | #endif /* MQGMO_VERSION_1 */ 724 | } 725 | } 726 | /* }}} */ 727 | 728 | void _mqseries_set_array_from_mqgmo(zval *array, PMQGMO get_msg_opts) /* {{{ */ 729 | { 730 | zval_dtor(array); 731 | array_init(array); 732 | 733 | switch (get_msg_opts->Version) { 734 | default: 735 | MQSERIES_UNSUPPRTED_VERSION(MQGMO, get_msg_opts); 736 | 737 | #ifdef MQGMO_VERSION_4 738 | case MQGMO_VERSION_4: 739 | // MQHMSG MsgHandle; 740 | MQSERIES_ADD_ASSOC_LONG(get_msg_opts, Reserved2); 741 | // no break intentional 742 | #endif /* MQGMO_VERSION_4 */ 743 | 744 | #ifdef MQGMO_VERSION_3 745 | case MQGMO_VERSION_3: 746 | MQSERIES_ADD_ASSOC_LONG(get_msg_opts, ReturnedLength); 747 | MQSERIES_ADD_ASSOC_RESOURCE(get_msg_opts, MsgToken); 748 | // no break intentional 749 | #endif /* MQGMO_VERSION_3 */ 750 | 751 | #ifdef MQGMO_VERSION_2 752 | case MQGMO_VERSION_2: 753 | MQSERIES_ADD_ASSOC_LONG(get_msg_opts, MatchOptions); 754 | MQSERIES_ADD_ASSOC_CHAR(get_msg_opts, GroupStatus); 755 | MQSERIES_ADD_ASSOC_CHAR(get_msg_opts, SegmentStatus); 756 | MQSERIES_ADD_ASSOC_CHAR(get_msg_opts, Segmentation); 757 | MQSERIES_ADD_ASSOC_CHAR(get_msg_opts, Reserved1); 758 | // no break intentional 759 | #endif /* MQGMO_VERSION_2 */ 760 | 761 | #ifdef MQGMO_VERSION_1 762 | case MQGMO_VERSION_1: 763 | MQSERIES_ADD_ASSOC_LONG(get_msg_opts, Version); 764 | MQSERIES_ADD_ASSOC_LONG(get_msg_opts, Options); 765 | MQSERIES_ADD_ASSOC_LONG(get_msg_opts, WaitInterval); 766 | MQSERIES_ADD_ASSOC_LONG(get_msg_opts, Signal1); 767 | MQSERIES_ADD_ASSOC_LONG(get_msg_opts, Signal2); 768 | MQSERIES_ADD_ASSOC_STRING(get_msg_opts, ResolvedQName); 769 | // no break intentional 770 | #endif /* MQGMO_VERSION_1 */ 771 | } 772 | } 773 | /* }}} */ 774 | 775 | void _mqseries_set_mqbo_from_array(zval *array, PMQBO mqbo) /* {{{ */ 776 | { 777 | HashTable *ht = Z_ARRVAL_P(array); 778 | zval *tmp; 779 | 780 | switch (mqbo->Version) { 781 | default: 782 | MQSERIES_UNSUPPRTED_VERSION(MQBO, mqbo); 783 | 784 | #ifdef MQBO_VERSION_1 785 | case MQBO_VERSION_1: 786 | MQSERIES_SETOPT_LONG(mqbo, Version); 787 | MQSERIES_SETOPT_LONG(mqbo, Options); 788 | #endif /* MQBO_VERSION_1 */ 789 | } 790 | } 791 | /* }}} */ 792 | 793 | #ifdef HAVE_MQSERIESLIB_V7 794 | 795 | void _mqseries_set_mqsd_from_array(zval *array, PMQSD sub_desc) /* {{{ */ 796 | { 797 | HashTable *ht = Z_ARRVAL_P(array); 798 | zval *tmp; 799 | 800 | MQSERIES_SETOPT_LONG(sub_desc, Version); 801 | switch (sub_desc->Version) { 802 | default: 803 | MQSERIES_UNSUPPRTED_VERSION(MQSD, sub_desc); 804 | 805 | #ifdef MQSD_VERSION_1 806 | case MQSD_VERSION_1: 807 | MQSERIES_SETOPT_LONG(sub_desc, Options); 808 | MQSERIES_SETOPT_STRING(sub_desc, ObjectName); 809 | MQSERIES_SETOPT_STRING(sub_desc, AlternateUserId); 810 | MQSERIES_SETOPT_RESBYTES(sub_desc, AlternateSecurityId); 811 | MQSERIES_SETOPT_LONG(sub_desc, SubExpiry); 812 | MQSERIES_SETOPT_CHARV(sub_desc, ObjectString); 813 | MQSERIES_SETOPT_CHARV(sub_desc, SubName); 814 | MQSERIES_SETOPT_CHARV(sub_desc, SubUserData); 815 | MQSERIES_SETOPT_RESBYTES(sub_desc, SubCorrelId); 816 | MQSERIES_SETOPT_LONG(sub_desc, PubPriority); 817 | MQSERIES_SETOPT_RESBYTES(sub_desc, PubAccountingToken); 818 | MQSERIES_SETOPT_STRING(sub_desc, PubApplIdentityData); 819 | MQSERIES_SETOPT_CHARV(sub_desc, SelectionString); 820 | MQSERIES_SETOPT_LONG(sub_desc, SubLevel); 821 | MQSERIES_SETOPT_CHARV(sub_desc, ResObjectString); 822 | } 823 | #endif /* MQSD_VERSION_1 */ 824 | } 825 | /* }}} */ 826 | 827 | void _mqseries_set_array_from_mqsd(zval *array, PMQSD sub_desc) /* {{{ */ 828 | { 829 | zval_dtor(array); 830 | array_init(array); 831 | 832 | switch (sub_desc->Version) { 833 | default: 834 | MQSERIES_UNSUPPRTED_VERSION(MQSD, sub_desc); 835 | 836 | #ifdef MQSD_VERSION_1 837 | case MQSD_VERSION_1: 838 | MQSERIES_ADD_ASSOC_LONG(sub_desc, Version); 839 | MQSERIES_ADD_ASSOC_LONG(sub_desc, Options); 840 | MQSERIES_ADD_ASSOC_STRING(sub_desc, ObjectName); 841 | MQSERIES_ADD_ASSOC_STRING(sub_desc, AlternateUserId); 842 | MQSERIES_ADD_ASSOC_RESOURCE(sub_desc, AlternateSecurityId); 843 | MQSERIES_ADD_ASSOC_LONG(sub_desc, SubExpiry); 844 | MQSERIES_ADD_ASSOC_CHARV(sub_desc, ObjectString); 845 | MQSERIES_ADD_ASSOC_CHARV(sub_desc, SubName); 846 | MQSERIES_ADD_ASSOC_CHARV(sub_desc, SubUserData); 847 | MQSERIES_ADD_ASSOC_RESOURCE(sub_desc, SubCorrelId); 848 | MQSERIES_ADD_ASSOC_LONG(sub_desc, PubPriority); 849 | MQSERIES_ADD_ASSOC_RESOURCE(sub_desc, PubAccountingToken); 850 | MQSERIES_ADD_ASSOC_STRING(sub_desc, PubApplIdentityData); 851 | MQSERIES_ADD_ASSOC_CHARV(sub_desc, SelectionString); 852 | MQSERIES_ADD_ASSOC_LONG(sub_desc, SubLevel); 853 | MQSERIES_ADD_ASSOC_CHARV(sub_desc, ResObjectString); 854 | #endif /* MQSD_VERSION_1 */ 855 | } 856 | } 857 | /* }}} */ 858 | 859 | void _mqseries_set_mqsts_from_array(zval *array, PMQSTS status) /* {{{ */ 860 | { 861 | HashTable *ht = Z_ARRVAL_P(array); 862 | zval *tmp; 863 | 864 | MQSERIES_SETOPT_LONG(status, Version); 865 | switch (status->Version) { 866 | default: 867 | MQSERIES_UNSUPPRTED_VERSION(MQSTS, status); 868 | 869 | #ifdef MQSTS_VERSION_2 870 | case MQSTS_VERSION_2: 871 | MQSERIES_SETOPT_CHARV(status, ObjectString); 872 | MQSERIES_SETOPT_CHARV(status, SubName); 873 | MQSERIES_SETOPT_LONG(status, OpenOptions); 874 | MQSERIES_SETOPT_LONG(status, SubOptions); 875 | // no break intentional 876 | #endif /* MQSTS_VERSION_2 */ 877 | 878 | #ifdef MQSTS_VERSION_1 879 | case MQSTS_VERSION_1: 880 | MQSERIES_SETOPT_LONG(status, CompCode); 881 | MQSERIES_SETOPT_LONG(status, Reason); 882 | MQSERIES_SETOPT_LONG(status, PutSuccessCount); 883 | MQSERIES_SETOPT_LONG(status, PutWarningCount); 884 | MQSERIES_SETOPT_LONG(status, PutFailureCount); 885 | MQSERIES_SETOPT_LONG(status, ObjectType); 886 | MQSERIES_SETOPT_STRING(status, ObjectName); 887 | MQSERIES_SETOPT_STRING(status, ObjectQMgrName); 888 | MQSERIES_SETOPT_STRING(status, ResolvedObjectName); 889 | MQSERIES_SETOPT_STRING(status, ResolvedQMgrName); 890 | // no break intentional 891 | #endif /* MQSTS_VERSION_1 */ 892 | } 893 | } 894 | /* }}} */ 895 | 896 | void _mqseries_set_array_from_mqsts(zval *array, PMQSTS status) /* {{{ */ 897 | { 898 | zval_dtor(array); 899 | array_init(array); 900 | 901 | switch (status->Version) { 902 | default: 903 | MQSERIES_UNSUPPRTED_VERSION(MQSTS, status); 904 | 905 | #ifdef MQSTS_VERSION_2 906 | case MQSTS_VERSION_2: 907 | MQSERIES_ADD_ASSOC_CHARV(status, ObjectString); 908 | MQSERIES_ADD_ASSOC_CHARV(status, SubName); 909 | MQSERIES_ADD_ASSOC_LONG(status, OpenOptions); 910 | MQSERIES_ADD_ASSOC_LONG(status, SubOptions); 911 | // no break intentional 912 | #endif /* MQSTS_VERSION_2 */ 913 | 914 | #ifdef MQSTS_VERSION_1 915 | case MQSTS_VERSION_1: 916 | MQSERIES_ADD_ASSOC_LONG(status, CompCode); 917 | MQSERIES_ADD_ASSOC_LONG(status, Reason); 918 | MQSERIES_ADD_ASSOC_LONG(status, PutSuccessCount); 919 | MQSERIES_ADD_ASSOC_LONG(status, PutWarningCount); 920 | MQSERIES_ADD_ASSOC_LONG(status, PutFailureCount); 921 | MQSERIES_ADD_ASSOC_LONG(status, ObjectType); 922 | MQSERIES_ADD_ASSOC_STRING(status, ObjectName); 923 | MQSERIES_ADD_ASSOC_STRING(status, ObjectQMgrName); 924 | MQSERIES_ADD_ASSOC_STRING(status, ResolvedObjectName); 925 | MQSERIES_ADD_ASSOC_STRING(status, ResolvedQMgrName); 926 | // no break intentional 927 | #endif /* MQSTS_VERSION_1 */ 928 | } 929 | } 930 | /* }}} */ 931 | 932 | #endif /* HAVE_MQSERIESLIB_V7 */ 933 | 934 | /* 935 | * Local variables: 936 | * tab-width: 4 937 | * c-basic-offset: 4 938 | * End: 939 | * vim600: noet sw=4 ts=4 fdm=marker 940 | * vim<600: noet sw=4 ts=4 941 | */ 942 | -------------------------------------------------------------------------------- /mqseries.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2003, JAWA Management Software GmbH http://www.jawa.at 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 3. The names of the authors may not be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 21 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | This code cannot simply be copied and put under the GNU Public License or 29 | any other GPL-like (LGPL, GPL2) License. 30 | 31 | $Id: b5ea348d1180621c3597e05fe347b2e16b0fbe0b $ 32 | 33 | Author: Michael Bretterklieber 34 | Philippe Tjon A Hen 35 | Pierrick Charron 36 | 37 | */ 38 | 39 | #ifdef HAVE_CONFIG_H 40 | #include "config.h" 41 | #endif 42 | 43 | #include "php.h" 44 | #include "ext/standard/info.h" 45 | #include "php_mqseries.h" 46 | 47 | /* {{{ helper methods 48 | */ 49 | static void _mqseries_disc(zend_resource *rsrc); 50 | static void _mqseries_close(zend_resource *rsrc); 51 | static void _mqseries_bytes(zend_resource *rsrc); 52 | 53 | static int _mqseries_is_compcode_reason_ref(zval *, zval *); 54 | static int _mqseries_is_called_by_ref(zval *, char *); 55 | 56 | /* }}} */ 57 | 58 | /* If you declare any globals in php_mqseries.h uncomment this: 59 | ZEND_DECLARE_MODULE_GLOBALS(mqseries) 60 | */ 61 | 62 | /* True global resources - no need for thread safety here */ 63 | int le_mqseries_conn; 64 | int le_mqseries_obj; 65 | int le_mqseries_bytes; 66 | 67 | static HashTable *ht_reason_texts; 68 | 69 | /* {{{ arginfo */ 70 | 71 | /****************************************************************/ 72 | /* Parameter usage in functions and structures */ 73 | /* I: input */ 74 | /* IB: input, data buffer */ 75 | /* IL: input, length of data buffer */ 76 | /* IO: input and output */ 77 | /* IOB: input and output, data buffer */ 78 | /* IOL: input and output, length of data buffer */ 79 | /* O: output */ 80 | /* OB: output, data buffer */ 81 | /* OC: output, completion code */ 82 | /* OR: output, reason code */ 83 | /* FP: function pointer */ 84 | /****************************************************************/ 85 | 86 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mqseries_back, 0, 0, 3) 87 | ZEND_ARG_INFO(0, hconn) /* I: Connection handle */ 88 | ZEND_ARG_INFO(1, compCode) /* OC: Completion code */ 89 | ZEND_ARG_INFO(1, reason) /* OR: Reason code qualifying CompCode */ 90 | ZEND_END_ARG_INFO() 91 | 92 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mqseries_begin, 0, 0, 4) 93 | ZEND_ARG_INFO(0, hconn) /* I: Connection handle */ 94 | ZEND_ARG_ARRAY_INFO(0, beginOptions, 0) /* IO: Options that control the action of MQBEGIN */ 95 | ZEND_ARG_INFO(1, compCode) /* OC: Completion code */ 96 | ZEND_ARG_INFO(1, reason) /* OR: Reason code qualifying CompCode */ 97 | ZEND_END_ARG_INFO() 98 | 99 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mqseries_close, 0, 0, 5) 100 | ZEND_ARG_INFO(0, hconn) /* I: Connection handle */ 101 | ZEND_ARG_INFO(1, hobj) /* IO: Object handle */ 102 | ZEND_ARG_INFO(0, options) /* I: Options that control the action of MQCLOSE */ 103 | ZEND_ARG_INFO(1, compCode) /* OC: Completion code */ 104 | ZEND_ARG_INFO(1, reason) /* OR: Reason code qualifying CompCode */ 105 | ZEND_END_ARG_INFO() 106 | 107 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mqseries_cmit, 0, 0, 3) 108 | ZEND_ARG_INFO(0, hconn) /* I: Connection handle */ 109 | ZEND_ARG_INFO(1, compCode) /* OC: Completion code */ 110 | ZEND_ARG_INFO(1, reason) /* OR: Reason code qualifying CompCode */ 111 | ZEND_END_ARG_INFO() 112 | 113 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mqseries_conn, 0, 0, 4) 114 | ZEND_ARG_INFO(0, qMgrName) /* I: Name of queue manager */ 115 | ZEND_ARG_INFO(1, hconn) /* O: Connection handle */ 116 | ZEND_ARG_INFO(1, compCode) /* OC: Completion code */ 117 | ZEND_ARG_INFO(1, reason) /* OR: Reason code qualifying CompCode */ 118 | ZEND_END_ARG_INFO() 119 | 120 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mqseries_connx, 0, 0, 5) 121 | ZEND_ARG_INFO(0, qMgrName) /* I: Name of queue manager */ 122 | ZEND_ARG_ARRAY_INFO(1, connectOpts, 0) /* IO: Options that control the action of MQCONNX */ 123 | ZEND_ARG_INFO(1, hconn) /* O: Connection handle */ 124 | ZEND_ARG_INFO(1, compCode) /* OC: Completion code */ 125 | ZEND_ARG_INFO(1, reason) /* OR: Reason code qualifying CompCode */ 126 | ZEND_END_ARG_INFO() 127 | 128 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mqseries_disc, 0, 0, 3) 129 | ZEND_ARG_INFO(0, hconn) /* IO: Connection handle */ 130 | ZEND_ARG_INFO(1, compCode) /* OC: Completion code */ 131 | ZEND_ARG_INFO(1, reason) /* OR: Reason code qualifying CompCode */ 132 | ZEND_END_ARG_INFO() 133 | 134 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mqseries_get, 0, 0, 9) 135 | ZEND_ARG_INFO(0, hconn) /* I: Connection handle */ 136 | ZEND_ARG_INFO(0, hobj) /* I: Object handle */ 137 | ZEND_ARG_ARRAY_INFO(1, msgDesc, 0) /* IO: Message descriptor */ 138 | ZEND_ARG_ARRAY_INFO(1, getMsgOts, 0) /* IO: Options that control the action of MQGET */ 139 | ZEND_ARG_INFO(0, bufferlength) /* IL: Length in bytes of the Buffer area */ 140 | ZEND_ARG_INFO(1, buffer) /* OB: Area to contain the message data */ 141 | ZEND_ARG_INFO(1, dataLength) /* O: Length of the message */ 142 | ZEND_ARG_INFO(1, compCode) /* OC: Completion code */ 143 | ZEND_ARG_INFO(1, reason) /* OR: Reason code qualifying CompCode */ 144 | ZEND_END_ARG_INFO() 145 | 146 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mqseries_inq, 0, 0, 10) 147 | ZEND_ARG_INFO(0, hconn) /* I: Connection handle */ 148 | ZEND_ARG_INFO(0, hobj) /* I: Object handle */ 149 | ZEND_ARG_INFO(0, selectorCount) /* I: Count of selectors */ 150 | ZEND_ARG_ARRAY_INFO(0, selectors, 0) /* I: Array of attribute selectors */ 151 | ZEND_ARG_INFO(0, intAttrCount) /* I: Count of integer attributes */ 152 | ZEND_ARG_INFO(1, intAttrs) /* O: Array of integer attributes */ 153 | ZEND_ARG_INFO(0, charAttrLength) /* IL: Length of character attributes buffer */ 154 | ZEND_ARG_INFO(1, charAttrs) /* OB: Character attributes */ 155 | ZEND_ARG_INFO(1, compCode) /* OC: Completion code */ 156 | ZEND_ARG_INFO(1, reason) /* OR: Reason code qualifying CompCode */ 157 | ZEND_END_ARG_INFO() 158 | 159 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mqseries_open, 0, 0, 6) 160 | ZEND_ARG_INFO(0, hconn) /* I: Connection handle */ 161 | ZEND_ARG_ARRAY_INFO(1, objDesc, 0) /* IO: Object descriptor */ 162 | ZEND_ARG_INFO(0, options) /* I: Options that control the action of MQOPEN */ 163 | ZEND_ARG_INFO(1, hobj) /* O: Object handle */ 164 | ZEND_ARG_INFO(1, compCode) /* OC: Completion code */ 165 | ZEND_ARG_INFO(1, reason) /* OR: Reason code qualifying CompCode */ 166 | ZEND_END_ARG_INFO() 167 | 168 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mqseries_put, 0, 0, 7) 169 | ZEND_ARG_INFO(0, hconn) /* I: Connection handle */ 170 | ZEND_ARG_INFO(0, hobj) /* I: Object handle */ 171 | ZEND_ARG_ARRAY_INFO(1, msgDesc, 0) /* IO: Message descriptor */ 172 | ZEND_ARG_ARRAY_INFO(1, putMsgOpts, 0) /* IO: Options that control the action of MQPUT */ 173 | ZEND_ARG_INFO(0, buffer) /* IB: Message data */ 174 | ZEND_ARG_INFO(1, compCode) /* OC: Completion code */ 175 | ZEND_ARG_INFO(1, reason) /* OR: Reason code qualifying CompCode */ 176 | ZEND_END_ARG_INFO() 177 | 178 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mqseries_put1, 0, 0, 7) 179 | ZEND_ARG_INFO(0, hconn) /* I: Connection handle */ 180 | ZEND_ARG_ARRAY_INFO(0, objDesc, 0) /* IO: Object descriptor */ 181 | ZEND_ARG_ARRAY_INFO(1, msgDesc, 0) /* IO: Message descriptor */ 182 | ZEND_ARG_ARRAY_INFO(1, putMsgOpts, 0) /* IO: Options that control the action of MQPUT1 */ 183 | ZEND_ARG_INFO(0, buffer) /* IB: Message data */ 184 | ZEND_ARG_INFO(1, compCode) /* OC: Completion code */ 185 | ZEND_ARG_INFO(1, reason) /* OR: Reason code qualifying CompCode */ 186 | ZEND_END_ARG_INFO() 187 | 188 | 189 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mqseries_set, 0, 0, 10) 190 | ZEND_ARG_INFO(0, hconn) /* I: Connection handle */ 191 | ZEND_ARG_INFO(0, hobj) /* I: Object handle */ 192 | ZEND_ARG_INFO(0, selectorCount) /* I: Count of selectors */ 193 | ZEND_ARG_ARRAY_INFO(0, selectors, 0) /* I: Array of attribute selectors */ 194 | ZEND_ARG_INFO(0, intAttrCount) /* I: Count of integer attributes */ 195 | ZEND_ARG_ARRAY_INFO(0, intAttrs, 0) /* I: Array of integer attributes */ 196 | ZEND_ARG_INFO(0, charAttrLength) /* IL: Length of character attributes buffer */ 197 | ZEND_ARG_ARRAY_INFO(0, charAttrs, 0) /* IB: Character attributes */ 198 | ZEND_ARG_INFO(1, compCode) /* OC: Completion code */ 199 | ZEND_ARG_INFO(1, reason) /* OR: Reason code qualifying CompCode */ 200 | ZEND_END_ARG_INFO() 201 | 202 | #ifdef HAVE_MQSERIESLIB_V7 203 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mqseries_sub, 0, 0, 6) 204 | ZEND_ARG_INFO(0, hconn) /* I: Connection handle */ 205 | ZEND_ARG_ARRAY_INFO(1, subDesc, 0) /* IO: Subscription descriptor */ 206 | ZEND_ARG_INFO(1, hobj) /* IO: Object handle */ 207 | ZEND_ARG_INFO(1, hsub) /* O: Subscription object handle */ 208 | ZEND_ARG_INFO(1, compCode) /* OC: Completion code */ 209 | ZEND_ARG_INFO(1, reason) /* OR: Reason code qualifying CompCode */ 210 | ZEND_END_ARG_INFO() 211 | 212 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mqseries_stat, 0, 0, 5) 213 | ZEND_ARG_INFO(0, hconn) /* I: Connection handle */ 214 | ZEND_ARG_INFO(0, type) /* I: Status information type */ 215 | ZEND_ARG_ARRAY_INFO(1, status, 0) /* IO: Status information */ 216 | ZEND_ARG_INFO(1, compCode) /* OC: Completion code */ 217 | ZEND_ARG_INFO(1, reason) /* OR: Reason code qualifying CompCode */ 218 | ZEND_END_ARG_INFO() 219 | 220 | #endif /* HAVE_MQSERIESLIB_V7 */ 221 | 222 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mqseries_strerror, 0, 0, 1) 223 | ZEND_ARG_INFO(0, reason) 224 | ZEND_END_ARG_INFO() 225 | 226 | ZEND_BEGIN_ARG_INFO_EX(arginfo_mqseries_bytes_val, 0, 0, 1) 227 | ZEND_ARG_INFO(0, resource) 228 | ZEND_END_ARG_INFO() 229 | /* }}} */ 230 | 231 | /* {{{ mqseries_functions[] 232 | * 233 | * Every user visible function must have an entry in mqseries_functions[]. 234 | */ 235 | zend_function_entry mqseries_functions[] = { 236 | PHP_FE(mqseries_back, arginfo_mqseries_back) 237 | PHP_FE(mqseries_begin, arginfo_mqseries_begin) 238 | PHP_FE(mqseries_close, arginfo_mqseries_close) 239 | PHP_FE(mqseries_cmit, arginfo_mqseries_cmit) 240 | PHP_FE(mqseries_conn, arginfo_mqseries_conn) 241 | PHP_FE(mqseries_connx, arginfo_mqseries_connx) 242 | PHP_FE(mqseries_disc, arginfo_mqseries_disc) 243 | PHP_FE(mqseries_get, arginfo_mqseries_get) 244 | PHP_FE(mqseries_inq, arginfo_mqseries_inq) 245 | PHP_FE(mqseries_open, arginfo_mqseries_open) 246 | PHP_FE(mqseries_put, arginfo_mqseries_put) 247 | PHP_FE(mqseries_put1, arginfo_mqseries_put1) 248 | PHP_FE(mqseries_set, arginfo_mqseries_set) 249 | PHP_FE(mqseries_strerror, arginfo_mqseries_strerror) 250 | PHP_FE(mqseries_bytes_val, arginfo_mqseries_bytes_val) 251 | #ifdef HAVE_MQSERIESLIB_V7 252 | PHP_FE(mqseries_sub, arginfo_mqseries_sub) 253 | PHP_FE(mqseries_stat, arginfo_mqseries_stat) 254 | #endif /* HAVE_MQSERIESLIB_V7 */ 255 | {NULL, NULL, NULL} /* Must be the last line in mqseries_functions[] */ 256 | }; 257 | /* }}} */ 258 | 259 | /* {{{ mqseries_module_entry 260 | */ 261 | zend_module_entry mqseries_module_entry = { 262 | #if ZEND_MODULE_API_NO >= 20010901 263 | STANDARD_MODULE_HEADER, 264 | #endif 265 | "mqseries", 266 | mqseries_functions, 267 | PHP_MINIT(mqseries), 268 | PHP_MSHUTDOWN(mqseries), 269 | NULL, 270 | NULL, 271 | PHP_MINFO(mqseries), 272 | #if ZEND_MODULE_API_NO >= 20010901 273 | PHP_MQSERIES_VERSION, 274 | #endif 275 | STANDARD_MODULE_PROPERTIES 276 | }; 277 | /* }}} */ 278 | 279 | #ifdef COMPILE_DL_MQSERIES 280 | ZEND_GET_MODULE(mqseries) 281 | #endif 282 | 283 | 284 | /* {{{ PHP_MINIT_FUNCTION 285 | */ 286 | PHP_MINIT_FUNCTION(mqseries) 287 | { 288 | char *vp = NULL; 289 | 290 | /* don't change the order of these, objects must be freed before connections */ 291 | le_mqseries_obj = zend_register_list_destructors_ex(_mqseries_close, NULL, PHP_MQSERIES_OBJ_RES_NAME, module_number); 292 | 293 | le_mqseries_conn = zend_register_list_destructors_ex(_mqseries_disc, NULL, PHP_MQSERIES_DESCRIPTOR_RES_NAME, module_number); 294 | 295 | le_mqseries_bytes = zend_register_list_destructors_ex(_mqseries_bytes, NULL, PHP_MQSERIES_BYTES_RES_NAME, module_number); 296 | 297 | #include "mqseries_init_const.h" 298 | 299 | ht_reason_texts = (HashTable *) malloc(sizeof(HashTable)); 300 | zend_hash_init(ht_reason_texts, 0, NULL, NULL, 1); 301 | 302 | #define ADD_MQ_REASON_TXT(key, value) { vp = value; zend_hash_index_update_ptr(ht_reason_texts, key, vp); } 303 | #include "mqseries_reason_texts.h" 304 | 305 | return SUCCESS; 306 | } 307 | /* }}} */ 308 | 309 | /* {{{ PHP_MSHUTDOWN_FUNCTION 310 | */ 311 | PHP_MSHUTDOWN_FUNCTION(mqseries) 312 | { 313 | zend_hash_destroy(ht_reason_texts); 314 | free(ht_reason_texts); 315 | return SUCCESS; 316 | } 317 | /* }}} */ 318 | 319 | /* {{{ PHP_MINFO_FUNCTION 320 | */ 321 | PHP_MINFO_FUNCTION(mqseries) 322 | { 323 | php_info_print_table_start(); 324 | php_info_print_table_header(2, "mqseries support", "enabled"); 325 | php_info_print_table_row(2, "Version", PHP_MQSERIES_VERSION); 326 | php_info_print_table_row(2, "Revision", "$Id: b5ea348d1180621c3597e05fe347b2e16b0fbe0b $"); 327 | php_info_print_table_end(); 328 | } 329 | /* }}} */ 330 | 331 | /* {{{ proto void mqseries_conn(string name, resource &hconn, int &compcode, int &reason) 332 | 333 | The mqseries_conn call connects an application program to a queue manager. 334 | It provides a queue manager connection handle, which the application uses on subsequent message queuing calls. 335 | 336 | PHP sample: 337 | 338 | mqseries_conn('QM_donald', $hconn, $compCode, $reason); 339 | if ($compCode !== MQSERIES_MQCC_OK) { 340 | printf("CompCode:%d Reason:%d Text:%s\n", $compCode, $reason, mqseries_strerror($reason)); 341 | } 342 | 343 | MQ call: 344 | 345 | MQCONN (QMgrName, &Hconn, &CompCode, &Reason); 346 | 347 | MQCHAR48 QMgrName; -- Name of queue manager 348 | MQHCONN Hconn; -- Connection handle 349 | MQLONG CompCode; -- Completion code 350 | MQLONG Reason; -- Reason code qualifying CompCode 351 | 352 | */ 353 | PHP_FUNCTION(mqseries_conn) 354 | { 355 | char *name; 356 | size_t name_len; 357 | zval *z_conn, *z_comp_code, *z_reason; 358 | 359 | mqseries_descriptor *mqdesc; 360 | 361 | MQCHAR48 qManagerName; 362 | MQLONG comp_code; 363 | MQLONG reason; 364 | 365 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "sz/z/z/", &name, &name_len, &z_conn, &z_comp_code, &z_reason) == FAILURE) { 366 | return; 367 | } 368 | 369 | strncpy(qManagerName, name, sizeof(MQCHAR48)); 370 | 371 | mqdesc = (mqseries_descriptor *) emalloc(sizeof(mqseries_descriptor)); 372 | MQCONN(qManagerName, &mqdesc->conn, &comp_code, &reason); 373 | 374 | ZVAL_LONG(z_comp_code, (long) comp_code); 375 | ZVAL_LONG(z_reason, (long) reason); 376 | 377 | if (comp_code == MQCC_OK) { 378 | zval_dtor(z_conn); 379 | ZVAL_RES(z_conn, zend_register_resource(mqdesc, le_mqseries_conn)); 380 | mqdesc->id = Z_RES_P(z_conn)->handle; 381 | } else { 382 | efree(mqdesc); 383 | } 384 | } 385 | /* }}} */ 386 | 387 | /* {{{ proto void mqseries_connx(string name, array &connect_opts, resource &hconn, int &compCode, int &reason) 388 | 389 | The mqseries_connx call connects an application program to a queue manager. It provides a queue manager connection handle, which is used by the application on subsequent MQ calls. 390 | The mqseries_connx call is similar to the mqseries_conn call, except that mqseries_connx allows options to be specified to control the way that the call works. 391 | 392 | PHP sample: 393 | 394 | $mqcno = array( 395 | 'StrucId' => MQSERIES_MQCNO_STRUC_ID, 396 | 'Version' => MQSERIES_MQCNO_VERSION_2, 397 | 'Options' => MQSERIES_MQCNO_STANDARD_BINDING, 398 | 'MQCD' => array( 399 | 'ChannelName' => 'D800MQ.CLIENT', 400 | 'ConnectionName' => 'localhost', 401 | 'TransportType' => MQSERIES_MQXPT_TCP, 402 | ), 403 | ); 404 | mqseries_connx('D800MQ', $mqcno, $hconn, $compCode, $reason); 405 | if ($compCode !== MQSERIES_MQCC_OK) { 406 | printf("CompCode:%d Reason:%d Text:%s\n", $compCode, $reason, mqseries_strerror($reason)); 407 | } 408 | 409 | MQ call: 410 | 411 | MQCONNX (QMgrName, &ConnectOpts, &Hconn, &CompCode, &Reason); 412 | 413 | MQCHAR48 QMgrName; -- Name of queue manager 414 | MQCNO ConnectOpts; -- Options that control the action of MQCONNX 415 | MQHCONN Hconn; -- Connection handle 416 | MQLONG CompCode; -- Completion code 417 | MQLONG Reason; -- Reason code qualifying CompCode 418 | */ 419 | PHP_FUNCTION(mqseries_connx) 420 | { 421 | char *name; 422 | size_t name_len; 423 | mqseries_descriptor *mqdesc; 424 | zval *z_connect_opts, *z_conn, *z_comp_code, *z_reason; 425 | 426 | MQLONG comp_code; 427 | MQLONG reason; 428 | MQCNO connect_opts = {MQCNO_DEFAULT}; 429 | MQCD channel_definition = {MQCD_CLIENT_CONN_DEFAULT}; 430 | MQSCO ssl_configuration = {MQSCO_DEFAULT}; 431 | MQAIR authentication_information_record = {MQAIR_DEFAULT}; /* Only 1 (one) record is supported for now. */ 432 | MQCHAR LDAPUserName[MQ_DISTINGUISHED_NAME_LENGTH]; 433 | 434 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "saz/z/z/", &name, &name_len, &z_connect_opts, &z_conn, &z_comp_code, &z_reason) == FAILURE) { 435 | return; 436 | } 437 | 438 | _mqseries_set_mqcno_from_array(z_connect_opts, &connect_opts, &channel_definition, &ssl_configuration, &authentication_information_record, LDAPUserName); 439 | 440 | mqdesc = (mqseries_descriptor *) emalloc(sizeof(mqseries_descriptor)); 441 | 442 | MQCONNX(name, &connect_opts, &mqdesc->conn, &comp_code, &reason); 443 | 444 | ZVAL_LONG(z_comp_code, (long) comp_code); 445 | ZVAL_LONG(z_reason, (long) reason); 446 | 447 | if (comp_code == MQCC_OK) { 448 | zval_dtor(z_conn); 449 | ZVAL_RES(z_conn, zend_register_resource(mqdesc, le_mqseries_conn)); 450 | mqdesc->id = Z_RES_P(z_conn)->handle; 451 | } else { 452 | efree(mqdesc); 453 | } 454 | } 455 | /* }}} */ 456 | 457 | /* {{{ proto void mqseries_open(resource hconn, array &objDesc, int options, resource &hobj, int &compCode, int &reason) 458 | 459 | The mq_open call establishes access to an object. 460 | 461 | PHP sample: 462 | 463 | mqseries_open( 464 | $conn, 465 | array('ObjectName' => 'TESTQ', 'ObjectQMgrName' => 'D800MQ'), 466 | MQSERIES_MQOO_INPUT_AS_Q_DEF | MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT, 467 | $obj, 468 | $compCode, 469 | $reason 470 | ); 471 | if ($compCode !== MQSERIES_MQCC_OK) { 472 | printf("CompCode:%d Reason:%d Text:%s\n", $compCode, $reason, mqseries_strerror($reason)); 473 | } 474 | 475 | MQ call: 476 | 477 | MQOPEN (Hconn, &ObjDesc, Options, &Hobj, &CompCode, &Reason); 478 | 479 | MQHCONN Hconn; -- Connection handle 480 | MQOD ObjDesc; -- Object descriptor 481 | MQLONG Options; -- Options that control the action of MQOPEN 482 | MQHOBJ Hobj; -- Object handle 483 | MQLONG CompCode; -- Completion code 484 | MQLONG Reason; -- Reason code qualifying CompCode 485 | */ 486 | PHP_FUNCTION(mqseries_open) 487 | { 488 | mqseries_descriptor *mqdesc; 489 | mqseries_obj *mqobj; 490 | zval *z_mqdesc, *z_obj_desc, *z_obj, *z_comp_code, *z_reason; 491 | 492 | zend_long open_options; 493 | 494 | MQLONG comp_code; 495 | MQLONG reason; 496 | MQOD obj_desc = {MQOD_DEFAULT}; 497 | 498 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "ra/lz/z/z/", &z_mqdesc, &z_obj_desc, &open_options, &z_obj, &z_comp_code, &z_reason) == FAILURE) { 499 | return; 500 | } 501 | 502 | if ((mqdesc = (mqseries_descriptor *) zend_fetch_resource(Z_RES_P(z_mqdesc), PHP_MQSERIES_DESCRIPTOR_RES_NAME, le_mqseries_conn)) == NULL) { 503 | RETURN_FALSE; 504 | } 505 | 506 | _mqseries_set_mqod_from_array(z_obj_desc, &obj_desc); 507 | 508 | mqobj = (mqseries_obj *) emalloc(sizeof(mqseries_obj)); 509 | 510 | MQOPEN(mqdesc->conn, &obj_desc, (MQLONG) open_options, &mqobj->obj, &comp_code, &reason); 511 | 512 | ZVAL_LONG(z_comp_code, (long) comp_code); 513 | ZVAL_LONG(z_reason, (long) reason); 514 | 515 | _mqseries_set_array_from_mqod(z_obj_desc, &obj_desc); 516 | 517 | if (comp_code == MQCC_OK) { 518 | zval_dtor(z_obj); 519 | mqobj->conn = &mqdesc->conn; 520 | ZVAL_RES(z_obj, zend_register_resource(mqobj, le_mqseries_obj)); 521 | mqobj->id = Z_RES_P(z_obj)->handle; 522 | } else { 523 | /* So we don't register the ref. But we already allocated some memory lets free that */ 524 | efree(mqobj); 525 | } 526 | } 527 | /* }}} */ 528 | 529 | /* {{{ proto void mqseries_get(resource hconn, resource hobj, array &msgDesc, array &getMsgOpts, int bufferLength, string &buffer, int &dataLength, int &compCode, int &reason) 530 | 531 | The mqseries_get call retrieves a message from a local queue that has been opened using the mqseries_open call. 532 | 533 | PHP sample: 534 | 535 | $mqmd = array(); 536 | $mqgmo = array( 537 | 'Options' => MQSERIES_MQGMO_FAIL_IF_QUIESCING | MQSERIES_MQGMO_WAIT, 538 | 'WaitInterval' => MQSERIES_MQWI_UNLIMITED 539 | ); 540 | mqseries_get($conn, $obj, $mqmd, $mqmo, 10, $msg, $dataLength, $compCode, $reason); 541 | if ($compCode !== MQSERIES_MQCC_OK) { 542 | printf("CompCode:%d Reason:%d Text:%s\n", $compCode, $reason, mqseries_strerror($reason)); 543 | } 544 | 545 | MQ call: 546 | 547 | MQGET (Hconn, Hobj, &MsgDesc, &GetMsgOpts, BufferLength, Buffer, &DataLength, &CompCode, &Reason); 548 | 549 | MQHCONN Hconn; -- Connection handle 550 | MQHOBJ Hobj; -- Object handle 551 | MQMD MsgDesc; -- Message descriptor 552 | MQGMO GetMsgOpts; -- Options that control the action of MQGET 553 | MQLONG BufferLength; -- Length in bytes of the Buffer area 554 | MQBYTE Buffer[n]; -- Area to contain the message data 555 | MQLONG DataLength; -- Length of the message 556 | MQLONG CompCode; -- Completion code 557 | MQLONG Reason; -- Reason code qualifying CompCode 558 | 559 | */ 560 | PHP_FUNCTION(mqseries_get) 561 | { 562 | mqseries_descriptor *mqdesc; 563 | mqseries_obj *mqobj; 564 | zval *z_mqdesc, *z_mqobj, *z_msg_desc, *z_get_msg_opts, *z_comp_code, *z_reason, *z_data_length, *z_buffer; 565 | 566 | MQLONG comp_code; 567 | MQLONG reason; 568 | 569 | zend_long buf_len = 0L; 570 | 571 | MQLONG data_length = 0L; 572 | MQBYTE *buf, *data; 573 | MQMD msg_desc = { MQMD_DEFAULT }; /* Message descriptor */ 574 | MQGMO get_msg_opts = { MQGMO_DEFAULT }; /* Options which control the MQGET call */ 575 | 576 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "rra/a/lz/z/z/z/", &z_mqdesc, &z_mqobj, &z_msg_desc, &z_get_msg_opts, &buf_len, &z_buffer, &z_data_length, &z_comp_code, &z_reason) == FAILURE) { 577 | return; 578 | } 579 | 580 | if ((mqdesc = (mqseries_descriptor *) zend_fetch_resource(Z_RES_P(z_mqdesc), PHP_MQSERIES_DESCRIPTOR_RES_NAME, le_mqseries_conn)) == NULL) { 581 | RETURN_FALSE; 582 | } 583 | if ((mqobj = (mqseries_obj *) zend_fetch_resource(Z_RES_P(z_mqobj), PHP_MQSERIES_OBJ_RES_NAME, le_mqseries_obj)) == NULL) { 584 | RETURN_FALSE; 585 | } 586 | 587 | _mqseries_set_mqmd_from_array(z_msg_desc, &msg_desc); 588 | _mqseries_set_mqgmo_from_array(z_get_msg_opts, &get_msg_opts); 589 | 590 | data = buf = (MQBYTE *) emalloc(sizeof(MQBYTE) * buf_len); 591 | MQGET(mqdesc->conn, mqobj->obj, &msg_desc, &get_msg_opts, (MQLONG) buf_len, buf, &data_length, &comp_code, &reason); 592 | 593 | if (!strncmp(msg_desc.Format, MQFMT_RF_HEADER, sizeof(msg_desc.Format))) { 594 | MQRFH rfh = {MQRFH_DEFAULT}; 595 | memcpy(&rfh, buf, MQRFH_STRUC_LENGTH_FIXED); 596 | data = buf + rfh.StrucLength; 597 | buf_len -= rfh.StrucLength; 598 | } else if (!strncmp(msg_desc.Format, MQFMT_RF_HEADER_2, sizeof(msg_desc.Format))) { 599 | MQRFH2 rfh2 = {MQRFH2_DEFAULT}; 600 | memcpy(&rfh2, buf, MQRFH_STRUC_LENGTH_FIXED_2); 601 | data = buf + rfh2.StrucLength; 602 | buf_len -= rfh2.StrucLength; 603 | } else if (!strncmp(msg_desc.Format, MQFMT_MD_EXTENSION, sizeof(msg_desc.Format))) { 604 | MQMDE rfhe = { MQMDE_DEFAULT }; 605 | memcpy(&rfhe, buf, MQMDE_LENGTH_2); 606 | data = buf + rfhe.StrucLength; 607 | buf_len -= rfhe.StrucLength; 608 | } 609 | 610 | ZVAL_LONG(z_comp_code, (long) comp_code); 611 | ZVAL_LONG(z_reason, (long) reason); 612 | ZVAL_LONG(z_data_length, (long) data_length); 613 | 614 | zval_dtor(z_buffer); 615 | 616 | ZVAL_STRINGL(z_buffer, (char *) data, (buf_len > 0) ? (buf_len < (long) data_length ? buf_len : (long) data_length) : 0); 617 | 618 | _mqseries_set_array_from_mqmd(z_msg_desc, &msg_desc); 619 | _mqseries_set_array_from_mqgmo(z_get_msg_opts, &get_msg_opts); 620 | 621 | efree(buf); 622 | } 623 | /* }}} */ 624 | 625 | /* {{{ proto void mqseries_put(resource hconn, resource hobj, array &msgDesc, array &putMsgOpts, string buffer, int &compCode, int &reason) 626 | 627 | The mqseries_put call puts a message on a queue or distribution list, or to a topic. The queue, distribution list or topic must already be open. 628 | 629 | PHP sample: 630 | 631 | $md = array( 632 | 'Version' => MQSERIES_MQMD_VERSION_1, 633 | 'Expiry' => MQSERIES_MQEI_UNLIMITED, 634 | 'Report' => MQSERIES_MQRO_NONE, 635 | 'MsgType' => MQSERIES_MQMT_DATAGRAM, 636 | 'Format' => MQSERIES_MQFMT_STRING, 637 | 'Priority' => 1, 638 | 'Persistence' => MQSERIES_MQPER_PERSISTENT, 639 | 'ReplyToQ' => 'RCVQ' 640 | ); 641 | mqseries_put($conn, $obj_snd, $md, array('Options' => MQSERIES_MQPMO_NEW_MSG_ID), 'Ping', $compCode, $reason); 642 | if ($compCode !== MQSERIES_MQCC_OK) { 643 | printf("CompCode:%d Reason:%d Text:%s\n", $compCode, $reason, mqseries_strerror($reason)); 644 | } 645 | 646 | MQ call: 647 | 648 | MQPUT (Hconn, Hobj, &MsgDesc, &PutMsgOpts, BufferLength, Buffer, &CompCode, &Reason); 649 | 650 | MQHCONN Hconn; -- Connection handle 651 | MQHOBJ Hobj; -- Object handle 652 | MQMD MsgDesc; -- Message descriptor 653 | MQPMO PutMsgOpts; -- Options that control the action of MQPUT 654 | MQLONG BufferLength; -- Length of the message in Buffer 655 | MQBYTE Buffer[n]; -- Message data 656 | MQLONG CompCode; -- Completion code 657 | MQLONG Reason; -- Reason code qualifying CompCode 658 | */ 659 | PHP_FUNCTION(mqseries_put) 660 | { 661 | mqseries_descriptor *mqdesc; 662 | mqseries_obj *mqobj; 663 | zval *z_mqdesc, *z_mqobj, *z_msg_desc, *z_put_msg_opts, *z_comp_code, *z_reason; 664 | char *msg; 665 | zend_long msg_len; 666 | 667 | MQMD msg_desc = {MQMD_DEFAULT}; /* Message descriptor */ 668 | MQPMO put_msg_opts = {MQPMO_DEFAULT}; /* Options which control the MQPUT call */ 669 | MQLONG comp_code; 670 | MQLONG reason; 671 | 672 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "rra/a/sz/z/", &z_mqdesc, &z_mqobj, &z_msg_desc, &z_put_msg_opts, &msg, &msg_len, &z_comp_code, &z_reason) == FAILURE) { 673 | return; 674 | } 675 | 676 | if ((mqdesc = (mqseries_descriptor *) zend_fetch_resource(Z_RES_P(z_mqdesc), PHP_MQSERIES_DESCRIPTOR_RES_NAME, le_mqseries_conn)) == NULL) { 677 | RETURN_FALSE; 678 | } 679 | if ((mqobj = (mqseries_obj *) zend_fetch_resource(Z_RES_P(z_mqobj), PHP_MQSERIES_OBJ_RES_NAME, le_mqseries_obj)) == NULL) { 680 | RETURN_FALSE; 681 | } 682 | 683 | _mqseries_set_mqmd_from_array(z_msg_desc, &msg_desc); 684 | _mqseries_set_mqpmo_from_array(z_put_msg_opts, &put_msg_opts); 685 | 686 | MQPUT(mqdesc->conn, mqobj->obj, &msg_desc, &put_msg_opts, (MQLONG) msg_len, msg, &comp_code, &reason); 687 | 688 | ZVAL_LONG(z_comp_code, (long) comp_code); 689 | ZVAL_LONG(z_reason, (long) reason); 690 | 691 | _mqseries_set_array_from_mqmd(z_msg_desc, &msg_desc); 692 | _mqseries_set_array_from_mqpmo(z_put_msg_opts, &put_msg_opts); 693 | } 694 | /* }}} */ 695 | 696 | /* {{{ proto void mqseries_begin(resource hconn, array &beginOptions, int &compCode, int &reason) 697 | 698 | The mqseries_begin call begins a unit of work that is coordinated by the queue manager, and that may involve external resource managers. 699 | 700 | PHP sample: 701 | 702 | mqseries_begin( 703 | $conn, 704 | array('Options' => MQSERIES_MQBO_NONE), 705 | $compCcode, 706 | $reason 707 | ); 708 | 709 | MQ call: 710 | 711 | MQBEGIN (Hconn, &BeginOptions, &CompCode, &Reason); 712 | 713 | MQHCONN Hconn; -- Connection handle 714 | MQBO BeginOptions; -- Options that control the action of MQBEGIN 715 | MQLONG CompCode; -- Completion code 716 | MQLONG Reason; -- Reason code qualifying CompCode 717 | */ 718 | PHP_FUNCTION(mqseries_begin) 719 | { 720 | mqseries_descriptor *mqdesc; 721 | zval *z_mqdesc, *z_array, *z_comp_code, *z_reason; 722 | MQLONG comp_code; 723 | MQLONG reason; 724 | 725 | MQBO begin_opts = {MQBO_DEFAULT}; 726 | 727 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "raz/z/", &z_mqdesc, &z_array, &z_comp_code, &z_reason) == FAILURE) { 728 | return; 729 | } 730 | 731 | if ((mqdesc = (mqseries_descriptor *) zend_fetch_resource(Z_RES_P(z_mqdesc), PHP_MQSERIES_DESCRIPTOR_RES_NAME, le_mqseries_conn)) == NULL) { 732 | RETURN_FALSE; 733 | } 734 | 735 | _mqseries_set_mqbo_from_array(z_array, &begin_opts); 736 | 737 | MQBEGIN(mqdesc->conn, &begin_opts, &comp_code, &reason); 738 | 739 | ZVAL_LONG(z_comp_code, (long) comp_code); 740 | ZVAL_LONG(z_reason, (long) reason); 741 | } 742 | /* }}} */ 743 | 744 | /* {{{ proto void mqseries_cmit(resource hconn, int &compCode, int &reason) 745 | 746 | The mqseries_cmit call indicates to the queue manager that the application has reached a syncpoint, and that all the message 747 | gets and puts that have occurred since the last syncpoint are to be made permanent. 748 | 749 | PHP sample: 750 | 751 | mqseries_cmit($conn, $compCode, $reason); 752 | 753 | MQ call: 754 | 755 | MQCMIT (Hconn, &CompCode, &Reason); 756 | 757 | MQHCONN Hconn; -- Connection handle 758 | MQLONG CompCode; -- Completion code 759 | MQLONG Reason; -- Reason code qualifying CompCode 760 | */ 761 | PHP_FUNCTION(mqseries_cmit) 762 | { 763 | MQLONG comp_code; 764 | MQLONG reason; 765 | 766 | mqseries_descriptor *mqdesc; 767 | zval *z_mqdesc, *z_comp_code, *z_reason; 768 | 769 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz/z/", &z_mqdesc, &z_comp_code, &z_reason) == FAILURE) { 770 | return; 771 | } 772 | 773 | if ((mqdesc = (mqseries_descriptor *) zend_fetch_resource(Z_RES_P(z_mqdesc), PHP_MQSERIES_DESCRIPTOR_RES_NAME, le_mqseries_conn)) == NULL) { 774 | RETURN_FALSE; 775 | } 776 | 777 | MQCMIT(mqdesc->conn, &comp_code, &reason); 778 | 779 | ZVAL_LONG(z_comp_code, (long) comp_code); 780 | ZVAL_LONG(z_reason, (long) reason); 781 | } 782 | /* }}} */ 783 | 784 | /* {{{ proto void mqseries_back(resource hconn, int &compcode, int &reason) 785 | 786 | The mqseries_back call indicates to the queue manager that all the message gets and puts that have occurred since the last syncpoint are to be backed out. 787 | 788 | PHP sample: 789 | 790 | mqseries_back($conn, $compCode, $reason); 791 | 792 | MQ call: 793 | 794 | MQBACK (Hconn, &CompCode, &Reason); 795 | 796 | MQHCONN Hconn; -- Connection handle 797 | MQLONG CompCode; -- Completion code 798 | MQLONG Reason; -- Reason code qualifying CompCode 799 | */ 800 | PHP_FUNCTION(mqseries_back) 801 | { 802 | MQLONG comp_code; 803 | MQLONG reason; 804 | 805 | mqseries_descriptor *mqdesc; 806 | zval *z_mqdesc, *z_comp_code, *z_reason; 807 | 808 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz/z/", &z_mqdesc, &z_comp_code, &z_reason) == FAILURE) { 809 | return; 810 | } 811 | 812 | if ((mqdesc = (mqseries_descriptor *) zend_fetch_resource(Z_RES_P(z_mqdesc), PHP_MQSERIES_DESCRIPTOR_RES_NAME, le_mqseries_conn)) == NULL) { 813 | RETURN_FALSE; 814 | } 815 | 816 | MQBACK(mqdesc->conn, &comp_code, &reason); 817 | 818 | ZVAL_LONG(z_comp_code, (long) comp_code); 819 | ZVAL_LONG(z_reason, (long) reason); 820 | } 821 | /* }}} */ 822 | 823 | /* {{{ proto void mqseries_close(resoure hconn, resource &hobj, int options, int &compCode, int &reason) 824 | 825 | The mqseries_close call relinquishes access to an object, and is the inverse of the mqseries_open and mqseries_sub calls. 826 | 827 | PHP sample: 828 | 829 | mqseries_close($conn, $obj, MQSERIES_MQCO_NONE, $compCode, $reason); 830 | 831 | MQ call: 832 | 833 | MQCLOSE (Hconn, &Hobj, Options, &CompCode, &Reason); 834 | 835 | MQHCONN Hconn; -- Connection handle 836 | MQHOBJ Hobj; -- Object handle 837 | MQLONG Options; -- Options that control the action of MQCLOSE 838 | MQLONG CompCode; -- Completion code 839 | MQLONG Reason; -- Reason code qualifying CompCode 840 | */ 841 | PHP_FUNCTION(mqseries_close) 842 | { 843 | MQLONG comp_code; 844 | MQLONG reason; 845 | zend_long close_options; 846 | 847 | mqseries_obj *mqobj; 848 | mqseries_descriptor *mqdesc; 849 | zval *z_mqdesc, *z_mqobj, *z_comp_code, *z_reason; 850 | 851 | zend_output_debug_string(1, "%s", "MQClose - start"); 852 | 853 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "rrlz/z/", &z_mqdesc, &z_mqobj, &close_options, &z_comp_code, &z_reason) == FAILURE) { 854 | return; 855 | } 856 | 857 | if ((mqdesc = (mqseries_descriptor *) zend_fetch_resource(Z_RES_P(z_mqdesc), PHP_MQSERIES_DESCRIPTOR_RES_NAME, le_mqseries_conn)) == NULL) { 858 | RETURN_FALSE; 859 | } 860 | if ((mqobj = (mqseries_obj *) zend_fetch_resource(Z_RES_P(z_mqobj), PHP_MQSERIES_OBJ_RES_NAME, le_mqseries_obj)) == NULL) { 861 | RETURN_FALSE; 862 | } 863 | 864 | MQCLOSE(mqdesc->conn, &mqobj->obj, (MQLONG) close_options, &comp_code, &reason); 865 | 866 | ZVAL_LONG(z_comp_code, (long) comp_code); 867 | ZVAL_LONG(z_reason, (long) reason); 868 | 869 | zend_list_close(Z_RES_P(z_mqobj)); 870 | zend_output_debug_string(1, "%s", "MQClose - end"); 871 | } 872 | /* }}} */ 873 | 874 | /* {{{ internal used nethod to close resources void _mqseries_close() */ 875 | static void _mqseries_close(zend_resource *rsrc) 876 | { 877 | MQLONG comp_code; /* Completion code */ 878 | MQLONG reason; /* Qualifying reason */ 879 | mqseries_obj *mqobj = (mqseries_obj *)rsrc->ptr; 880 | 881 | if (mqobj->obj != MQHO_UNUSABLE_HOBJ) { /* Already closed */ 882 | if (*mqobj->conn != MQHC_UNUSABLE_HCONN) { /* Already disconeccted */ 883 | /* Should not be posible but just in case */ 884 | 885 | MQCLOSE(*mqobj->conn, &mqobj->obj, MQCO_NONE, &comp_code, &reason); 886 | 887 | if ((comp_code != MQCC_OK) || (reason != MQRC_NONE && reason)) { 888 | switch(reason) { 889 | case MQRC_CONNECTION_BROKEN: 890 | case MQRC_HCONN_ERROR: 891 | case MQRC_HOBJ_ERROR: 892 | break; 893 | 894 | default: 895 | #if defined(MQ_64_BIT) 896 | zend_error(E_WARNING, "_mqseries_close Error %d %d\n", comp_code, reason); 897 | #else 898 | zend_error(E_WARNING, "_mqseries_close Error %ld %ld\n", comp_code, reason); 899 | #endif 900 | } 901 | } 902 | } 903 | } 904 | 905 | efree(mqobj); 906 | } 907 | /* }}} */ 908 | 909 | /* {{{ proto void mqseries_disc(resource &hconn, int &compCode, int &reason) 910 | 911 | The mqseries_disc call breaks the connection between the queue manager and the application program, and is the inverse of the mqseries_conn or mqseries_connx call. 912 | 913 | PHP sample: 914 | 915 | mqseries_disc($conn, $compCode, $reason); 916 | if ($compCode !== MQSERIES_MQCC_OK) { 917 | printf("CompCode:%d Reason:%d Text:%s\n", $compCode, $reason, mqseries_strerror($reason)); 918 | } 919 | 920 | MQ call: 921 | 922 | MQDISC (&Hconn, &CompCode, &Reason); 923 | 924 | MQHCONN Hconn; -- Connection handle 925 | MQLONG CompCode; -- Completion code 926 | MQLONG Reason; -- Reason code qualifying CompCode 927 | Parent topic: Language invocations for MQDISC 928 | */ 929 | PHP_FUNCTION(mqseries_disc) 930 | { 931 | MQLONG comp_code; /* Completion code */ 932 | MQLONG reason; /* Qualifying reason */ 933 | 934 | mqseries_descriptor *mqdesc; 935 | zval *z_mqdesc, *z_comp_code, *z_reason; 936 | 937 | zend_output_debug_string(1, "%s", "MQDisc - start"); 938 | 939 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz/z/", &z_mqdesc, &z_comp_code, &z_reason) == FAILURE) { 940 | return; 941 | } 942 | 943 | if ((mqdesc = (mqseries_descriptor *) zend_fetch_resource(Z_RES_P(z_mqdesc), PHP_MQSERIES_DESCRIPTOR_RES_NAME, le_mqseries_conn)) == NULL) { 944 | RETURN_FALSE; 945 | } 946 | 947 | MQDISC(&mqdesc->conn, &comp_code, &reason); 948 | 949 | ZVAL_LONG(z_comp_code, (long) comp_code); 950 | ZVAL_LONG(z_reason, (long) reason); 951 | 952 | zend_list_close(Z_RES_P(z_mqdesc)); 953 | zend_output_debug_string(1, "%s", "MQDisc - end"); 954 | } 955 | /* }}} */ 956 | 957 | /* {{{ internal used disconnect method _mqseries_disc() */ 958 | static void _mqseries_disc(zend_resource *rsrc) 959 | { 960 | MQLONG comp_code; /* Completion code */ 961 | MQLONG reason; /* Qualifying reason */ 962 | 963 | mqseries_descriptor *mqdesc = (mqseries_descriptor *)rsrc->ptr; 964 | 965 | if (mqdesc->conn != MQHC_UNUSABLE_HCONN) { 966 | 967 | MQDISC(&mqdesc->conn, &comp_code, &reason); 968 | 969 | if ((comp_code != MQCC_OK) || (reason != MQRC_NONE)) { 970 | switch(reason) { 971 | case MQRC_CONNECTION_BROKEN: 972 | case MQRC_HCONN_ERROR: 973 | break; 974 | 975 | default: 976 | #if defined(MQ_64_BIT) 977 | zend_error(E_WARNING, "_mqseries_disc Error %d %d\n", comp_code, reason); 978 | #else 979 | zend_error(E_WARNING, "_mqseries_disc Error %ld %ld\n", comp_code, reason); 980 | #endif 981 | } 982 | } 983 | } 984 | 985 | efree(mqdesc); 986 | } 987 | /* }}} */ 988 | 989 | /* {{{ proto string mqseries_strerror(int reason) 990 | 991 | Returns the detailed error text for the given reason code. 992 | 993 | PHP sample: 994 | 995 | echo mqseries_strerror($reason); 996 | */ 997 | PHP_FUNCTION(mqseries_strerror) 998 | { 999 | char *text; 1000 | zend_long reason_code; 1001 | 1002 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &reason_code) == FAILURE) { 1003 | return; 1004 | } 1005 | 1006 | RETVAL_NULL(); 1007 | 1008 | if ((text = zend_hash_index_find_ptr(ht_reason_texts, reason_code)) != NULL) { 1009 | RETVAL_STRING(text); 1010 | } 1011 | } 1012 | /* }}} */ 1013 | 1014 | /* {{{ proto void mqseries_put1(resource hconn, array &objDesc, array &msgDesc, array &putMsgOpts, string buffer, int &compCode, int &reason) 1015 | 1016 | The mqseries_put1 call puts one message on a queue, or distribution list, or to a topic. 1017 | 1018 | PHP sample: 1019 | 1020 | 1021 | 1022 | MQ call: 1023 | 1024 | MQPUT1 (Hconn, &ObjDesc, &MsgDesc, &PutMsgOpts, BufferLength, Buffer, &CompCode, &Reason); 1025 | 1026 | MQHCONN Hconn; -- Connection handle 1027 | MQOD ObjDesc; -- Object descriptor 1028 | MQMD MsgDesc; -- Message descriptor 1029 | MQPMO PutMsgOpts; -- Options that control the action of MQPUT1 1030 | MQLONG BufferLength; -- Length of the message in Buffer 1031 | MQBYTE Buffer[n]; -- Message data 1032 | MQLONG CompCode; -- Completion code 1033 | MQLONG Reason; -- Reason code qualifying CompCode 1034 | */ 1035 | PHP_FUNCTION(mqseries_put1) 1036 | { 1037 | mqseries_descriptor *mqdesc; 1038 | zval *z_mqdesc, *z_msg_desc, *z_put_msg_opts, *z_obj_desc, *z_comp_code, *z_reason; 1039 | char *msg; 1040 | zend_long msg_len; 1041 | MQMD msg_desc = {MQMD_DEFAULT}; /* Message descriptor */ 1042 | MQOD obj_desc = {MQOD_DEFAULT}; /* Object descriptor */ 1043 | MQPMO put_msg_opts = {MQPMO_DEFAULT}; /* Options which control the MQPUT call */ 1044 | MQLONG comp_code; 1045 | MQLONG reason; 1046 | 1047 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "ra/a/a/sz/z/", &z_mqdesc, &z_obj_desc, &z_msg_desc, &z_put_msg_opts, &msg, &msg_len, &z_comp_code, &z_reason) == FAILURE) { 1048 | return; 1049 | } 1050 | 1051 | if ((mqdesc = (mqseries_descriptor *) zend_fetch_resource(Z_RES_P(z_mqdesc), PHP_MQSERIES_DESCRIPTOR_RES_NAME, le_mqseries_conn)) == NULL) { 1052 | RETURN_FALSE; 1053 | } 1054 | 1055 | _mqseries_set_mqod_from_array(z_obj_desc, &obj_desc); 1056 | _mqseries_set_mqmd_from_array(z_msg_desc, &msg_desc); 1057 | _mqseries_set_mqpmo_from_array(z_put_msg_opts, &put_msg_opts); 1058 | 1059 | MQPUT1(mqdesc->conn, &obj_desc, &msg_desc, &put_msg_opts, (MQLONG) msg_len, msg, &comp_code, &reason); 1060 | 1061 | ZVAL_LONG(z_comp_code, (long) comp_code); 1062 | ZVAL_LONG(z_reason, (long) reason); 1063 | 1064 | _mqseries_set_array_from_mqod(z_obj_desc, &obj_desc); 1065 | _mqseries_set_array_from_mqmd(z_msg_desc, &msg_desc); 1066 | _mqseries_set_array_from_mqpmo(z_put_msg_opts, &put_msg_opts); 1067 | } 1068 | /* }}} */ 1069 | 1070 | /* {{{ proto void mqseries_inq(resource hconn, resource hobj, int selectorCount, array selectors, int intAttrCount, array &initAttrs, int charAttrLength, string &charAttrs, int &compCode, int &reason) 1071 | 1072 | The mqseries_inc call returns an array of integers and a set of character strings containing the attributes of an object. 1073 | 1074 | PHP Sample: 1075 | 1076 | mqseries_inq($conn, $obj, 1, array(MQSERIES_MQCA_Q_MGR_NAME), 0, $int_attr, 48, $char_attr, $comp_code, $reason); 1077 | 1078 | MQ call: 1079 | 1080 | MQINQ (Hconn, Hobj, SelectorCount, Selectors, IntAttrCount, IntAttrs, CharAttrLength, CharAttrs, &CompCode, &Reason); 1081 | 1082 | MQHCONN Hconn; -- Connection handle 1083 | MQHOBJ Hobj; -- Object handle 1084 | MQLONG SelectorCount; -- Count of selectors 1085 | MQLONG Selectors[n]; -- Array of attribute selectors 1086 | MQLONG IntAttrCount; -- Count of integer attributes 1087 | MQLONG IntAttrs[n]; -- Array of integer attributes 1088 | MQLONG CharAttrLength; -- Length of character attributes buffer 1089 | MQCHAR CharAttrs[n]; -- Character attributes 1090 | MQLONG CompCode; -- Completion code 1091 | MQLONG Reason; -- Reason code qualifying CompCode 1092 | */ 1093 | PHP_FUNCTION(mqseries_inq) 1094 | { 1095 | mqseries_descriptor *mqdesc; 1096 | mqseries_obj *mqobj; 1097 | zval *option_val; 1098 | zval *z_mqdesc, *z_mqobj, *z_selectors, *z_intAttrs, *z_charAttrs, *z_comp_code, *z_reason; 1099 | HashPosition pos; 1100 | long current=0; 1101 | zend_long selectorCount, intAttrLength, i, charAttrLength; 1102 | MQLONG *selectors; 1103 | MQCHAR *charAttrs = NULL; 1104 | MQLONG *intAttrs = NULL; 1105 | MQLONG comp_code; 1106 | MQLONG reason; 1107 | 1108 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "rrlalz/lz/z/z/", &z_mqdesc, &z_mqobj, &selectorCount, &z_selectors, &intAttrLength, &z_intAttrs, &charAttrLength, &z_charAttrs, &z_comp_code, &z_reason) == FAILURE) { 1109 | return; 1110 | } 1111 | 1112 | if ((mqdesc = (mqseries_descriptor *) zend_fetch_resource(Z_RES_P(z_mqdesc), PHP_MQSERIES_DESCRIPTOR_RES_NAME, le_mqseries_conn)) == NULL) { 1113 | RETURN_FALSE; 1114 | } 1115 | if ((mqobj = (mqseries_obj *) zend_fetch_resource(Z_RES_P(z_mqobj), PHP_MQSERIES_OBJ_RES_NAME, le_mqseries_obj)) == NULL) { 1116 | RETURN_FALSE; 1117 | } 1118 | 1119 | selectors = (MQLONG *) emalloc(selectorCount * sizeof(MQLONG)); 1120 | 1121 | ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_selectors), option_val) { 1122 | if (current < selectorCount) { 1123 | selectors[current++] = Z_LVAL_P(option_val); 1124 | } 1125 | } ZEND_HASH_FOREACH_END(); 1126 | 1127 | if (charAttrLength > 0) { /* Are charAttr requested */ 1128 | charAttrs = (MQCHAR *) emalloc(charAttrLength+1); 1129 | memset(charAttrs, 0, charAttrLength+1); // set to zero 1130 | } 1131 | if (intAttrLength > 0) { /* Are intAttr requested */ 1132 | intAttrs = (MQLONG *) emalloc(intAttrLength*sizeof(MQLONG)); 1133 | } 1134 | 1135 | MQINQ(mqdesc->conn, mqobj->obj, (MQLONG) selectorCount, selectors, (MQLONG) intAttrLength, intAttrs, (MQLONG) charAttrLength, charAttrs, &comp_code, &reason); 1136 | 1137 | ZVAL_LONG(z_comp_code, (long) comp_code); 1138 | ZVAL_LONG(z_reason, (long) reason); 1139 | 1140 | if (comp_code == MQCC_OK) { 1141 | if (charAttrLength > 0) { /* set only when charAttrs where requested */ 1142 | ZVAL_STRING(z_charAttrs, charAttrs); 1143 | } 1144 | if (intAttrLength > 0) { /* set only when intAttrs where requested */ 1145 | /* create an indexed array of long values */ 1146 | zval_dtor(z_intAttrs); 1147 | array_init(z_intAttrs); 1148 | 1149 | for (i = 0; i < intAttrLength; i++) { 1150 | add_index_long(z_intAttrs, i, (long) intAttrs[i]); 1151 | } 1152 | } 1153 | } 1154 | 1155 | if (charAttrLength > 0) { /* set only when charAttrs where requested */ 1156 | efree(charAttrs); 1157 | } 1158 | if (intAttrLength > 0) { /* set only when charAttrs where requested */ 1159 | efree(intAttrs); 1160 | } 1161 | efree(selectors); 1162 | } 1163 | /* }}} */ 1164 | 1165 | /* {{{ proto void mqseries_set(resource hconn, resource hobj, int selectorCount, array selectors, int intAttrCount, array intAttrs, int charAttrLength, array &charAttrs, int &compCode, int &reason) 1166 | 1167 | Use the mqseries_set call to change the attributes of an object represented by a handle. The object must be a queue. 1168 | 1169 | PHP sample: 1170 | 1171 | MQ call: 1172 | 1173 | MQSET (Hconn, Hobj, SelectorCount, Selectors, IntAttrCount, IntAttrs, CharAttrLength, CharAttrs, &CompCode, &Reason); 1174 | 1175 | MQHCONN Hconn; -- Connection handle 1176 | MQHOBJ Hobj; -- Object handle 1177 | MQLONG SelectorCount; -- Count of selectors 1178 | MQLONG Selectors[n]; -- Array of attribute selectors 1179 | MQLONG IntAttrCount; -- Count of integer attributes 1180 | MQLONG IntAttrs[n]; -- Array of integer attributes 1181 | MQLONG CharAttrLength; -- Length of character attributes buffer 1182 | MQCHAR CharAttrs[n]; -- Character attributes 1183 | MQLONG CompCode; -- Completion code 1184 | MQLONG Reason; -- Reason code qualifying CompCode 1185 | */ 1186 | PHP_FUNCTION(mqseries_set) 1187 | { 1188 | mqseries_descriptor *mqdesc; 1189 | mqseries_obj *mqobj; 1190 | zval *option_val; 1191 | zval *z_mqdesc, *z_mqobj, *z_selectors, *z_intAttrs, *z_charAttrs, *z_comp_code, *z_reason; 1192 | HashPosition pos; 1193 | zend_long selectorCount, intAttrLength, charAttrLength; 1194 | MQLONG current=0, *selectors; 1195 | MQCHAR *charAttrs = NULL; 1196 | MQLONG *intAttrs = NULL; 1197 | MQLONG comp_code; 1198 | MQLONG reason; 1199 | 1200 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "rrlalalaz/z/", &z_mqdesc, &z_mqobj, &selectorCount, &z_selectors, &intAttrLength, &z_intAttrs, &charAttrLength, &z_charAttrs, &z_comp_code, &z_reason) == FAILURE) { 1201 | return; 1202 | } 1203 | 1204 | if ((mqdesc = (mqseries_descriptor *) zend_fetch_resource(Z_RES_P(z_mqdesc), PHP_MQSERIES_DESCRIPTOR_RES_NAME, le_mqseries_conn)) == NULL) { 1205 | RETURN_FALSE; 1206 | } 1207 | if ((mqobj = (mqseries_obj *) zend_fetch_resource(Z_RES_P(z_mqobj), PHP_MQSERIES_OBJ_RES_NAME, le_mqseries_obj)) == NULL) { 1208 | RETURN_FALSE; 1209 | } 1210 | 1211 | selectors = (MQLONG *) emalloc(selectorCount * sizeof(MQLONG)); 1212 | 1213 | current = 0; 1214 | 1215 | ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_selectors), option_val) { 1216 | if (current < selectorCount) { 1217 | selectors[current++] = Z_LVAL_P(option_val); 1218 | } 1219 | } ZEND_HASH_FOREACH_END(); 1220 | 1221 | if (intAttrLength > 0) { /* Are intAttr requested */ 1222 | intAttrs = (MQLONG *) emalloc(intAttrLength*sizeof(MQLONG)); 1223 | current = 0; 1224 | 1225 | ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_intAttrs), option_val) { 1226 | if (current < intAttrLength) { 1227 | intAttrs[current++] = (MQLONG) Z_LVAL_P(option_val); 1228 | } 1229 | } ZEND_HASH_FOREACH_END(); 1230 | } 1231 | 1232 | if (charAttrLength > 0) { /* Are charAttr requested */ 1233 | charAttrs = (MQCHAR *) emalloc(charAttrLength+1); 1234 | current = 0; 1235 | 1236 | ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_charAttrs), option_val) { 1237 | if (current < charAttrLength) { 1238 | charAttrs[current++] = Z_LVAL_P(option_val); /* hoe helen we char uit een array? */ 1239 | } 1240 | } ZEND_HASH_FOREACH_END(); 1241 | } 1242 | 1243 | MQSET(mqdesc->conn, mqobj->obj, (MQLONG) selectorCount, selectors, (MQLONG) intAttrLength, intAttrs, (MQLONG) charAttrLength, charAttrs, &comp_code, &reason); 1244 | 1245 | ZVAL_LONG(z_comp_code, (long) comp_code); 1246 | ZVAL_LONG(z_reason, (long) reason); 1247 | 1248 | if (charAttrLength > 0) { /* set only when charAttrs where requested */ 1249 | efree(charAttrs); 1250 | } 1251 | if (intAttrLength > 0) { /* set only when charAttrs where requested */ 1252 | efree(intAttrs); 1253 | } 1254 | efree(selectors); 1255 | } 1256 | /* }}} */ 1257 | 1258 | /* {{{ proto string mqseries_bytes_val(resource bytes) 1259 | 1260 | Returns the string of bytes contained in the mqseries bytes resource 1261 | 1262 | PHP sample: 1263 | 1264 | mqseries_bytes_val($res); 1265 | 1266 | */ 1267 | PHP_FUNCTION(mqseries_bytes_val) 1268 | { 1269 | zval *z_bytes; 1270 | mqseries_bytes *bytes; 1271 | 1272 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &z_bytes) == FAILURE) { 1273 | return; 1274 | } 1275 | 1276 | if ((bytes = (mqseries_bytes *) zend_fetch_resource(Z_RES_P(z_bytes), PHP_MQSERIES_BYTES_RES_NAME, le_mqseries_bytes)) == NULL) { 1277 | RETURN_FALSE; 1278 | } 1279 | 1280 | if (bytes && bytes->bytes) { 1281 | RETVAL_STRINGL((char *) bytes->bytes, 24); /* MQBYTE24 */ 1282 | } else { 1283 | RETVAL_NULL(); 1284 | } 1285 | } 1286 | /* }}} */ 1287 | 1288 | #ifdef HAVE_MQSERIESLIB_V7 1289 | 1290 | /* {{{ proto void mqseries_sub(resource hconn, array &subDesc, resource &hobj, resource &hsub, int &compCode, int &reason) 1291 | 1292 | The mqseries_sub call registers the applications subscription to a particular topic. 1293 | 1294 | PHP sample: 1295 | 1296 | mqseries_sub($connection, $subDesc, $queue, $sub, $compCode, $reason); 1297 | if ($compCode !== MQSERIES_MQCC_OK) { 1298 | printf("CompCode:%d Reason:%d Text:%s\n", $compCode, $reason, mqseries_strerror($reason)); 1299 | } 1300 | 1301 | MQ call: 1302 | 1303 | MQSUB (Hconn, &SubDesc, &Hobj, &Hsub, &CompCode, &Reason); 1304 | 1305 | MQHCONN Hconn; -- Connection handle 1306 | MQSD SubDesc; -- Subscription descriptor 1307 | MQHOBJ Hobj; -- Object handle 1308 | MQHOBJ Hsub; -- Subscription handle 1309 | MQLONG CompCode; -- Completion code 1310 | MQLONG Reason; -- Reason code qualifying CompCode 1311 | */ 1312 | PHP_FUNCTION(mqseries_sub) 1313 | { 1314 | mqseries_descriptor *mqdesc; 1315 | mqseries_obj *mqobj = NULL, *mqsub; 1316 | zval *z_mqdesc, 1317 | *z_sub_desc, 1318 | *z_obj, 1319 | *z_sub, 1320 | *z_comp_code, 1321 | *z_reason; 1322 | 1323 | MQSD sub_desc = {MQSD_DEFAULT}; 1324 | MQLONG comp_code; /* Completion code */ 1325 | MQLONG reason; /* Qualifying reason */ 1326 | 1327 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "ra/z/zz/z/", &z_mqdesc, &z_sub_desc, &z_obj, &z_sub, &z_comp_code, &z_reason) == FAILURE) { 1328 | return; 1329 | } 1330 | 1331 | if (Z_TYPE_P(z_obj) == IS_RESOURCE) { 1332 | if ((mqobj = (mqseries_obj *) zend_fetch_resource(Z_RES_P(z_obj), PHP_MQSERIES_OBJ_RES_NAME, le_mqseries_obj)) == NULL) { 1333 | RETURN_FALSE; 1334 | } 1335 | } else { 1336 | mqobj = (mqseries_obj *) emalloc(sizeof(mqseries_obj)); 1337 | } 1338 | 1339 | if ((mqdesc = (mqseries_descriptor *) zend_fetch_resource(Z_RES_P(z_mqdesc), PHP_MQSERIES_DESCRIPTOR_RES_NAME, le_mqseries_conn)) == NULL) { 1340 | RETURN_FALSE; 1341 | } 1342 | 1343 | _mqseries_set_mqsd_from_array(z_sub_desc, &sub_desc); 1344 | 1345 | mqsub = (mqseries_obj *) emalloc(sizeof(mqseries_obj)); 1346 | 1347 | MQSUB(mqdesc->conn, &sub_desc, &mqobj->obj, &mqsub->obj, &comp_code, &reason); 1348 | 1349 | ZVAL_LONG(z_comp_code, (long) comp_code); 1350 | ZVAL_LONG(z_reason, (long) reason); 1351 | 1352 | _mqseries_set_array_from_mqsd(z_sub_desc, &sub_desc); 1353 | if (comp_code == MQCC_OK) { 1354 | if (Z_TYPE_P(z_obj) != IS_RESOURCE) { 1355 | zval_dtor(z_obj); 1356 | mqobj->conn = &mqdesc->conn; 1357 | ZVAL_RES(z_obj, zend_register_resource(mqobj, le_mqseries_obj)); 1358 | mqobj->id = Z_RES_P(z_obj)->handle; 1359 | } 1360 | 1361 | zval_dtor(z_sub); 1362 | mqsub->conn = &mqdesc->conn; 1363 | ZVAL_RES(z_sub, zend_register_resource(mqsub, le_mqseries_obj)); 1364 | mqsub->id = Z_RES_P(z_sub)->handle; 1365 | } else { 1366 | /* So we don't register the ref. But we already allocated some memory lets free that */ 1367 | if (Z_TYPE_P(z_obj) != IS_RESOURCE) { 1368 | efree(mqobj); 1369 | } 1370 | efree(mqsub); 1371 | } 1372 | } 1373 | /* }}} */ 1374 | 1375 | /* {{{ proto void mqseries_stat(resource hconn, int type, array &status, int &compCode, int &reason) 1376 | 1377 | Use the mqseries_stat call to retrieve status information. The type of status information returned is determined by the Type value specified on the call. 1378 | 1379 | PHP sample: 1380 | 1381 | $status = array(); 1382 | mqseries_stat($conn, MQSERIES_MQSTAT_TYPE_RECONNECTION, $status, $compCode, $reason); 1383 | if ($compCode !== MQSERIES_MQCC_OK) { 1384 | printf("CompCode:%d Reason:%d Text:%s\n", $compCode, $reason, mqseries_strerror($reason)); 1385 | } 1386 | 1387 | MQ call: 1388 | 1389 | MQSTAT (Hconn, StatType, &Stat, &CompCode, &Reason); 1390 | 1391 | MQHCONN Hconn; -- Connection Handle 1392 | MQLONG StatType; -- Status type 1393 | MQSTS Stat; -- Status information structure 1394 | MQLONG CompCode; -- Completion code 1395 | MQLONG Reason; -- Reason code qualifying CompCode 1396 | */ 1397 | PHP_FUNCTION(mqseries_stat) 1398 | { 1399 | mqseries_descriptor *mqdesc; 1400 | zend_long type; 1401 | MQLONG comp_code, reason; 1402 | zval *z_mqdesc, 1403 | *z_status, 1404 | *z_comp_code, 1405 | *z_reason; 1406 | 1407 | MQSTS status = {MQSTS_DEFAULT}; 1408 | 1409 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlaz/z/", &z_mqdesc, &type, &z_status, &z_comp_code, &z_reason) == FAILURE) { 1410 | return; 1411 | } 1412 | 1413 | if ((mqdesc = (mqseries_descriptor *) zend_fetch_resource(Z_RES_P(z_mqdesc), PHP_MQSERIES_DESCRIPTOR_RES_NAME, le_mqseries_conn)) == NULL) { 1414 | RETURN_FALSE; 1415 | } 1416 | 1417 | _mqseries_set_mqsts_from_array(z_status, &status); 1418 | 1419 | MQSTAT(mqdesc->conn, (MQLONG) type, &status, &comp_code, &reason); 1420 | 1421 | ZVAL_LONG(z_comp_code, (long) comp_code); 1422 | ZVAL_LONG(z_reason, (long) reason); 1423 | 1424 | _mqseries_set_array_from_mqsts(z_status, &status); 1425 | } 1426 | /* }}} */ 1427 | 1428 | #endif /* HAVE_MQSERIESLIB_V7 */ 1429 | 1430 | /* {{{ _mqseries_bytes 1431 | * frees memomory previuosly allocated 1432 | */ 1433 | void _mqseries_bytes(zend_resource *rsrc) 1434 | { 1435 | efree(((mqseries_bytes *)rsrc->ptr)->bytes); 1436 | efree(rsrc->ptr); 1437 | } 1438 | /* }}} */ 1439 | 1440 | /* 1441 | * Local variables: 1442 | * tab-width: 4 1443 | * c-basic-offset: 4 1444 | * End: 1445 | * vim600: noet sw=4 ts=4 fdm=marker 1446 | * vim<600: noet sw=4 ts=4 1447 | */ 1448 | --------------------------------------------------------------------------------