GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libcurses/lib_keyname.c Lines: 0 38 0.0 %
Date: 2017-11-07 Branches: 0 38 0.0 %

Line Branch Exec Source
1
/* generated by MKkeyname.awk */
2
3
#include <curses.priv.h>
4
#include <tic.h>
5
#include <term_entry.h>
6
7
struct kn { short offset; int code; };
8
static const struct kn _nc_key_names[] = {
9
	{ 0, KEY_A1 },
10
	{ 7, KEY_A3 },
11
	{ 14, KEY_B2 },
12
	{ 21, KEY_BACKSPACE },
13
	{ 35, KEY_BEG },
14
	{ 43, KEY_BREAK },
15
	{ 53, KEY_BTAB },
16
	{ 62, KEY_C1 },
17
	{ 69, KEY_C3 },
18
	{ 76, KEY_CANCEL },
19
	{ 87, KEY_CATAB },
20
	{ 97, KEY_CLEAR },
21
	{ 107, KEY_CLOSE },
22
	{ 117, KEY_COMMAND },
23
	{ 129, KEY_COPY },
24
	{ 138, KEY_CREATE },
25
	{ 149, KEY_CTAB },
26
	{ 158, KEY_DC },
27
	{ 165, KEY_DL },
28
	{ 172, KEY_DOWN },
29
	{ 181, KEY_EIC },
30
	{ 189, KEY_END },
31
	{ 197, KEY_ENTER },
32
	{ 207, KEY_EOL },
33
	{ 215, KEY_EOS },
34
	{ 223, KEY_EXIT },
35
	{ 232, KEY_F(0) },
36
	{ 241, KEY_F(1) },
37
	{ 250, KEY_F(10) },
38
	{ 260, KEY_F(11) },
39
	{ 270, KEY_F(12) },
40
	{ 280, KEY_F(13) },
41
	{ 290, KEY_F(14) },
42
	{ 300, KEY_F(15) },
43
	{ 310, KEY_F(16) },
44
	{ 320, KEY_F(17) },
45
	{ 330, KEY_F(18) },
46
	{ 340, KEY_F(19) },
47
	{ 350, KEY_F(2) },
48
	{ 359, KEY_F(20) },
49
	{ 369, KEY_F(21) },
50
	{ 379, KEY_F(22) },
51
	{ 389, KEY_F(23) },
52
	{ 399, KEY_F(24) },
53
	{ 409, KEY_F(25) },
54
	{ 419, KEY_F(26) },
55
	{ 429, KEY_F(27) },
56
	{ 439, KEY_F(28) },
57
	{ 449, KEY_F(29) },
58
	{ 459, KEY_F(3) },
59
	{ 468, KEY_F(30) },
60
	{ 478, KEY_F(31) },
61
	{ 488, KEY_F(32) },
62
	{ 498, KEY_F(33) },
63
	{ 508, KEY_F(34) },
64
	{ 518, KEY_F(35) },
65
	{ 528, KEY_F(36) },
66
	{ 538, KEY_F(37) },
67
	{ 548, KEY_F(38) },
68
	{ 558, KEY_F(39) },
69
	{ 568, KEY_F(4) },
70
	{ 577, KEY_F(40) },
71
	{ 587, KEY_F(41) },
72
	{ 597, KEY_F(42) },
73
	{ 607, KEY_F(43) },
74
	{ 617, KEY_F(44) },
75
	{ 627, KEY_F(45) },
76
	{ 637, KEY_F(46) },
77
	{ 647, KEY_F(47) },
78
	{ 657, KEY_F(48) },
79
	{ 667, KEY_F(49) },
80
	{ 677, KEY_F(5) },
81
	{ 686, KEY_F(50) },
82
	{ 696, KEY_F(51) },
83
	{ 706, KEY_F(52) },
84
	{ 716, KEY_F(53) },
85
	{ 726, KEY_F(54) },
86
	{ 736, KEY_F(55) },
87
	{ 746, KEY_F(56) },
88
	{ 756, KEY_F(57) },
89
	{ 766, KEY_F(58) },
90
	{ 776, KEY_F(59) },
91
	{ 786, KEY_F(6) },
92
	{ 795, KEY_F(60) },
93
	{ 805, KEY_F(61) },
94
	{ 815, KEY_F(62) },
95
	{ 825, KEY_F(63) },
96
	{ 835, KEY_F(7) },
97
	{ 844, KEY_F(8) },
98
	{ 853, KEY_F(9) },
99
	{ 862, KEY_FIND },
100
	{ 871, KEY_HELP },
101
	{ 880, KEY_HOME },
102
	{ 889, KEY_IC },
103
	{ 896, KEY_IL },
104
	{ 903, KEY_LEFT },
105
	{ 912, KEY_LL },
106
	{ 919, KEY_MARK },
107
	{ 928, KEY_MESSAGE },
108
	{ 940, KEY_MOUSE },
109
	{ 950, KEY_MOVE },
110
	{ 959, KEY_NEXT },
111
	{ 968, KEY_NPAGE },
112
	{ 978, KEY_OPEN },
113
	{ 987, KEY_OPTIONS },
114
	{ 999, KEY_PPAGE },
115
	{ 1009, KEY_PREVIOUS },
116
	{ 1022, KEY_PRINT },
117
	{ 1032, KEY_REDO },
118
	{ 1041, KEY_REFERENCE },
119
	{ 1055, KEY_REFRESH },
120
	{ 1067, KEY_REPLACE },
121
	{ 1079, KEY_RESET },
122
	{ 1089, KEY_RESIZE },
123
	{ 1100, KEY_RESTART },
124
	{ 1112, KEY_RESUME },
125
	{ 1123, KEY_RIGHT },
126
	{ 1133, KEY_SAVE },
127
	{ 1142, KEY_SBEG },
128
	{ 1151, KEY_SCANCEL },
129
	{ 1163, KEY_SCOMMAND },
130
	{ 1176, KEY_SCOPY },
131
	{ 1186, KEY_SCREATE },
132
	{ 1198, KEY_SDC },
133
	{ 1206, KEY_SDL },
134
	{ 1214, KEY_SELECT },
135
	{ 1225, KEY_SEND },
136
	{ 1234, KEY_SEOL },
137
	{ 1243, KEY_SEXIT },
138
	{ 1253, KEY_SF },
139
	{ 1260, KEY_SFIND },
140
	{ 1270, KEY_SHELP },
141
	{ 1280, KEY_SHOME },
142
	{ 1290, KEY_SIC },
143
	{ 1298, KEY_SLEFT },
144
	{ 1308, KEY_SMESSAGE },
145
	{ 1321, KEY_SMOVE },
146
	{ 1331, KEY_SNEXT },
147
	{ 1341, KEY_SOPTIONS },
148
	{ 1354, KEY_SPREVIOUS },
149
	{ 1368, KEY_SPRINT },
150
	{ 1379, KEY_SR },
151
	{ 1386, KEY_SREDO },
152
	{ 1396, KEY_SREPLACE },
153
	{ 1409, KEY_SRESET },
154
	{ 1420, KEY_SRIGHT },
155
	{ 1431, KEY_SRSUME },
156
	{ 1442, KEY_SSAVE },
157
	{ 1452, KEY_SSUSPEND },
158
	{ 1465, KEY_STAB },
159
	{ 1474, KEY_SUNDO },
160
	{ 1484, KEY_SUSPEND },
161
	{ 1496, KEY_UNDO },
162
	{ 1505, KEY_UP },
163
	{ -1, 0 }};
