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
| @@ -64,6 +64,13 @@ PHP_METHOD(tn3270, __construct) | @@ -64,6 +64,13 @@ PHP_METHOD(tn3270, __construct) | ||
| 64 | obj->hSession = session::start(); | 64 | obj->hSession = session::start(); |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | + if(szURL) | ||
| 68 | + { | ||
| 69 | + char text[szURL+1]; | ||
| 70 | + strncpy(text,url,szURL); | ||
| 71 | + text[szURL] = 0; | ||
| 72 | + obj->hSession->set_url(text); | ||
| 73 | + } | ||
| 67 | 74 | ||
| 68 | } | 75 | } |
| 69 | 76 |
src/php/main.cc
| @@ -43,6 +43,8 @@ static zend_object_handlers tn3270_object_handlers; | @@ -43,6 +43,8 @@ static zend_object_handlers tn3270_object_handlers; | ||
| 43 | zend_function_entry tn3270_methods[] = | 43 | zend_function_entry tn3270_methods[] = |
| 44 | { | 44 | { |
| 45 | PHP_ME( tn3270, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) | 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 | {NULL, NULL, NULL} | 50 | {NULL, NULL, NULL} |
| @@ -121,3 +123,34 @@ extern "C" | @@ -121,3 +123,34 @@ extern "C" | ||
| 121 | } | 123 | } |
| 122 | // #endif | 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
| @@ -4,5 +4,12 @@ | @@ -4,5 +4,12 @@ | ||
| 4 | 4 | ||
| 5 | $host = new tn3270("pw3270:a"); | 5 | $host = new tn3270("pw3270:a"); |
| 6 | 6 | ||
| 7 | + $rc = $host->connect(); | ||
| 8 | + print("connect() exits with rc=" . $rc . "\n"); | ||
| 9 | + | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + $rc = $host->disconnect(); | ||
| 13 | + print("disconnect() exits with rc=" . $rc . "\n"); | ||
| 7 | 14 | ||
| 8 | ?> | 15 | ?> |