diff --git a/src/php/init.cc b/src/php/init.cc index 33fb2fd..a00c7a8 100644 --- a/src/php/init.cc +++ b/src/php/init.cc @@ -64,6 +64,13 @@ PHP_METHOD(tn3270, __construct) obj->hSession = session::start(); } + if(szURL) + { + char text[szURL+1]; + strncpy(text,url,szURL); + text[szURL] = 0; + obj->hSession->set_url(text); + } } diff --git a/src/php/main.cc b/src/php/main.cc index 8f99a48..1a5264c 100644 --- a/src/php/main.cc +++ b/src/php/main.cc @@ -43,6 +43,8 @@ static zend_object_handlers tn3270_object_handlers; zend_function_entry tn3270_methods[] = { PHP_ME( tn3270, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) + PHP_ME( tn3270, connect, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) + PHP_ME( tn3270, disconnect, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) {NULL, NULL, NULL} @@ -121,3 +123,34 @@ extern "C" } // #endif +PHP_METHOD(tn3270, connect) +{ + const char * host; + int szHost; + zend_bool wait = 0; + int rc = 0; + tn3270_object * obj = (tn3270_object *) zend_object_store_get_object(getThis() TSRMLS_CC); + + if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sb", &host, &szHost, &wait) == FAILURE) + RETURN_NULL(); + + if(szHost) + { + char text[szHost+1]; + strncpy(text,host,szHost); + text[szHost] = 0; + rc = obj->hSession->connect(text,wait); + } + else + { + rc = obj->hSession->connect(); + } + + RETURN_LONG(rc); +} + +PHP_METHOD(tn3270, disconnect) +{ + tn3270_object * obj = (tn3270_object *) zend_object_store_get_object(getThis() TSRMLS_CC); + RETURN_LONG(obj->hSession->disconnect()); +} diff --git a/src/php/php3270.h b/src/php/php3270.h index c391b39..8b50ab3 100644 --- a/src/php/php3270.h +++ b/src/php/php3270.h @@ -48,6 +48,8 @@ // 3270 session methods PHP_METHOD(tn3270,__construct); + PHP_METHOD(tn3270,connect); + PHP_METHOD(tn3270,disconnect); #undef PACKAGE_NAME diff --git a/src/php/sample.php b/src/php/sample.php index 6b56667..e16f31b 100644 --- a/src/php/sample.php +++ b/src/php/sample.php @@ -4,5 +4,12 @@ $host = new tn3270("pw3270:a"); + $rc = $host->connect(); + print("connect() exits with rc=" . $rc . "\n"); + + + + $rc = $host->disconnect(); + print("disconnect() exits with rc=" . $rc . "\n"); ?> -- libgit2 0.21.2