From 61045cafe255666648ed100c187a2a497bde1ae2 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Fri, 14 Dec 2012 11:40:31 +0000 Subject: [PATCH] Iniciando implementação de novas funções para o plugin hllapi --- src/include/pw3270/hllapi.h | 17 +++++++++++++---- src/plugins/remotectl/hllapi.c | 16 ++++++++-------- src/plugins/remotectl/pipesource.c | 32 ++++++++++++++++++-------------- src/plugins/remotectl/remotectl.c | 48 +++++++++++++++++++++++++----------------------- src/plugins/remotectl/remotectl.h | 2 ++ src/pw3270/filetransfer.c | 33 ++------------------------------- 6 files changed, 68 insertions(+), 80 deletions(-) diff --git a/src/include/pw3270/hllapi.h b/src/include/pw3270/hllapi.h index 64f7860..efbedbe 100644 --- a/src/include/pw3270/hllapi.h +++ b/src/include/pw3270/hllapi.h @@ -38,16 +38,25 @@ extern "C" { #endif - #define HLLAPI_REQUEST_ID 0x01 + #define HLLAPI_REQUEST_QUERY 0x01 + #define HLLAPI_RESPONSE_VALUE 0x02 + #define HLLAPI_RESPONSE_TEXT 0x03 + #define HLLAPI_MAXLENGTH 32768 #define HLLAPI_CMD_CONNECTPS 1 /**< connect presentation space */ #define HLLAPI_CMD_DISCONNECTPS 2 /**< disconnect presentation space */ #define HLLAPI_CMD_INPUTSTRING 3 /**< send string */ #define HLLAPI_CMD_WAIT 4 /**< Wait if the session is waiting for a host response */ + #define HLLAPI_CMD_COPYPS 5 /**< Copies the contents of the presentation space into a string buffer. */ + #define HLLAPI_CMD_SEARCHPS 6 /**< Search the presentation space for a specified string. */ + #define HLLAPI_CMD_QUERYCURSOR 7 /**< Determines the location of the cursor in the presentation space. */ + #define HLLAPI_CMD_COPYPSTOSTR 8 /**< Copy presentation space to string */ + #define HLLAPI_CMD_COPYSTRTOPS 15 /**< Copies an ASCII string directly to a specified position in the presentation space. */ + #define HLLAPI_CMD_SETCURSOR 40 /**< Places the cursor at a specified position in presentation space.*/ + #define HLLAPI_CMD_SENDFILE 90 /**< Send file to the host */ + #define HLLAPI_CMD_RECEIVEFILE 91 /**< Receive a file from the host */ - #define HLLAPI_CMD_COPYPSTOSTR 8 /**< copy presentation space to string */ - #define HLLAPI_CMD_SETCURSOR 40 /**< set cursor */ #define HLLAPI_CMD_GETREVISION 2000 /**< Get lib3270 revision */ #pragma pack(1) @@ -56,7 +65,7 @@ extern "C" { unsigned char id; /**< Request id */ unsigned long func; /**< Function number */ unsigned short rc; /**< Short argument/return code */ - unsigned short len; /**< Text length */ + unsigned int value; /**< Requested value */ char string[1]; /**< String argument */ } HLLAPI_DATA; #pragma pack() diff --git a/src/plugins/remotectl/hllapi.c b/src/plugins/remotectl/hllapi.c index affc9ce..1d22a5b 100644 --- a/src/plugins/remotectl/hllapi.c +++ b/src/plugins/remotectl/hllapi.c @@ -98,10 +98,10 @@ memset(buffer,0,HLLAPI_MAXLENGTH); - data->id = HLLAPI_REQUEST_ID; + data->id = HLLAPI_REQUEST_QUERY; data->func = func; data->rc = *rc; - data->len = *length; + data->value = *length; if(arg && *length > 0) memcpy(data->string,arg,*length); @@ -116,15 +116,15 @@ else { *rc = buffer->rc; - *length = buffer->len; + *length = buffer->value; - trace("buffer->len=%d rc=%d",buffer->len,buffer->rc); + trace("buffer->id=%d buffer->value=%d rc=%d",buffer->id,buffer->value,buffer->rc); - if(buffer->len > 0) + if(buffer->value > 0 && buffer->id == HLLAPI_RESPONSE_TEXT) { - outBuffer = malloc(buffer->len+1); - memcpy(outBuffer,buffer->string,buffer->len); - outBuffer[buffer->len] = 0; + outBuffer = malloc(buffer->value+1); + memcpy(outBuffer,buffer->string,buffer->value); + outBuffer[buffer->value] = 0; trace("outBuffer=[%s]",outBuffer); } diff --git a/src/plugins/remotectl/pipesource.c b/src/plugins/remotectl/pipesource.c index ebc211b..9877d13 100644 --- a/src/plugins/remotectl/pipesource.c +++ b/src/plugins/remotectl/pipesource.c @@ -143,12 +143,12 @@ static void wait_for_client(pipe_source *source) qry->hPipe = source->hPipe; qry->text = (const gchar *) (qry+1); - if(data->id == 0x01) + if(data->id == HLLAPI_REQUEST_QUERY) { // HLLAPI query qry->cmd = (int) data->func; qry->pos = (int) data->rc; - qry->length = data->len; + qry->length = data->value; memcpy((gchar *)(qry->text),data->string,qry->length); } else @@ -175,26 +175,29 @@ static void wait_for_client(pipe_source *source) { request_buffer(qry, rc, 0, NULL); } -/* - HLLAPI_DATA data; + } - memset(&data,0,sizeof(data)); + void request_value(QUERY *qry, int rc, unsigned int value) + { + HLLAPI_DATA data; - data.id = 0x01; + memset(&data,0,sizeof(data)); + data.id = HLLAPI_RESPONSE_VALUE; data.func = qry->cmd; data.rc = rc; - - trace("rc=%d",rc); + data.value = value; #ifdef WIN32 { DWORD wrote = sizeof(data); WriteFile(qry->hPipe,&data,wrote,&wrote,NULL); + trace("Wrote=%d len=%d",(int) wrote, sizeof(data)); } #endif // WIN32 g_free(qry); -*/ + + } void request_buffer(QUERY *qry, int rc, size_t szBuffer, const gpointer buffer) @@ -206,20 +209,21 @@ static void wait_for_client(pipe_source *source) { sz = sizeof(HLLAPI_DATA)+szBuffer; data = g_malloc0(sz); - data->len = szBuffer; + data->id = HLLAPI_RESPONSE_TEXT; memcpy(data->string,buffer,szBuffer); } else { - sz = sizeof(HLLAPI_DATA); - data = g_malloc0(sz); + sz = sizeof(HLLAPI_DATA); + data = g_malloc0(sz); + data->id = HLLAPI_RESPONSE_VALUE; } - data->id = 0x01; data->func = qry->cmd; data->rc = rc; + data->value = szBuffer; - trace("rc=%d data->len=%d",rc,(int) data->len); + trace("rc=%d data->len=%d",rc,(int) szBuffer); #ifdef WIN32 { diff --git a/src/plugins/remotectl/remotectl.c b/src/plugins/remotectl/remotectl.c index 8f1940e..709b10a 100644 --- a/src/plugins/remotectl/remotectl.c +++ b/src/plugins/remotectl/remotectl.c @@ -405,6 +405,11 @@ g_free(buffer); } + static void cmd_querycursor(QUERY *qry) + { + request_value(qry,0,lib3270_get_cursor_address(qry->hSession)); + } + void enqueue_request(QUERY *qry) { static const struct _cmd @@ -413,15 +418,29 @@ void (*exec)(QUERY *qry); } cmd[] = { - { HLLAPI_CMD_CONNECTPS, cmd_connectps }, - { HLLAPI_CMD_DISCONNECTPS, cmd_disconnectps }, - { HLLAPI_CMD_INPUTSTRING, cmd_sendstring }, - { HLLAPI_CMD_SETCURSOR, cmd_setcursor }, + { HLLAPI_CMD_CONNECTPS, cmd_connectps }, // 1 + { HLLAPI_CMD_DISCONNECTPS, cmd_disconnectps }, // 2 + { HLLAPI_CMD_INPUTSTRING, cmd_sendstring }, // 3 + { HLLAPI_CMD_WAIT, cmd_wait }, // 4 +// { HLLAPI_CMD_COPYPS, }, // 5 +// { HLLAPI_CMD_SEARCHPS, }, // 6 + { HLLAPI_CMD_QUERYCURSOR, cmd_querycursor }, // 7 + + { HLLAPI_CMD_COPYPSTOSTR, cmd_copypstostr }, // 8 + +// { HLLAPI_CMD_COPYSTRTOPS }, // 15 + + { HLLAPI_CMD_SETCURSOR, cmd_setcursor }, // 40 + +// { HLLAPI_CMD_SENDFILE }, // 90 +// { HLLAPI_CMD_RECEIVEFILE }, + + { HLLAPI_CMD_GETREVISION, cmd_getrevision }, - { HLLAPI_CMD_COPYPSTOSTR, cmd_copypstostr }, - { HLLAPI_CMD_WAIT, cmd_wait }, }; + + int f; trace("HLLAPI function %d",(int) qry->cmd); @@ -441,23 +460,6 @@ request_status(qry,EINVAL); } -/* - int run_hllapi(unsigned long function, char *string, unsigned short length, unsigned short rc) - { - - trace("HLLAPI function %d",(int) function); - - for(f=0;fready,is_dialog_ok(editable,dlg)); } -static GtkWidget * add_filename_entry(GObject *action, int ix, int row, struct ftdialog *dlg, GtkTable *table) +static GtkEntry * add_filename_entry(GObject *action, int ix, int row, struct ftdialog *dlg, GtkTable *table) { static const gchar * label_text[] = { N_( "_Local file name:" ), N_( "_Host file name:" ) }; static const gchar * attr[] = { "local", "remote" }; @@ -201,14 +201,13 @@ static GtkWidget * add_filename_entry(GObject *action, int ix, int row, struct f gtk_table_attach(GTK_TABLE(table),entry,1,3,row,row+1,GTK_EXPAND|GTK_SHRINK|GTK_FILL,GTK_EXPAND|GTK_SHRINK|GTK_FILL,2,2); - return entry; + return GTK_ENTRY(entry); } static void add_file_fields(GObject *action, struct ftdialog *dlg) { GtkTable * table = GTK_TABLE(gtk_table_new(2,3,FALSE)); GtkWidget * widget; - int f; gtk_container_set_border_width(GTK_CONTAINER(table),2); @@ -232,34 +231,6 @@ static void add_file_fields(GObject *action, struct ftdialog *dlg) dlg->file[1] = add_filename_entry(action,1,1,dlg,table); } - - -/* - for(f=0;f<2;f++) - { - - gchar *val; - - widget = gtk_label_new_with_mnemonic(gettext(label[f])); - - gtk_misc_set_alignment(GTK_MISC(widget),0,.5); - gtk_table_attach(GTK_TABLE(table),widget,0,1,f,f+1,GTK_FILL,GTK_FILL,2,2); - - dlg->file[f] = GTK_ENTRY(gtk_entry_new()); - - gtk_widget_set_name(GTK_WIDGET(dlg->file[f]),attr[f]); - - val = get_attribute(action,dlg,attr[f]); - gtk_entry_set_text(dlg->file[f],val); - g_free(val); - - gtk_entry_set_width_chars(dlg->file[f],40); - - gtk_label_set_mnemonic_widget(GTK_LABEL(widget),GTK_WIDGET(dlg->file[f])); - - gtk_table_attach(GTK_TABLE(table),GTK_WIDGET(dlg->file[f]),1,3,f,f+1,GTK_EXPAND|GTK_SHRINK|GTK_FILL,GTK_EXPAND|GTK_SHRINK|GTK_FILL,2,2); - } -*/ gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dlg->dialog))),GTK_WIDGET(table),FALSE,FALSE,2); -- libgit2 0.21.2