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