Commit 792c9aabcf90529fd0dce297ac6c01ae181fd98a
1 parent
edea2a31
Exists in
master
and in
5 other branches
Incluindo métodos connect/disconnect
Showing
4 changed files
with
49 additions
and
0 deletions
Show diff stats
src/php/init.cc
src/php/main.cc
| ... | ... | @@ -43,6 +43,8 @@ static zend_object_handlers tn3270_object_handlers; |
| 43 | 43 | zend_function_entry tn3270_methods[] = |
| 44 | 44 | { |
| 45 | 45 | PHP_ME( tn3270, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) |
| 46 | + PHP_ME( tn3270, connect, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) | |
| 47 | + PHP_ME( tn3270, disconnect, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) | |
| 46 | 48 | |
| 47 | 49 | |
| 48 | 50 | {NULL, NULL, NULL} |
| ... | ... | @@ -121,3 +123,34 @@ extern "C" |
| 121 | 123 | } |
| 122 | 124 | // #endif |
| 123 | 125 | |
| 126 | +PHP_METHOD(tn3270, connect) | |
| 127 | +{ | |
| 128 | + const char * host; | |
| 129 | + int szHost; | |
| 130 | + zend_bool wait = 0; | |
| 131 | + int rc = 0; | |
| 132 | + tn3270_object * obj = (tn3270_object *) zend_object_store_get_object(getThis() TSRMLS_CC); | |
| 133 | + | |
| 134 | + if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sb", &host, &szHost, &wait) == FAILURE) | |
| 135 | + RETURN_NULL(); | |
| 136 | + | |
| 137 | + if(szHost) | |
| 138 | + { | |
| 139 | + char text[szHost+1]; | |
| 140 | + strncpy(text,host,szHost); | |
| 141 | + text[szHost] = 0; | |
| 142 | + rc = obj->hSession->connect(text,wait); | |
| 143 | + } | |
| 144 | + else | |
| 145 | + { | |
| 146 | + rc = obj->hSession->connect(); | |
| 147 | + } | |
| 148 | + | |
| 149 | + RETURN_LONG(rc); | |
| 150 | +} | |
| 151 | + | |
| 152 | +PHP_METHOD(tn3270, disconnect) | |
| 153 | +{ | |
| 154 | + tn3270_object * obj = (tn3270_object *) zend_object_store_get_object(getThis() TSRMLS_CC); | |
| 155 | + RETURN_LONG(obj->hSession->disconnect()); | |
| 156 | +} | ... | ... |
src/php/php3270.h
src/php/sample.php