xref: /openbsd/regress/lib/libedit/read/glue.c (revision 09467b48)
1 /*	$OpenBSD: glue.c,v 1.4 2017/07/05 15:31:45 bluhm Exp $	*/
2 /*
3  * Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 /*
19  * Glue for unit tests of libedit/read.c.
20  * Rather than linking in all the various libedit modules,
21  * provide dummies for those functions called in read.c.
22  */
23 
24 #define EL EditLine *el __attribute__((__unused__))
25 #define UU __attribute__((__unused__))
26 
27 int ch_enlargebufs(EL, size_t addlen UU) { return 1; }
28 void ch_reset(EL) { }
29 void el_resize(EL) { }
30 int el_set(EL, int op UU, ...) { return 0; }
31 int el_wset(EL, int op UU, ...) { return 0; }
32 void re_clear_display(EL) { }
33 void re_clear_lines(EL) { }
34 void re_refresh(EL) { }
35 void re_refresh_cursor(EL) { }
36 void sig_clr(EL) { }
37 void sig_set(EL) { }
38 void terminal__flush(EL) { }
39 void terminal_beep(EL) { }
40 int tty_cookedmode(EL) { return 0; }
41 int tty_rawmode(EL) { return 0; }
42 
43 int
44 keymacro_get(EL, wchar_t *ch, keymacro_value_t *val)
45 {
46 	static wchar_t value[] = L"ic";
47 
48 	switch (*ch) {
49 	case L'c':
50 		val->cmd = ED_COMMAND;
51 		return XK_CMD;
52 	case L's':
53 		val->str = value;
54 		return XK_STR;
55 	default:
56 		val->str = NULL;
57 		*ch = '\0';
58 		return XK_STR;
59 	}
60 }
61 
62 #undef EL
63 #undef UU
64