hllapi.h
9.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/*
* "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. Registro no INPI sob o nome G3270.
*
* Copyright (C) <2008> <Banco do Brasil S.A.>
*
* 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., 51 Franklin
* St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Este programa está nomeado como hllapi.h e possui - linhas de código.
*
* Contatos:
*
* perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
* erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
* licinio@bb.com.br (Licínio Luis Branco)
* kraucer@bb.com.br (Kraucer Fernandes Mazuco)
*
*/
#ifndef HLLAPI_H_INCLUDED
#define HLLAPI_H_INCLUDED 1
#include <lib3270.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define HLLAPI_MAXLENGTH 4096
/* Function codes - Reference http://www.ibm.com/support/knowledgecenter/SSEQ5Y_6.0.0/com.ibm.pcomm.doc/books/html/emulator_programming08.htm */
#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_SET_SESSION_PARAMETERS 9 /**< Lets you change certain default session options in EHLLAPI for all sessions. */
#define HLLAPI_CMD_COPYSTRTOPS 15 /**< Copies an ASCII string directly to a specified position in the presentation space. */
#define HLLAPI_CMD_PAUSE 18 /**< Waits for a specified amount of time. */
#define HLLAPI_RESET_SYSTEM 21 /**< Reinitializes EHLLAPI to its starting state. */
#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_GETREVISION 2000 /**< Get lib3270 revision */
/* Standard Return Codes - http://ps-2.kev009.com/tl/techlib/manuals/adoclib/3270hcon/hconugd/retrncod.htm#C20819C058kmar */
// 00 Either the function was successfully executed, or there were no host updates since the last call was issued.
#define HLLAPI_STATUS_SUCCESS 0 /**< Good return code */
// 01 Either the presentation space short session ID was invalid, or the application is not connected.
#define HLLAPI_STATUS_DISCONNECTED 1 /**< The presentation space was not valid or not connected. */
// 02 A parameter error occurred.
#define HLLAPI_STATUS_BAD_PARAMETER 2 /**< An incorrect option was specified. */
// 04 The execution of the function was inhibited because the target presentation space was busy.
// For example, X or XSYSTEM is displayed in the OIA for the 3270 terminal emulation.
#define HLLAPI_STATUS_TIMEOUT 4 /**< Timeout */
// 05 The execution of the function was inhibited for some reason other than the reasons stated in return code 4.
#define HLLAPI_STATUS_KEYBOARD_LOCKED 5 /**< The keyboard is locked. */
// 06 A data error occurred due to specification of an invalid parameter (for example, a length error causing truncation).
// 07 The specified presentation space position was invalid.
// 08 No prerequisite function was issued.
// 09 A system error occurred.
#define HLLAPI_STATUS_SYSTEM_ERROR 9 /**< A system error occurred */
// 10 The function number is not supported by the emulation program.
#define HLLAPI_STATUS_UNSUPPORTED 10
// 11 The resource that you requested is unavailable (for example, too many attempts have been made to connect to the same presentation space (PS) or another application is connected to the PS).
#define HLLAPI_STATUS_UNAVAILABLE 11 /**< Resource unavailable at this time */
// 20 Invalid keystroke caused by ESC= option.
// 21 OIA was updated.
// 22 PS was updated.
// 23 Both OIA and PS were updated.
// 24 Either the string was not found, or the presentation space is unformatted.
#define HLLAPI_STATUS_NOT_FOUND 24 /**< String not found or unformatted presentation space */
// 25 Keystrokes were not available on input queue.
// 26 A host event occurred. See QUERY HOST UPDATE (24) for details.
// 28 Field length was 0.
// 31 Keystroke queue overflow. Keystrokes were lost.
#define HLLAPI_STATUS_WAITING HLLAPI_STATUS_TIMEOUT
#if defined(_WIN32)
#include <windows.h>
// http://www.mingw.org/wiki/Visual_Basic_DLL
#define HLLAPI_API_CALL __declspec (dllexport) DWORD __stdcall
#else
// From wtypesbase.h
typedef uint8_t BYTE;
typedef uint16_t WORD;
typedef unsigned int UINT;
typedef int INT;
typedef uint32_t LONG;
typedef LONG WINBOOL;
typedef uint32_t DWORD;
typedef void *HANDLE;
typedef WORD *LPWORD;
typedef DWORD *LPDWORD;
typedef char CHAR;
typedef CHAR *LPSTR;
typedef const CHAR *LPCSTR;
typedef char WCHAR;
typedef WCHAR TCHAR;
typedef WCHAR *LPWSTR;
typedef TCHAR *LPTSTR;
typedef const WCHAR *LPCWSTR;
typedef const TCHAR *LPCTSTR;
typedef HANDLE *LPHANDLE;
#define LPWORD uint16_t *
#define LPSTR char *
#define HANDLE int
#define HLLAPI_API_CALL __attribute__((visibility("default"))) extern DWORD
#endif // _WIN32
HLLAPI_API_CALL hllapi(const LPWORD func, LPSTR str, LPWORD length, LPWORD rc);
HLLAPI_API_CALL hllapi_init(LPSTR mode);
HLLAPI_API_CALL hllapi_deinit(void);
HLLAPI_API_CALL hllapi_reset(void);
HLLAPI_API_CALL hllapi_connect(LPSTR uri, WORD wait);
HLLAPI_API_CALL hllapi_disconnect(void);
HLLAPI_API_CALL hllapi_get_message_id(void);
HLLAPI_API_CALL hllapi_is_connected(void);
HLLAPI_API_CALL hllapi_get_state(void);
HLLAPI_API_CALL hllapi_get_screen_at(WORD row, WORD col, LPSTR buffer);
HLLAPI_API_CALL hllapi_get_screen(WORD pos, LPSTR buffer, WORD len);
HLLAPI_API_CALL hllapi_enter(void);
HLLAPI_API_CALL hllapi_set_text_at(WORD row, WORD col, LPSTR text);
HLLAPI_API_CALL hllapi_cmp_text_at(WORD row, WORD col, LPSTR text);
HLLAPI_API_CALL hllapi_find_text(LPSTR text);
HLLAPI_API_CALL hllapi_emulate_input(const LPSTR buffer, WORD len, WORD pasting);
HLLAPI_API_CALL hllapi_input_string(LPSTR buffer, WORD len);
HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds);
HLLAPI_API_CALL hllapi_wait_for_change(WORD seconds);
HLLAPI_API_CALL hllapi_wait(WORD seconds);
HLLAPI_API_CALL hllapi_pfkey(WORD key);
HLLAPI_API_CALL hllapi_pakey(WORD key);
HLLAPI_API_CALL hllapi_set_session_parameter(LPSTR param, WORD len, WORD value);
HLLAPI_API_CALL hllapi_erase(void);
HLLAPI_API_CALL hllapi_erase_eof(void);
HLLAPI_API_CALL hllapi_erase_eol(void);
HLLAPI_API_CALL hllapi_erase_input(void);
HLLAPI_API_CALL hllapi_action(LPSTR buffer);
HLLAPI_API_CALL hllapi_print(void);
HLLAPI_API_CALL hllapi_init(LPSTR mode);
HLLAPI_API_CALL hllapi_deinit(void);
HLLAPI_API_CALL hllapi_get_revision(void);
HLLAPI_API_CALL hllapi_get_datadir(LPSTR datadir);
HLLAPI_API_CALL hllapi_set_charset(LPSTR datadir);
HLLAPI_API_CALL hllapi_connect(LPSTR uri, WORD wait);
HLLAPI_API_CALL hllapi_disconnect(void);
HLLAPI_API_CALL hllapi_get_message_id(void);
HLLAPI_API_CALL hllapi_is_connected(void);
HLLAPI_API_CALL hllapi_get_state(void);
HLLAPI_API_CALL hllapi_get_screen(WORD pos, LPSTR buffer, WORD len);
HLLAPI_API_CALL hllapi_enter(void);
HLLAPI_API_CALL hllapi_set_text_at(WORD row, WORD col, LPSTR text);
HLLAPI_API_CALL hllapi_cmp_text_at(WORD row, WORD col, LPSTR text);
HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds);
HLLAPI_API_CALL hllapi_wait(WORD seconds);
HLLAPI_API_CALL hllapi_pfkey(WORD key);
HLLAPI_API_CALL hllapi_pakey(WORD key);
HLLAPI_API_CALL hllapi_setcursor(WORD key);
HLLAPI_API_CALL hllapi_getcursor();
HLLAPI_API_CALL hllapi_get_cursor_address();
HLLAPI_API_CALL hllapi_setcursor(WORD addr);
HLLAPI_API_CALL hllapi_set_cursor_address(WORD addr);
HLLAPI_API_CALL hllapi_erase_eof(void);
HLLAPI_API_CALL hllapi_print(void);
HLLAPI_API_CALL hllapi_set_unlock_delay(WORD ms);
#ifdef __cplusplus
} /* end of extern "C" */
#endif
#endif // HLLAPI_H_INCLUDED