Commit 452df2c70445c3ad7c1fdfad7015d6da9aac5c29
1 parent
05094bbe
Exists in
master
and in
5 other branches
Implementando plugin hllapi
Showing
4 changed files
with
46 additions
and
25 deletions
Show diff stats
po/pt_BR.po
@@ -5,7 +5,7 @@ msgid "" | @@ -5,7 +5,7 @@ msgid "" | ||
5 | msgstr "" | 5 | msgstr "" |
6 | "Project-Id-Version: pw3270 5.0\n" | 6 | "Project-Id-Version: pw3270 5.0\n" |
7 | "Report-Msgid-Bugs-To: \n" | 7 | "Report-Msgid-Bugs-To: \n" |
8 | -"POT-Creation-Date: 2012-09-17 09:45-0300\n" | 8 | +"POT-Creation-Date: 2012-09-17 14:31-0300\n" |
9 | "PO-Revision-Date: 2012-09-14 14:32-0300\n" | 9 | "PO-Revision-Date: 2012-09-14 14:32-0300\n" |
10 | "Last-Translator: Perry Werneck <perry.werneck@gmail.com>\n" | 10 | "Last-Translator: Perry Werneck <perry.werneck@gmail.com>\n" |
11 | "Language-Team: Português <perry.werneck@gmail.com>\n" | 11 | "Language-Team: Português <perry.werneck@gmail.com>\n" |
src/include/pw3270/hllapi.h
@@ -41,11 +41,14 @@ extern "C" { | @@ -41,11 +41,14 @@ extern "C" { | ||
41 | #define HLLAPI_REQUEST_ID 0x01 | 41 | #define HLLAPI_REQUEST_ID 0x01 |
42 | #define HLLAPI_MAXLENGTH 32768 | 42 | #define HLLAPI_MAXLENGTH 32768 |
43 | 43 | ||
44 | - #define HLLAPI_CMD_CONNECTPS 1 /**< connect presentation space */ | ||
45 | - #define HLLAPI_CMD_INPUTSTRING 3 /**< send string */ | ||
46 | - #define HLLAPI_CMD_COPYPSTOSTR 8 /**< copy presentation space to string */ | ||
47 | - #define HLLAPI_CMD_SETCURSOR 40 /**< set cursor */ | ||
48 | - #define HLLAPI_CMD_GETREVISION 2000 /**< Get lib3270 revision */ | 44 | + #define HLLAPI_CMD_CONNECTPS 1 /**< connect presentation space */ |
45 | + #define HLLAPI_CMD_DISCONNECTPS 2 /**< disconnect presentation space */ | ||
46 | + #define HLLAPI_CMD_INPUTSTRING 3 /**< send string */ | ||
47 | + #define HLLAPI_CMD_WAIT 4 /**< Wait if the session is waiting for a host response */ | ||
48 | + | ||
49 | + #define HLLAPI_CMD_COPYPSTOSTR 8 /**< copy presentation space to string */ | ||
50 | + #define HLLAPI_CMD_SETCURSOR 40 /**< set cursor */ | ||
51 | + #define HLLAPI_CMD_GETREVISION 2000 /**< Get lib3270 revision */ | ||
49 | 52 | ||
50 | #pragma pack(1) | 53 | #pragma pack(1) |
51 | typedef struct _hllapi_data | 54 | typedef struct _hllapi_data |
src/plugins/remotectl/hllapi.c
@@ -51,6 +51,9 @@ | @@ -51,6 +51,9 @@ | ||
51 | if(length < 0 && string) | 51 | if(length < 0 && string) |
52 | length = strlen(string); | 52 | length = strlen(string); |
53 | 53 | ||
54 | + if(!session_name) | ||
55 | + session_name = strdup("pw3270A"); | ||
56 | + | ||
54 | snprintf(PipeName,4095,"\\\\.\\pipe\\%s",session_name); | 57 | snprintf(PipeName,4095,"\\\\.\\pipe\\%s",session_name); |
55 | 58 | ||
56 | if(!WaitNamedPipe(PipeName,NMPWAIT_USE_DEFAULT_WAIT)) | 59 | if(!WaitNamedPipe(PipeName,NMPWAIT_USE_DEFAULT_WAIT)) |
@@ -114,7 +117,6 @@ | @@ -114,7 +117,6 @@ | ||
114 | if(!session_name) | 117 | if(!session_name) |
115 | free(session_name); | 118 | free(session_name); |
116 | session_name = strdup(name); | 119 | session_name = strdup(name); |
117 | - | ||
118 | return 0; | 120 | return 0; |
119 | } | 121 | } |
120 | 122 | ||
@@ -152,15 +154,22 @@ | @@ -152,15 +154,22 @@ | ||
152 | result = run_query(*func, arg, str, *length, rc); | 154 | result = run_query(*func, arg, str, *length, rc); |
153 | break; | 155 | break; |
154 | 156 | ||
155 | - default: | ||
156 | - if(!session_name) | 157 | + case HLLAPI_CMD_DISCONNECTPS: |
158 | + if(session_name) | ||
157 | { | 159 | { |
158 | - if(set_session_name("pw3270A")) | ||
159 | - return ENOENT; | 160 | + result = run_query(*func, arg, str, *length, rc); |
161 | + free(session_name); | ||
162 | + session_name = NULL; | ||
160 | } | 163 | } |
164 | + break; | ||
165 | + | ||
166 | + default: | ||
161 | result = run_query(*func, arg, str, *length, rc); | 167 | result = run_query(*func, arg, str, *length, rc); |
162 | } | 168 | } |
163 | 169 | ||
170 | + if(result && length && *length && str) | ||
171 | + strncpy(str,strerror(result),*length); | ||
172 | + | ||
164 | free(arg); | 173 | free(arg); |
165 | return result; | 174 | return result; |
166 | } | 175 | } |
src/plugins/remotectl/remotectl.c
@@ -133,22 +133,26 @@ | @@ -133,22 +133,26 @@ | ||
133 | return 0; | 133 | return 0; |
134 | } | 134 | } |
135 | 135 | ||
136 | - static int cmd_connectps(unsigned short rc, char *string, unsigned short length) | 136 | + static int cmd_connectps(H3270 *hSession, unsigned short rc, char *string, unsigned short length) |
137 | { | 137 | { |
138 | g_message("%s","HLLAPI ConnectPS request received"); | 138 | g_message("%s","HLLAPI ConnectPS request received"); |
139 | return 0; | 139 | return 0; |
140 | } | 140 | } |
141 | 141 | ||
142 | - static int cmd_getrevision(unsigned short rc, char *string, unsigned short length) | 142 | + static int cmd_disconnectps(H3270 *hSession, unsigned short rc, char *string, unsigned short length) |
143 | { | 143 | { |
144 | - strncpy(string,lib3270_get_revision(),length); | 144 | + g_message("%s","HLLAPI DisconnectPS request received"); |
145 | return 0; | 145 | return 0; |
146 | } | 146 | } |
147 | 147 | ||
148 | - static int cmd_setcursor(unsigned short rc, char *string, unsigned short length) | 148 | + static int cmd_getrevision(H3270 *hSession, unsigned short rc, char *string, unsigned short length) |
149 | { | 149 | { |
150 | - H3270 *hSession = lib3270_get_default_session_handle(); | 150 | + strncpy(string,lib3270_get_revision(),length); |
151 | + return 0; | ||
152 | + } | ||
151 | 153 | ||
154 | + static int cmd_setcursor(H3270 *hSession, unsigned short rc, char *string, unsigned short length) | ||
155 | + { | ||
152 | if(!lib3270_connected(hSession)) | 156 | if(!lib3270_connected(hSession)) |
153 | return ENOTCONN; | 157 | return ENOTCONN; |
154 | 158 | ||
@@ -156,10 +160,8 @@ | @@ -156,10 +160,8 @@ | ||
156 | return 0; | 160 | return 0; |
157 | } | 161 | } |
158 | 162 | ||
159 | - static int cmd_sendstring(unsigned short rc, char *text, unsigned short length) | 163 | + static int cmd_sendstring(H3270 *hSession, unsigned short rc, char *text, unsigned short length) |
160 | { | 164 | { |
161 | - H3270 *hSession = lib3270_get_default_session_handle(); | ||
162 | - | ||
163 | if(!lib3270_connected(hSession)) | 165 | if(!lib3270_connected(hSession)) |
164 | return ENOTCONN; | 166 | return ENOTCONN; |
165 | 167 | ||
@@ -169,18 +171,25 @@ | @@ -169,18 +171,25 @@ | ||
169 | return 0; | 171 | return 0; |
170 | } | 172 | } |
171 | 173 | ||
174 | + static int cmd_wait(H3270 *hSession, unsigned short rc, char *text, unsigned short length) | ||
175 | + { | ||
176 | + return lib3270_wait_for_ready(hSession,60); | ||
177 | + } | ||
178 | + | ||
172 | int run_hllapi(unsigned long function, char *string, unsigned short length, unsigned short rc) | 179 | int run_hllapi(unsigned long function, char *string, unsigned short length, unsigned short rc) |
173 | { | 180 | { |
174 | static const struct _cmd | 181 | static const struct _cmd |
175 | { | 182 | { |
176 | unsigned long function; | 183 | unsigned long function; |
177 | - int (*exec)(unsigned short rc, char *string, unsigned short length); | 184 | + int (*exec)(H3270 *hSession, unsigned short rc, char *string, unsigned short length); |
178 | } cmd[] = | 185 | } cmd[] = |
179 | { | 186 | { |
180 | - { HLLAPI_CMD_CONNECTPS, cmd_connectps }, | ||
181 | - { HLLAPI_CMD_SETCURSOR, cmd_setcursor }, | ||
182 | - { HLLAPI_CMD_INPUTSTRING, cmd_sendstring }, | ||
183 | - { HLLAPI_CMD_GETREVISION, cmd_getrevision } | 187 | + { HLLAPI_CMD_CONNECTPS, cmd_connectps }, |
188 | + { HLLAPI_CMD_DISCONNECTPS, cmd_disconnectps }, | ||
189 | + { HLLAPI_CMD_INPUTSTRING, cmd_sendstring }, | ||
190 | + { HLLAPI_CMD_WAIT, cmd_wait }, | ||
191 | + { HLLAPI_CMD_SETCURSOR, cmd_setcursor }, | ||
192 | + { HLLAPI_CMD_GETREVISION, cmd_getrevision } | ||
184 | }; | 193 | }; |
185 | int f; | 194 | int f; |
186 | 195 | ||
@@ -189,7 +198,7 @@ | @@ -189,7 +198,7 @@ | ||
189 | for(f=0;f<G_N_ELEMENTS(cmd);f++) | 198 | for(f=0;f<G_N_ELEMENTS(cmd);f++) |
190 | { | 199 | { |
191 | if(cmd[f].function == function) | 200 | if(cmd[f].function == function) |
192 | - return cmd[f].exec(rc,string,length); | 201 | + return cmd[f].exec(lib3270_get_default_session_handle(),rc,string,length); |
193 | } | 202 | } |
194 | 203 | ||
195 | g_warning("Unexpected HLLAPI function %d",(int) function); | 204 | g_warning("Unexpected HLLAPI function %d",(int) function); |