From 3ea87533e5e52774bdb67b49ec421bf3bc79c1d9 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Mon, 24 Aug 2015 19:24:31 +0000 Subject: [PATCH] Incluindo método "action" na API PHP --- src/php/main.cc | 2 ++ src/php/misc.cc | 22 ++++++++++++++++++++++ src/php/php3270.h.in | 2 ++ src/php/sample.php | 3 +++ 4 files changed, 29 insertions(+), 0 deletions(-) diff --git a/src/php/main.cc b/src/php/main.cc index d245a23..a81444f 100644 --- a/src/php/main.cc +++ b/src/php/main.cc @@ -65,6 +65,8 @@ zend_function_entry tn3270_methods[] = PHP_ME( tn3270, getisprotected, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) PHP_ME( tn3270, getisprotectedat, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) + PHP_ME( tn3270, action, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) + {NULL, NULL, NULL} }; diff --git a/src/php/misc.cc b/src/php/misc.cc index 3cfff65..2a2fbe3 100644 --- a/src/php/misc.cc +++ b/src/php/misc.cc @@ -115,3 +115,25 @@ PHP_METHOD(tn3270, iterate) RETURN_LONG(obj->hSession->iterate(wait)); } + +PHP_METHOD(tn3270, action) +{ + + tn3270_object * obj = (tn3270_object *) zend_object_store_get_object(getThis() TSRMLS_CC); + + const char * text; + int szText; + + if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &text, &szText) == FAILURE) + RETURN_NULL(); + + if(!szText) + RETURN_NULL(); + + char buffer[szText+1]; + memcpy(buffer,text,szText); + buffer[szText] = 0; + + RETURN_LONG(obj->hSession->action(buffer)); + +} diff --git a/src/php/php3270.h.in b/src/php/php3270.h.in index 31c8d83..75d138b 100644 --- a/src/php/php3270.h.in +++ b/src/php/php3270.h.in @@ -67,6 +67,8 @@ PHP_METHOD(tn3270,getisprotected); PHP_METHOD(tn3270,getisprotectedat); + PHP_METHOD(tn3270,action); + #undef PACKAGE_NAME #undef PACKAGE_VERSION #undef HAVE_MALLOC_H diff --git a/src/php/sample.php b/src/php/sample.php index 6328743..734e5a4 100644 --- a/src/php/sample.php +++ b/src/php/sample.php @@ -19,6 +19,9 @@ $rc = $host->getisprotectedat(20,39); print("GetIsprotectedAt(20,39) saiu com \"" . $rc . "\"\n"); + $rc = $host->action("clear"); + print("Action(\"clear\") saiu com \"" . $rc . "\"\n"); + $rc = $host->disconnect(); print("disconnect() exits with rc=" . $rc . "\n"); -- libgit2 0.21.2