From 034342bbe4adafa80deae969738363ba18c6e31a Mon Sep 17 00:00:00 2001 From: PerryWerneck Date: Thu, 15 Dec 2016 22:16:34 -0200 Subject: [PATCH] Ajustes para empacotamento. --- .gitignore | 1 + Makefile.in | 18 ++++++++++-------- configure.ac | 1 + php.ini.in | 2 ++ src/get.cc | 20 ++++++++++++++++++++ src/main.cc | 3 +++ src/php3270.h.in | 4 ++++ testprograms/sample.php | 28 ++++++++++++++++++++++++++++ testprograms/version.php | 10 ++++++++++ 9 files changed, 79 insertions(+), 8 deletions(-) create mode 100644 php.ini.in create mode 100644 testprograms/sample.php create mode 100644 testprograms/version.php diff --git a/.gitignore b/.gitignore index 2663d28..2315cad 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ ChangeLog revision revision.m4 php3270.h +*.ini diff --git a/Makefile.in b/Makefile.in index 08c0642..1f8b0f2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -104,16 +104,13 @@ Release: \ $(BINRLS)/$(LIBNAME) install: \ - $(BINRLS)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ - - @$(MKDIR) $(DESTDIR)/$(libdir) - @$(INSTALL_PROGRAM) $(BINRLS)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ $(DESTDIR)/$(libdir) + $(BINRLS)/$(LIBNAME) - @rm -f $(DESTDIR)/$(libdir)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@ - @rm -f $(DESTDIR)/$(libdir)/$(LIBNAME) + @$(MKDIR) $(DESTDIR)/`$(PHPCONFIG) --extension-dir` + @$(INSTALL_PROGRAM) $(BINRLS)/$(LIBNAME) $(DESTDIR)/`$(PHPCONFIG) --extension-dir`/tn3270@DLLEXT@ - @$(LN_S) $(LIBNAME).@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ $(DESTDIR)/$(libdir)/$(LIBNAME).@PACKAGE_MAJOR_VERSION@ - @$(LN_S) $(LIBNAME).@PACKAGE_MAJOR_VERSION@ $(DESTDIR)/$(libdir)/$(LIBNAME) + @$(MKDIR) $(DESTDIR)/@PHPCONFDIR@ + @$(INSTALL_DATA) php.ini $(DESTDIR)/@PHPCONFDIR@/tn3270.ini $(BINRLS)/$(LIBNAME): \ $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC).o) @@ -132,6 +129,11 @@ $(BINDBG)/$(LIBNAME): \ @$(MKDIR) `dirname $@` @$(LD) -shared -Wl,-soname,$(LIBNAME) $(LDFLAGS) -o $@ $^ $(LIBS) +run: \ + $(BINDBG)/$(LIBNAME) + + php -d extension=$(BINDBG)/$(LIBNAME) testprograms/version.php + clean: @rm -fr $(BINDIR) diff --git a/configure.ac b/configure.ac index 0d3d83a..87cde15 100644 --- a/configure.ac +++ b/configure.ac @@ -367,6 +367,7 @@ dnl --------------------------------------------------------------------------- AC_CONFIG_FILES(Makefile) AC_CONFIG_FILES(src/php3270.h) +AC_CONFIG_FILES(php.ini) dnl --------------------------------------------------------------------------- dnl Output the generated config.status script. diff --git a/php.ini.in b/php.ini.in new file mode 100644 index 0000000..596b7d9 --- /dev/null +++ b/php.ini.in @@ -0,0 +1,2 @@ +; comment out next line to disable pdo extension in php +extension=tn3270@DLLEXT@ diff --git a/src/get.cc b/src/get.cc index 94c7093..798c21c 100644 --- a/src/get.cc +++ b/src/get.cc @@ -106,3 +106,23 @@ PHP_METHOD(tn3270, getisprotectedat) RETURN_LONG(obj->hSession->get_is_protected_at(row,col)); } + +PHP_METHOD(tn3270, getversion) +{ + tn3270_object * obj = (tn3270_object *) zend_object_store_get_object(getThis() TSRMLS_CC); + + string str = obj->hSession->get_version(); + + trace("String = [%s]",str.c_str()); + RETURN_STRING(str.c_str(),1); +} + +PHP_METHOD(tn3270, getrevision) +{ + tn3270_object * obj = (tn3270_object *) zend_object_store_get_object(getThis() TSRMLS_CC); + + string str = obj->hSession->get_revision(); + + trace("String = [%s]",str.c_str()); + RETURN_STRING(str.c_str(),1); +} diff --git a/src/main.cc b/src/main.cc index e509379..81280e9 100644 --- a/src/main.cc +++ b/src/main.cc @@ -44,6 +44,9 @@ zend_function_entry tn3270_methods[] = { PHP_ME( tn3270, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) + PHP_ME( tn3270, getversion, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) + PHP_ME( tn3270, getrevision, 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) diff --git a/src/php3270.h.in b/src/php3270.h.in index 75d138b..2c44ba7 100644 --- a/src/php3270.h.in +++ b/src/php3270.h.in @@ -48,6 +48,10 @@ // 3270 session methods PHP_METHOD(tn3270,__construct); + + PHP_METHOD(tn3270,getversion); + PHP_METHOD(tn3270,getrevision); + PHP_METHOD(tn3270,connect); PHP_METHOD(tn3270,disconnect); PHP_METHOD(tn3270,isconnected); diff --git a/testprograms/sample.php b/testprograms/sample.php new file mode 100644 index 0000000..734e5a4 --- /dev/null +++ b/testprograms/sample.php @@ -0,0 +1,28 @@ +connect(); + print("connect() exits with rc=" . $rc . "\n"); + + $rc = $host->waitforready(10); + print("waitforready() exits with rc=" . $rc . "\n"); + + $str = $host->getstringat(3,2,14); + print("Getstring(3,2,14) saiu com \"" . $str . "\"\n"); + + $rc = $host->getisprotectedat(19,39); + print("GetIsprotectedAt(19,39) saiu com \"" . $rc . "\"\n"); + + $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"); + +?> diff --git a/testprograms/version.php b/testprograms/version.php new file mode 100644 index 0000000..7d933b7 --- /dev/null +++ b/testprograms/version.php @@ -0,0 +1,10 @@ +getVersion() . " revision " . $host->getRevision()); + +?> + -- libgit2 0.21.2