forked from balabit/libtermcapparser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
puttyparser.cc
310 lines (251 loc) · 5.5 KB
/
puttyparser.cc
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
#include <stdlib.h>
#include "puttyparser.hh"
#include "putty/termcapparser.hh"
__BEGIN_DECLS
static int send_raw_mouse;
void fatal_message_box(void *window, char *msg)
{
fprintf(stderr, "%s\n", msg);
}
void fatalbox(char *p, ...)
{
va_list ap;
char *msg;
va_start(ap, p);
msg = dupvprintf(p, ap);
va_end(ap);
fatal_message_box(NULL, msg);
sfree(msg);
}
/* Dummy routine, only required in plink. */
void ldisc_update(void *frontend, int echo, int edit)
{
}
int from_backend(void *frontend, int is_stderr, const char *data, int len)
{
struct gui_data *inst = (struct gui_data *)frontend;
return term_data(inst->term, is_stderr, data, len);
}
/*
* Ask whether to wipe a session log file before writing to it.
* Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
*/
int askappend(void *frontend, Filename filename,
void (*callback)(void *ctx, int result), void *ctx)
{
return 2;
}
void logevent(void *frontend, const char *string)
{
}
/*
* Minimise or restore the window in response to a server-side
* request.
*/
void set_iconic(void *frontend, int iconic)
{
}
/*
* Move the window in response to a server-side request.
*/
void move_window(void *frontend, int x, int y)
{
}
/*
* Move the window to the top or bottom of the z-order in response
* to a server-side request.
*/
void set_zorder(void *frontend, int top)
{
}
/*
* Refresh the window in response to a server-side request.
*/
void refresh_window(void *frontend)
{
struct gui_data *inst = (struct gui_data *)frontend;
term_invalidate(inst->term);
}
/*
* Maximise or restore the window in response to a server-side
* request.
*/
void set_zoomed(void *frontend, int zoomed)
{
}
/*
* Report whether the window is iconic, for terminal reports.
*/
int is_iconic(void *frontend)
{
return 0;
}
/*
* Report the window's position, for terminal reports.
*/
void get_window_pos(void *frontend, int *x, int *y)
{
*x = *y = 0;
}
/*
* Report the window's pixel size, for terminal reports.
*/
void get_window_pixels(void *frontend, int *x, int *y)
{
*x = *y = 0;
}
/*
* Return the window or icon title.
*/
char *get_window_title(void *frontend, int icon)
{
struct gui_data *inst = (struct gui_data *)frontend;
return icon ? inst->icontitle : inst->wintitle;
}
static void update_mouseptr(struct gui_data *inst)
{
}
void frontend_keypress(void *handle)
{
}
void timer_change_notify(long next)
{
}
/*
* set or clear the "raw mouse message" mode
*/
void set_raw_mouse_mode(void *frontend, int activate)
{
struct gui_data *inst = (struct gui_data *)frontend;
activate = activate && !inst->cfg.no_mouse_rep;
send_raw_mouse = activate;
update_mouseptr(inst);
}
void request_resize(void *frontend, int w, int h)
{
}
void palette_set(void *frontend, int n, int r, int g, int b)
{
struct gui_data *inst = (struct gui_data *)frontend;
inst->parser->get_palette().set_color(n, r, g, b);
}
void palette_reset(void *frontend)
{
struct gui_data *inst = (struct gui_data *)frontend;
inst->parser->get_palette().reset();
}
void write_clip(void *frontend, wchar_t * data, int *attr, int len, int must_deselect)
{
}
void request_paste(void *frontend)
{
}
void get_clip(void *frontend, wchar_t ** p, int *len)
{
struct gui_data *inst = (struct gui_data *)frontend;
if (p)
{
*p = inst->pastein_data;
*len = inst->pastein_data_len;
}
}
void set_title(void *frontend, char *title)
{
struct gui_data *inst = (struct gui_data *)frontend;
strncpy(inst->wintitle, title, lenof(inst->wintitle));
inst->wintitle[lenof(inst->wintitle)-1] = '\0';
}
void set_icon(void *frontend, char *title)
{
struct gui_data *inst = (struct gui_data *)frontend;
strncpy(inst->icontitle, title, lenof(inst->icontitle));
inst->icontitle[lenof(inst->icontitle)-1] = '\0';
}
void set_sbar(void *frontend, int total, int start, int page)
{
}
void sys_cursor(void *frontend, int x, int y)
{
}
/*
* This is still called when mode==BELL_VISUAL, even though the
* visual bell is handled entirely within terminal.c, because we
* may want to perform additional actions on any kind of bell (for
* example, taskbar flashing in Windows).
*/
void do_beep(void *frontend, int mode)
{
}
int char_width(Context ctx, int uc)
{
return 1;
}
Context get_ctx(void *frontend)
{
return frontend;
}
void free_ctx(Context ctx)
{
}
void do_text(Context ctx, int x, int y, wchar_t *text, int len,
unsigned long attr, int lattr)
{
struct gui_data *inst = (struct gui_data *)ctx;
std::wstring str(text, len);
inst->parser->update_display(x, y, str, attr, lattr);
}
void do_cursor(Context ctx, int x, int y, wchar_t *text, int len,
unsigned long attr, int lattr)
{
}
void modalfatalbox(char *p, ...)
{
va_list ap;
fprintf(stderr, "FATAL ERROR: ");
va_start(ap, p);
vfprintf(stderr, p, ap);
va_end(ap);
fputc('\n', stderr);
exit(1);
}
/*
* dummies from uxprint.c
*/
printer_job *printer_start_job(char *printer)
{
return NULL;
}
void printer_job_data(printer_job *pj, void *data, int len)
{
}
void printer_finish_job(printer_job *pj)
{
}
/*
* dummies from logging.c
*/
/*
* Flush any open log file.
*/
void logflush(void *handle)
{
}
/*
* Log session traffic.
*/
void logtraffic(void *handle, unsigned char c, int logmode)
{
}
/*
* Get the number of lines in the scrollback.
*/
int sblines(Terminal *term)
{
int sblines = count234(term->scrollback);
if (term->cfg.erase_to_scrollback && term->alt_which && term->alt_screen)
{
sblines += term->alt_sblines;
}
return sblines;
}
__END_DECLS