164
165
static const char key_names[] =
166
	"KEY_A1\0"
167
	"KEY_A3\0"
168
	"KEY_B2\0"
169
	"KEY_BACKSPACE\0"
170
	"KEY_BEG\0"
171
	"KEY_BREAK\0"
172
	"KEY_BTAB\0"
173
	"KEY_C1\0"
174
	"KEY_C3\0"
175
	"KEY_CANCEL\0"
176
	"KEY_CATAB\0"
177
	"KEY_CLEAR\0"
178
	"KEY_CLOSE\0"
179
	"KEY_COMMAND\0"
180
	"KEY_COPY\0"
181
	"KEY_CREATE\0"
182
	"KEY_CTAB\0"
183
	"KEY_DC\0"
184
	"KEY_DL\0"
185
	"KEY_DOWN\0"
186
	"KEY_EIC\0"
187
	"KEY_END\0"
188
	"KEY_ENTER\0"
189
	"KEY_EOL\0"
190
	"KEY_EOS\0"
191
	"KEY_EXIT\0"
192
	"KEY_F(0)\0"
193
	"KEY_F(1)\0"
194
	"KEY_F(10)\0"
195
	"KEY_F(11)\0"
196
	"KEY_F(12)\0"
197
	"KEY_F(13)\0"
198
	"KEY_F(14)\0"
