Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libcurses/slave - add support for getparyx and get...
details: https://anonhg.NetBSD.org/src/rev/a2abb587c3f6
branches: trunk
changeset: 769582:a2abb587c3f6
user: blymn <blymn%NetBSD.org@localhost>
date: Thu Sep 15 11:46:19 2011 +0000
description:
- add support for getparyx and getyx calls
- allow a NULL pointer to be returned to the director
- add support for passing back a single chtype character
- fix some indentation
- fix a lot of curses command calls that were just plain wrong
- don't try to allocate storage for a NULL parameter, it doesn't need it
diffstat:
tests/lib/libcurses/slave/command_table.h | 4 +-
tests/lib/libcurses/slave/commands.c | 23 ++++-
tests/lib/libcurses/slave/curses_commands.c | 132 ++++++++++++++++++---------
tests/lib/libcurses/slave/curses_commands.h | 4 +-
tests/lib/libcurses/slave/slave.c | 13 +-
tests/lib/libcurses/slave/slave.h | 3 +-
6 files changed, 120 insertions(+), 59 deletions(-)
diffs (truncated from 474 to 300 lines):
diff -r 4a863f3619a3 -r a2abb587c3f6 tests/lib/libcurses/slave/command_table.h
--- a/tests/lib/libcurses/slave/command_table.h Thu Sep 15 11:36:43 2011 +0000
+++ b/tests/lib/libcurses/slave/command_table.h Thu Sep 15 11:46:19 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: command_table.h,v 1.2 2011/04/11 09:02:02 blymn Exp $ */
+/* $NetBSD: command_table.h,v 1.3 2011/09/15 11:46:19 blymn Exp $ */
/*-
* Copyright 2009 Brett Lymn <blymn%NetBSD.org@localhost>
@@ -143,12 +143,14 @@
{"getbkgd", cmd_getbkgd},
{"getcury", cmd_getcury},
{"getcurx", cmd_getcurx},
+ {"getyx", cmd_getyx},
{"getbegy", cmd_getbegy},
{"getbegx", cmd_getbegx},
{"getmaxy", cmd_getmaxy},
{"getmaxx", cmd_getmaxx},
{"getpary", cmd_getpary},
{"getparx", cmd_getparx},
+ {"getparyx", cmd_getparyx},
{"gettmode", cmd_gettmode},
{"getwin", cmd_getwin},
{"halfdelay", cmd_halfdelay},
diff -r 4a863f3619a3 -r a2abb587c3f6 tests/lib/libcurses/slave/commands.c
--- a/tests/lib/libcurses/slave/commands.c Thu Sep 15 11:36:43 2011 +0000
+++ b/tests/lib/libcurses/slave/commands.c Thu Sep 15 11:46:19 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: commands.c,v 1.3 2011/06/11 18:03:18 christos Exp $ */
+/* $NetBSD: commands.c,v 1.4 2011/09/15 11:46:19 blymn Exp $ */
/*-
* Copyright 2009 Brett Lymn <blymn%NetBSD.org@localhost>
@@ -76,7 +76,10 @@
{
char *string;
- asprintf(&string, "%p", ptr);
+ if (ptr == NULL)
+ asprintf(&string, "NULL");
+ else
+ asprintf(&string, "%p", ptr);
report_status(string);
free(string);
}
@@ -181,6 +184,19 @@
* Report a string of chtype back to the director via the command pipe.
*/
void
+report_byte(chtype c)
+{
+ chtype string[2];
+
+ string[0] = c;
+ string[1] = A_NORMAL | '\0';
+ report_nstr(string);
+}
+
+/*
+ * Report a string of chtype back to the director via the command pipe.
+ */
+void
report_nstr(chtype *string)
{
int len, type;
@@ -193,6 +209,9 @@
len++;
}
+ len++; /* add in the termination chtype */
+ len *= sizeof(chtype);
+
type = ret_byte;
if (write(slvpipe[WRITE_PIPE], &type, sizeof(int)) < 0)
err(1, "%s: command pipe write for status type failed",
diff -r 4a863f3619a3 -r a2abb587c3f6 tests/lib/libcurses/slave/curses_commands.c
--- a/tests/lib/libcurses/slave/curses_commands.c Thu Sep 15 11:36:43 2011 +0000
+++ b/tests/lib/libcurses/slave/curses_commands.c Thu Sep 15 11:46:19 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: curses_commands.c,v 1.5 2011/08/29 12:46:03 christos Exp $ */
+/* $NetBSD: curses_commands.c,v 1.6 2011/09/15 11:46:19 blymn Exp $ */
/*-
* Copyright 2009 Brett Lymn <blymn%NetBSD.org@localhost>
@@ -209,13 +209,13 @@
if (sscanf(args[0], "%d", &attrib) == 0) {
report_count(1);
- report_error("BAD ARGUMENT");
+ report_error("BAD ARGUMENT");
return;
}
if (sscanf(args[1], "%hd", &pair) == 0) {
report_count(1);
- report_error("BAD ARGUMENT");
+ report_error("BAD ARGUMENT");
return;
}
@@ -525,7 +525,7 @@
report_count(1);
- report_int(inch());
+ report_byte(inch());
}
@@ -563,7 +563,7 @@
{
chtype string[256];
- if (check_arg_count(nargs, 1) == 1)
+ if (check_arg_count(nargs, 0) == 1)
return;
/* XXX call2 */
@@ -596,7 +596,7 @@
/* XXX call2 */
report_count(2);
- report_return(innstr(string, limit));
+ report_int(innstr(string, limit));
report_status(string);
free(string);
}
@@ -648,7 +648,7 @@
{
char string[256];
- if (check_arg_count(nargs, 1) == 1)
+ if (check_arg_count(nargs, 0) == 1)
return;
/* XXX call2 */
@@ -882,6 +882,7 @@
cmd_mvaddch(int nargs, char **args)
{
int y, x;
+ chtype *ch;
if (check_arg_count(nargs, 3) == 1)
return;
@@ -898,8 +899,9 @@
return;
}
- report_count(1);
- report_return(mvaddch(y, x, args[2][0]));
+ ch = (chtype *) args[2];
+ report_count(1);
+ report_return(mvaddch(y, x, ch[0]));
}
@@ -1791,7 +1793,7 @@
return;
report_count(1);
- report_int(beep());
+ report_return(beep());
}
@@ -2179,14 +2181,14 @@
return;
report_count(1);
- report_return(erasechar());
+ report_int(erasechar());
}
void
cmd_flash(int nargs, char **args)
{
- if (check_arg_count(nargs, 1) == 0)
+ if (check_arg_count(nargs, 0) == 1)
return;
report_count(1);
@@ -2280,7 +2282,7 @@
}
report_count(1);
- report_int(getbkgd(win));
+ report_byte(getbkgd(win));
}
@@ -2323,6 +2325,28 @@
void
+cmd_getyx(int nargs, char **args)
+{
+ WINDOW *win;
+ int y, x;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ getyx(win, y, x);
+ report_count(2);
+ report_int(y);
+ report_int(x);
+}
+
+
+void
cmd_getbegy(int nargs, char **args)
{
WINDOW *win;
@@ -2437,6 +2461,28 @@
void
+cmd_getparyx(int nargs, char **args)
+{
+ WINDOW *win;
+ int y, x;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(2);
+ getparyx(win, y, x);
+ report_int(y);
+ report_int(x);
+}
+
+
+void
cmd_gettmode(int nargs, char **args)
{
if (check_arg_count(nargs, 0) == 1)
@@ -2522,16 +2568,13 @@
void
cmd_hline(int nargs, char **args)
{
- int ch, count;
+ int count;
+ chtype *ch;
if (check_arg_count(nargs, 2) == 1)
return;
- if (sscanf(args[0], "%d", &ch) == 0) {
- report_count(1);
- report_error("BAD ARGUMENT");
- return;
- }
+ ch = (chtype *) args[0];
if (sscanf(args[1], "%d", &count) == 0) {
report_count(1);
@@ -2540,7 +2583,7 @@
}
report_count(1);
- report_return(hline(ch, count));
+ report_return(hline(ch[0], count));
}
@@ -2811,7 +2854,7 @@
void
cmd_keyname(int nargs, char **args)
{
- int key;
+ unsigned int key;
if (check_arg_count(nargs, 1) == 1)
return;
@@ -3529,13 +3572,13 @@
return;
}
- if (sscanf(args[0], "%d", &begin_y) == 0) {
- report_count(1);
- report_error("BAD ARGUMENT");
- return;
- }
-
- if (sscanf(args[1], "%d", &begin_x) == 0) {
+ if (sscanf(args[2], "%d", &begin_y) == 0) {
+ report_count(1);
Home |
Main Index |
Thread Index |
Old Index