diff --git a/src/sample/Makefile.in b/src/sample/Makefile.in index c886c08..b95fbdb 100644 --- a/src/sample/Makefile.in +++ b/src/sample/Makefile.in @@ -35,6 +35,8 @@ MKDIR=@MKDIR_P@ CC=@CC@ LD=@CC@ +CFLAGS=-g -Wall + #---[ Targets ]---------------------------------------------------------------- all: connect$(EXEEXT) diff --git a/src/sample/connect.c b/src/sample/connect.c index 982e6c7..367360a 100644 --- a/src/sample/connect.c +++ b/src/sample/connect.c @@ -31,6 +31,7 @@ #include #include + #include #include /*--[ Implement ]------------------------------------------------------------------------------------*/ @@ -38,14 +39,49 @@ int main(int numpar, char *param[]) { H3270 *hSession; + int rc; - if(numpar != 1) + if(numpar != 2) { fprintf(stderr,"Inform host URI as argument\n"); exit(-1); - } + } + /* Get session handle */ + hSession = lib3270_session_new(""); + /* Connect to the requested URI, wait for 3270 negotiation */ + rc = lib3270_connect(hSession,param[1],1); + if(rc) + { + fprintf(stderr,"Can't connect to %s: %s\n",param[1],strerror(rc)); + return rc; + } + + printf("Connected to LU %s\n",lib3270_get_luname(hSession)); + + /* Wait until the host is ready for commands */ + rc = lib3270_wait_for_ready(hSession,60); + if(rc) + { + fprintf(stderr,"Error waiting for session negotiation: %s\n",strerror(rc)); + return rc; + } + else + { + /* Host is ready, get screen contents */ + char *text = lib3270_get_text(hSession,0,-1); + + printf("\nScreen contents:\n%s\n",text); + + lib3270_free(text); + } + + + + + /* Release session handle */ + lib3270_session_free(hSession); return 0; } diff --git a/src/sample/sample.cbp b/src/sample/sample.cbp new file mode 100644 index 0000000..fbbc9c8 --- /dev/null +++ b/src/sample/sample.cbp @@ -0,0 +1,32 @@ + + + + + + -- libgit2 0.21.2