Commit | Line | Data |
---|---|---|
f81b28ad | 1 | #include <stdio.h> |
87f7c3b6 | 2 | |
e99f17a9 GM |
3 | #include "../api/api.h" |
4 | #include "apilib.h" | |
5 | #include "../ctlr/oia.h" | |
6 | ||
7 | api_perror(string) | |
8 | char *string; | |
9 | { | |
10 | fprintf(stderr, "Error: [0x%x/0x%x:0x%x/0x%x] from %s.\n", | |
11 | api_sup_fcn_id, api_sup_errno, | |
12 | api_fcn_fcn_id, api_fcn_errno, string); | |
13 | } | |
14 | ||
15 | ||
16 | char * | |
17 | session_type(type) | |
18 | int type; | |
19 | { | |
20 | switch (type) { | |
21 | case TYPE_WSCTL: | |
22 | return "work station control"; | |
23 | case TYPE_DFT: | |
24 | return "distributed function terminal"; | |
25 | case TYPE_CUT: | |
26 | return "control unit terminal"; | |
27 | case TYPE_NOTEPAD: | |
28 | return "notepad"; | |
29 | case TYPE_PC: | |
30 | return "personal computer"; | |
31 | default: | |
32 | return "(UNKNOWN)"; | |
33 | } | |
34 | } | |
35 | ||
36 | ||
87f7c3b6 GM |
37 | main() |
38 | { | |
e99f17a9 GM |
39 | int session_id; |
40 | OIA oia; | |
41 | QuerySessionIdParms id; | |
42 | QuerySessionParametersParms pa; | |
43 | QuerySessionCursorParms cu; | |
44 | ConnectToKeyboardParms conn; | |
45 | DisconnectFromKeyboardParms disc; | |
46 | WriteKeystrokeParms wr; | |
47 | DisableInputParms disable; | |
48 | EnableInputParms enable; | |
49 | CopyStringParms copy; | |
50 | ReadOiaGroupParms re; | |
51 | NameArray namearray; | |
87f7c3b6 | 52 | |
f81b28ad GM |
53 | if (api_init() == 0) { |
54 | fprintf(stderr, "API function not available.\n"); | |
55 | return 1; | |
56 | } | |
57 | ||
e99f17a9 GM |
58 | id.rc = 0; |
59 | id.function_id = 0; | |
60 | id.option_code = ID_OPTION_BY_NAME; | |
61 | id.data_code = 'E'; | |
62 | id.name_array = &namearray; | |
63 | namearray.length = sizeof namearray; | |
64 | if (api_query_session_id(&id)) { | |
65 | api_perror("api_query_session_id"); | |
66 | } else if (namearray.number_matching_session == 0) { | |
67 | fprintf(stderr, "query_session_id: No matching sessions!\n"); | |
87f7c3b6 | 68 | } else { |
e99f17a9 GM |
69 | printf("Session short name 0x%x, type is ", |
70 | namearray.name_array_element.short_name); | |
71 | printf("%s", session_type(namearray.name_array_element.type)); | |
72 | printf(", session ID is: 0x%x\n", | |
73 | namearray.name_array_element.session_id); | |
87f7c3b6 | 74 | } |
e99f17a9 GM |
75 | session_id = namearray.name_array_element.session_id; |
76 | ||
77 | pa.rc = pa.function_id = 0; | |
78 | pa.session_id = session_id; | |
79 | if (api_query_session_parameters(&pa) == -1) { | |
80 | api_perror("api_query_session_parameters"); | |
87f7c3b6 | 81 | } else { |
e99f17a9 GM |
82 | printf("Session type %s, ", session_type(pa.session_type)); |
83 | if (pa.session_characteristics&CHARACTERISTIC_EAB) { | |
84 | printf(" has EAB, "); | |
85 | } | |
86 | if (pa.session_characteristics&CHARACTERISTIC_PSS) { | |
87 | printf(" has PSS, "); | |
88 | } | |
89 | printf("%d rows, %d columns ", pa.rows, pa.columns); | |
90 | if (pa.presentation_space) { | |
91 | printf("presentation space at 0x%x:0x%x.\n", | |
92 | FP_SEG(pa.presentation_space), FP_OFF(pa.presentation_space)); | |
93 | } else { | |
94 | printf("(no direct presentation space access).\n"); | |
95 | } | |
87f7c3b6 | 96 | } |
e99f17a9 GM |
97 | |
98 | cu.rc = cu.function_id = 0; | |
99 | cu.session_id = session_id; | |
100 | if (api_query_session_cursor(&cu) == -1) { | |
101 | api_perror("api_query_session_cursor"); | |
87f7c3b6 | 102 | } else { |
e99f17a9 GM |
103 | printf("cursor"); |
104 | if (cu.cursor_type&CURSOR_INHIBITED_AUTOSCROLL) { | |
105 | printf(" inhibited autoscroll"); | |
106 | } | |
107 | if (cu.cursor_type&CURSOR_INHIBITED) { | |
108 | printf(" inhibited"); | |
109 | } | |
110 | if (cu.cursor_type&CURSOR_BLINKING) { | |
111 | printf(" blinking"); | |
112 | } else { | |
113 | printf(" not blinking"); | |
114 | } | |
115 | if (cu.cursor_type&CURSOR_BOX) { | |
116 | printf(" box "); | |
117 | } else { | |
118 | printf(" not box "); | |
119 | } | |
120 | printf("at row %d, column %d.\n", cu.row_address, cu.column_address); | |
87f7c3b6 | 121 | } |
e99f17a9 GM |
122 | |
123 | re.rc = re.function_id = 0; | |
124 | re.session_id = session_id; | |
125 | re.oia_buffer = (char far *) &oia; | |
126 | re.oia_group_number = API_OIA_ALL_GROUPS; | |
127 | if (api_read_oia_group(&re) == -1) { | |
128 | api_perror("api_read_oia_group"); | |
87f7c3b6 | 129 | } else { |
e99f17a9 GM |
130 | if (IsOiaReady3274(&oia)) { |
131 | printf("3274 ready, "); | |
132 | } | |
133 | if (IsOiaMyJob(&oia)) { | |
134 | printf("my job, "); | |
135 | } | |
136 | if (IsOiaInsert(&oia)) { | |
137 | printf("insert mode, "); | |
138 | } | |
139 | if (IsOiaSystemLocked(&oia)) { | |
140 | printf("system locked, "); | |
141 | } | |
142 | if (IsOiaTWait(&oia)) { | |
143 | printf("terminal wait, "); | |
144 | } | |
145 | printf("are some bits from the OIA.\n"); | |
87f7c3b6 | 146 | } |
e99f17a9 GM |
147 | |
148 | conn.rc = conn.function_id = 0; | |
149 | conn.session_id = session_id; | |
150 | conn.event_queue_id = conn.input_queue_id = 0; | |
151 | conn.intercept_options = 0; | |
152 | if (api_connect_to_keyboard(&conn) == -1) { | |
153 | api_perror("api_connect_to_keyboard"); | |
154 | } else { | |
155 | if (conn.first_connection_identifier) { | |
156 | printf("First keyboard connection.\n"); | |
157 | } else { | |
158 | printf("Not first keyboard connection.\n"); | |
159 | } | |
160 | } | |
161 | ||
162 | disable.rc = disable.function_id = 0; | |
163 | disable.session_id = session_id; | |
164 | disable.connectors_task_id = 0; | |
165 | if (api_disable_input(&disable) == -1) { | |
166 | api_perror("api_disable_input"); | |
167 | } else { | |
168 | printf("Disabled.\n"); | |
169 | } | |
170 | ||
171 | wr.rc = wr.function_id = 0; | |
172 | wr.session_id = session_id; | |
173 | wr.connectors_task_id = 0; | |
174 | wr.options = OPTION_SINGLE_KEYSTROKE; | |
175 | wr.number_of_keys_sent = 0; | |
176 | wr.keystroke_specifier.keystroke_entry.scancode = 0x3a; | |
177 | wr.keystroke_specifier.keystroke_entry.shift_state = 0; | |
178 | if (api_write_keystroke(&wr) == -1) { | |
179 | api_perror("api_write_keystroke"); | |
180 | } else { | |
181 | if (wr.number_of_keys_sent != 1) { | |
182 | fprintf(stderr, | |
183 | "write_keystroke claims to have sent %d keystrokes.\n", | |
184 | wr.number_of_keys_sent); | |
185 | } else { | |
186 | printf("Keystroke sent.\n"); | |
187 | } | |
188 | } | |
189 | ||
190 | enable.rc = enable.function_id = 0; | |
191 | enable.session_id = session_id; | |
192 | enable.connectors_task_id = 0; | |
193 | if (api_enable_input(&enable) == -1) { | |
194 | api_perror("api_enable"); | |
195 | } else { | |
196 | printf("Enabled.\n"); | |
197 | } | |
198 | ||
199 | disc.rc = disc.function_id = 0; | |
200 | disc.session_id = session_id; | |
201 | disc.connectors_task_id = 0; | |
202 | if (api_disconnect_from_keyboard(&disc) == -1) { | |
203 | api_perror("api_disconnect_from_keyboard"); | |
204 | } else { | |
205 | printf("Disconnected from keyboard.\n"); | |
206 | } | |
207 | ||
208 | return 0; | |
87f7c3b6 | 209 | } |