diff --git a/pw3270.cbp b/pw3270.cbp
index d4c5081..e2a8f2b 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -225,6 +225,9 @@
+
+
+
diff --git a/src/include/pw3270/hllapi.h b/src/include/pw3270/hllapi.h
index bdff388..55eb8ff 100644
--- a/src/include/pw3270/hllapi.h
+++ b/src/include/pw3270/hllapi.h
@@ -29,6 +29,11 @@
*
*/
+#ifndef HLLAPI_H_INCLUDED
+
+ #define HLLAPI_H_INCLUDED 1
+ #include
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -53,9 +58,10 @@ extern "C" {
} HLLAPI_DATA;
#pragma pack()
- LIB3270_EXPORT int hllapi(unsigned long function, const char *string, unsigned short length, unsigned short *rc);
+ LIB3270_EXPORT int hllapi(unsigned long function, char *string, unsigned short length, unsigned short *rc);
#ifdef __cplusplus
} /* end of extern "C" */
#endif
+#endif // HLLAPI_H_INCLUDED
diff --git a/src/plugins/remotectl/Makefile.in b/src/plugins/remotectl/Makefile.in
index 761da97..055a5ca 100644
--- a/src/plugins/remotectl/Makefile.in
+++ b/src/plugins/remotectl/Makefile.in
@@ -104,7 +104,16 @@ $(BINDBG)/libhllapi.dll: $(foreach SRC, $(basename $(HLLAPI_SRC)), $(OBJDBG)/$(S
#---[ Misc targets ]-----------------------------------------------------------
+testprogram@EXEEXT@: testprogram.c
+ @echo " CCLD `basename $@`"
+ @$(MKDIR) `dirname $@`
+ @$(CC) $(CFLAGS) -I../../../src/include -L../../../$(BINDIR)/Debug $(DEBUG_CFLAGS) -lhllapi -o $@ -c $<
+
+test: testprogram@EXEEXT@
+ @PATH="../../../$(BINDIR)/Debug:$(PATH)" ./testprogram@EXEEXT@
+
clean:
@rm -fr $(OBJDIR)
@rm -fr $(BINDIR)
+ @rm -f testprogram@EXEEXT@
@find . -name "*~" -exec rm -f {} \;
diff --git a/src/plugins/remotectl/hllapi.c b/src/plugins/remotectl/hllapi.c
index 7cf78b9..3795e0b 100644
--- a/src/plugins/remotectl/hllapi.c
+++ b/src/plugins/remotectl/hllapi.c
@@ -32,10 +32,12 @@
#include
#include
#include
+ #include
+ #include
/*--[ Implement ]------------------------------------------------------------------------------------*/
- LIB3270_EXPORT int hllapi(unsigned long func, const char *string, unsigned short length, unsigned short *rc)
+ LIB3270_EXPORT int hllapi(unsigned long func, char *string, unsigned short length, unsigned short *rc)
{
int result = -1;
@@ -69,8 +71,8 @@
else
{
HLLAPI_DATA *buffer = malloc(HLLAPI_MAXLENGTH+1);
- DWORD cbSize = 0;
- HLLAPI_DATA *data = malloc(sizeof(HLLAPI_DATA) + length);
+ DWORD cbSize = sizeof(HLLAPI_DATA) + length;
+ HLLAPI_DATA *data = malloc(cbSize+1);
data->id = HLLAPI_REQUEST_ID;
data->func = func;
@@ -80,7 +82,9 @@
if(string && length > 0)
memcpy(data->string,string,length);
- if(!TransactNamedPipe(hPipe,(LPVOID) data,sizeof(HLLAPI_DATA) + length,buffer,HLLAPI_MAXLENGTH,&cbSize,NULL))
+ trace("Sending %d bytes",(int) cbSize);
+
+ if(!TransactNamedPipe(hPipe,(LPVOID) data,cbSize,buffer,HLLAPI_MAXLENGTH,&cbSize,NULL))
{
result = -1;
}
diff --git a/src/plugins/remotectl/pipesource.c b/src/plugins/remotectl/pipesource.c
index b038bb7..2b76714 100644
--- a/src/plugins/remotectl/pipesource.c
+++ b/src/plugins/remotectl/pipesource.c
@@ -34,7 +34,6 @@
#include
#include
- #include
#include "remotectl.h"
/*---[ Defines ]----------------------------------------------------------------------------*/
@@ -134,13 +133,18 @@ static void wait_for_client(pipe_source *source)
static void process_input(pipe_source *source, DWORD cbRead)
{
- gint argc = 0;
- gchar **argv;
- GError * error = NULL;
- gchar * cmd;
+ HLLAPI_DATA *data = (HLLAPI_DATA *) source->buffer;
source->buffer[cbRead] = 0;
+ if(data->id == 0x01)
+ {
+ DWORD wrote;
+ data->rc = run_hllapi(data->func,data->string,data->len,data->rc);
+ wrote = sizeof(HLLAPI_DATA)+data->len;
+ WriteFile(source->hPipe,data,wrote,&wrote,NULL);
+ }
+
}
static void read_input_pipe(pipe_source *source)
@@ -195,7 +199,7 @@ static void wait_for_client(pipe_source *source)
*/
BOOL fSuccess;
DWORD cbRead = 0;
- DWORD dwErr = 0;
+// DWORD dwErr = 0;
fSuccess = GetOverlappedResult(((pipe_source *) source)->hPipe,&((pipe_source *) source)->overlap,&cbRead,FALSE );
diff --git a/src/plugins/remotectl/remotectl.c b/src/plugins/remotectl/remotectl.c
index af5bfa3..43a30bc 100644
--- a/src/plugins/remotectl/remotectl.c
+++ b/src/plugins/remotectl/remotectl.c
@@ -33,6 +33,8 @@
#include "remotectl.h"
#include
+ #include
+ #include
/*--[ Implement ]------------------------------------------------------------------------------------*/
@@ -121,4 +123,30 @@
return 0;
}
+ static int cmd_getrevision(unsigned short rc, char *string, unsigned short length)
+ {
+ strncpy(string,lib3270_get_revision(),length);
+ return 0;
+ }
+
+ int run_hllapi(unsigned long function, char *string, unsigned short length, unsigned short rc)
+ {
+ static const struct _cmd
+ {
+ unsigned long function;
+ int (*exec)(unsigned short rc, char *string, unsigned short length);
+ } cmd[] =
+ {
+ { HLLAPI_CMD_GETREVISION, cmd_getrevision }
+ };
+ int f;
+
+ for(f=0;f
#include
+ int run_hllapi(unsigned long function, char *string, unsigned short length, unsigned short rc);
+
#ifdef WIN32
#define PIPE_BUFFER_LENGTH 4096
diff --git a/src/plugins/remotectl/testprogram.c b/src/plugins/remotectl/testprogram.c
new file mode 100644
index 0000000..424d526
--- /dev/null
+++ b/src/plugins/remotectl/testprogram.c
@@ -0,0 +1,46 @@
+/*
+ * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
+ * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
+ * aplicativos mainframe. Registro no INPI sob o nome G3270.
+ *
+ * Copyright (C) <2008>
+ *
+ * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
+ * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
+ * Free Software Foundation.
+ *
+ * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
+ * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
+ * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
+ * obter mais detalhes.
+ *
+ * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
+ * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA, 02111-1307, USA
+ *
+ * Este programa está nomeado como testprogram.c e possui - linhas de código.
+ *
+ * Contatos:
+ *
+ * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
+ * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
+ *
+ */
+
+ #include
+ #include
+ #include
+
+/*---[ Implement ]--------------------------------------------------------------------------------*/
+
+ int main(int numpar, char *param[])
+ {
+ char buffer[1024];
+ unsigned short rc;
+
+ // Test for GetRevision call
+ *buffer = 0;
+ printf("GetRevision exits with %d\n[%s]\n",hllapi(HLLAPI_CMD_GETREVISION,buffer,1024,&rc),buffer);
+
+ return 0;
+ }
--
libgit2 0.21.2