199
	"KEY_F(15)\0"
200
	"KEY_F(16)\0"
201
	"KEY_F(17)\0"
202
	"KEY_F(18)\0"
203
	"KEY_F(19)\0"
204
	"KEY_F(2)\0"
205
	"KEY_F(20)\0"
206
	"KEY_F(21)\0"
207
	"KEY_F(22)\0"
208
	"KEY_F(23)\0"
209
	"KEY_F(24)\0"
210
	"KEY_F(25)\0"
211
	"KEY_F(26)\0"
212
	"KEY_F(27)\0"
213
	"KEY_F(28)\0"
214
	"KEY_F(29)\0"
215
	"KEY_F(3)\0"
216
	"KEY_F(30)\0"
217
	"KEY_F(31)\0"
218
	"KEY_F(32)\0"
219
	"KEY_F(33)\0"
220
	"KEY_F(34)\0"
221
	"KEY_F(35)\0"
222
	"KEY_F(36)\0"
223
	"KEY_F(37)\0"
224
	"KEY_F(38)\0"
225
	"KEY_F(39)\0"
226
	"KEY_F(4)\0"
227
	"KEY_F(40)\0"
228
	"KEY_F(41)\0"
229
	"KEY_F(42)\0"
230
	"KEY_F(43)\0"
231
	"KEY_F(44)\0"
232
	"KEY_F(45)\0"
233
	"KEY_F(46)\0"
234
	"KEY_F(47)\0"
235
	"KEY_F(48)\0"
236
	"KEY_F(49)\0"
237
	"KEY_F(5)\0"
238
	"KEY_F(50)\0"
239
	"KEY_F(51)\0"
240
	"KEY_F(52)\0"
241
	"KEY_F(53)\0"
242
	"KEY_F(54)\0"
243
	"KEY_F(55)\0"
244
	"KEY_F(56)\0"
245
	"KEY_F(57)\0"
246
	"KEY_F(58)\0"
247
	"KEY_F(59)\0"
248
	"KEY_F(6)\0"
249
	"KEY_F(60)\0"
250
	"KEY_F(61)\0"
251
	"KEY_F(62)\0"
252
	"KEY_F(63)\0"
253
	"KEY_F(7)\0"
254
	"KEY_F(8)\0"
255
	"KEY_F(9)\0"
256
	"KEY_FIND\0"
257
	"KEY_HELP\0"
258
	"KEY_HOME\0"
259
	"KEY_IC\0"
260
	"KEY_IL\0"
261
	"KEY_LEFT\0"
262
	"KEY_LL\0"
263
	"KEY_MARK\0"
264
	"KEY_MESSAGE\0"
265
	"KEY_MOUSE\0"
266
	"KEY_MOVE\0"
267
	"KEY_NEXT\0"
268
	"KEY_NPAGE\0"
269
	"KEY_OPEN\0"
270
	"KEY_OPTIONS\0"
271
	"KEY_PPAGE\0"
272
	"KEY_PREVIOUS\0"
273
	"KEY_PRINT\0"
274
	"KEY_REDO\0"
275
	"KEY_REFERENCE\0"
276
	"KEY_REFRESH\0"
277
	"KEY_REPLACE\0"
278
	"KEY_RESET\0"
279
	"KEY_RESIZE\0"
280
	"KEY_RESTART\0"
281
	"KEY_RESUME\0"
282
	"KEY_RIGHT\0"
283
	"KEY_SAVE\0"
284
	"KEY_SBEG\0"
285
	"KEY_SCANCEL\0"
286
	"KEY_SCOMMAND\0"
287
	"KEY_SCOPY\0"
288
	"KEY_SCREATE\0"
289
	"KEY_SDC\0"
290
	"KEY_SDL\0"
291
	"KEY_SELECT\0"
292
	"KEY_SEND\0"
293
	"KEY_SEOL\0"
