Commit 3ea87533e5e52774bdb67b49ec421bf3bc79c1d9
1 parent
8c9dbdb4
Exists in
master
and in
5 other branches
Incluindo método "action" na API PHP
Showing
4 changed files
with
29 additions
and
0 deletions
Show diff stats
src/php/main.cc
| @@ -65,6 +65,8 @@ zend_function_entry tn3270_methods[] = | @@ -65,6 +65,8 @@ zend_function_entry tn3270_methods[] = | ||
| 65 | PHP_ME( tn3270, getisprotected, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) | 65 | PHP_ME( tn3270, getisprotected, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) |
| 66 | PHP_ME( tn3270, getisprotectedat, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) | 66 | PHP_ME( tn3270, getisprotectedat, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) |
| 67 | 67 | ||
| 68 | + PHP_ME( tn3270, action, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) | ||
| 69 | + | ||
| 68 | {NULL, NULL, NULL} | 70 | {NULL, NULL, NULL} |
| 69 | }; | 71 | }; |
| 70 | 72 |
src/php/misc.cc
| @@ -115,3 +115,25 @@ PHP_METHOD(tn3270, iterate) | @@ -115,3 +115,25 @@ PHP_METHOD(tn3270, iterate) | ||
| 115 | 115 | ||
| 116 | RETURN_LONG(obj->hSession->iterate(wait)); | 116 | RETURN_LONG(obj->hSession->iterate(wait)); |
| 117 | } | 117 | } |
| 118 | + | ||
| 119 | +PHP_METHOD(tn3270, action) | ||
| 120 | +{ | ||
| 121 | + | ||
| 122 | + tn3270_object * obj = (tn3270_object *) zend_object_store_get_object(getThis() TSRMLS_CC); | ||
| 123 | + | ||
| 124 | + const char * text; | ||
| 125 | + int szText; | ||
| 126 | + | ||
| 127 | + if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &text, &szText) == FAILURE) | ||
| 128 | + RETURN_NULL(); | ||
| 129 | + | ||
| 130 | + if(!szText) | ||
| 131 | + RETURN_NULL(); | ||
| 132 | + | ||
| 133 | + char buffer[szText+1]; | ||
| 134 | + memcpy(buffer,text,szText); | ||
| 135 | + buffer[szText] = 0; | ||
| 136 | + | ||
| 137 | + RETURN_LONG(obj->hSession->action(buffer)); | ||
| 138 | + | ||
| 139 | +} |
src/php/php3270.h.in
| @@ -67,6 +67,8 @@ | @@ -67,6 +67,8 @@ | ||
| 67 | PHP_METHOD(tn3270,getisprotected); | 67 | PHP_METHOD(tn3270,getisprotected); |
| 68 | PHP_METHOD(tn3270,getisprotectedat); | 68 | PHP_METHOD(tn3270,getisprotectedat); |
| 69 | 69 | ||
| 70 | + PHP_METHOD(tn3270,action); | ||
| 71 | + | ||
| 70 | #undef PACKAGE_NAME | 72 | #undef PACKAGE_NAME |
| 71 | #undef PACKAGE_VERSION | 73 | #undef PACKAGE_VERSION |
| 72 | #undef HAVE_MALLOC_H | 74 | #undef HAVE_MALLOC_H |
src/php/sample.php
| @@ -19,6 +19,9 @@ | @@ -19,6 +19,9 @@ | ||
| 19 | $rc = $host->getisprotectedat(20,39); | 19 | $rc = $host->getisprotectedat(20,39); |
| 20 | print("GetIsprotectedAt(20,39) saiu com \"" . $rc . "\"\n"); | 20 | print("GetIsprotectedAt(20,39) saiu com \"" . $rc . "\"\n"); |
| 21 | 21 | ||
| 22 | + $rc = $host->action("clear"); | ||
| 23 | + print("Action(\"clear\") saiu com \"" . $rc . "\"\n"); | ||
| 24 | + | ||
| 22 | $rc = $host->disconnect(); | 25 | $rc = $host->disconnect(); |
| 23 | print("disconnect() exits with rc=" . $rc . "\n"); | 26 | print("disconnect() exits with rc=" . $rc . "\n"); |
| 24 | 27 |