294
	"KEY_SEXIT\0"
295
	"KEY_SF\0"
296
	"KEY_SFIND\0"
297
	"KEY_SHELP\0"
298
	"KEY_SHOME\0"
299
	"KEY_SIC\0"
300
	"KEY_SLEFT\0"
301
	"KEY_SMESSAGE\0"
302
	"KEY_SMOVE\0"
303
	"KEY_SNEXT\0"
304
	"KEY_SOPTIONS\0"
305
	"KEY_SPREVIOUS\0"
306
	"KEY_SPRINT\0"
307
	"KEY_SR\0"
308
	"KEY_SREDO\0"
309
	"KEY_SREPLACE\0"
310
	"KEY_SRESET\0"
311
	"KEY_SRIGHT\0"
312
	"KEY_SRSUME\0"
313
	"KEY_SSAVE\0"
314
	"KEY_SSUSPEND\0"
315
	"KEY_STAB\0"
316
	"KEY_SUNDO\0"
317
	"KEY_SUSPEND\0"
318
	"KEY_UNDO\0"
319
	"KEY_UP\0";
320
321
#define SIZEOF_TABLE 256
322
#define MyTable _nc_globals.keyname_table
323
324
NCURSES_EXPORT(NCURSES_CONST char *) _nc_keyname (SCREEN *sp, int c)
325
{
326
	int i;
327
	char name[20];
328
	char *p;
329
	size_t psize;
330
	NCURSES_CONST char *result = 0;
331
332
	if (c == -1) {
333
		result = "-1";
334
	} else {
335
		for (i = 0; _nc_key_names[i].offset != -1; i++) {
336
			if (_nc_key_names[i].code == c) {
337
				result = (NCURSES_CONST char *)key_names + _nc_key_names[i].offset;
338
				break;
339
			}
340
		}
341
342
		if (result == 0 && (c >= 0 && c < SIZEOF_TABLE)) {
343
			if (MyTable == 0)
344
				MyTable = typeCalloc(char *, SIZEOF_TABLE);
345
			if (MyTable != 0) {
346
				if (MyTable[c] == 0) {
347
					int cc = c;
348
					p = name;
349
					psize = sizeof(name);
350
					if (cc >= 128 && (sp == 0 || sp->_use_meta)) {
351
						strlcpy(p, "M-", psize);
352
						p += 2;
353
						psize -= 2;
354
						cc -= 128;
355
					}
356
					if (cc < 32)
357
						snprintf(p, psize, "^%c", cc + '@');
358
					else if (cc == 127)
359
						strlcpy(p, "^?", psize);
360
					else
361
						snprintf(p, psize, "%c", cc);
362
					MyTable[c] = strdup(name);
363
				}
364
				result = MyTable[c];
365
			}
366
#if NCURSES_EXT_FUNCS && NCURSES_XNAMES
367
		} else if (result == 0 && cur_term != 0) {
368
			int j, k;
369
			char * bound;
370
			TERMTYPE *tp = &(cur_term->type);
371
			int save_trace = _nc_tracing;
372
373
			_nc_tracing = 0;	/* prevent recursion via keybound() */
374
			for (j = 0; (bound = keybound(c, j)) != 0; ++j) {
375
				for(k = STRCOUNT; k < (int) NUM_STRINGS(tp);  k++) {
376
					if (tp->Strings[k] != 0 && !strcmp(bound, tp->Strings[k])) {
377
						result = ExtStrname(tp, k, strnames);
378
						break;
379
					}
380
				}
381
				free(bound);
382
				if (result != 0)
383
					break;
384
			}
385
			_nc_tracing = save_trace;
386
#endif
387
		}
388
	}
389
	return result;
390
}
391
392
NCURSES_EXPORT(NCURSES_CONST char *) keyname (int c)
393
{
394
	return _nc_keyname(SP, c);
395
}
396
397
#if NO_LEAKS
398
void _nc_keyname_leaks(void)
399
{
400
	int j;
401
	if (MyTable != 0) {
402
		for (j = 0; j < SIZEOF_TABLE; ++j) {
403
			FreeIfNeeded(MyTable[j]);
404
		}
405
		FreeAndNull(MyTable);
406
	}
407
}
408
#endif /* NO_LEAKS */