summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/lib/libcurses
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/netbsd-tests/lib/libcurses')
-rw-r--r--contrib/netbsd-tests/lib/libcurses/atf.terminfo44
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/addch.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/addchstr.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/addstr.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/attributes.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/background1.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/background2.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/background3.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/background4.chk6
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/background5.chk3
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/bell.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/box_standout.chk5
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/chgat1.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/chgat2.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/chgat3.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/clear1.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/clear10.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/clear2.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/clear3.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/clear4.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/clear5.chk23
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/clear6.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/clear7.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/clear8.chk6
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/clear9.chk6
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/color_blank_draw.chk24
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/color_blue_back.chk24
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/color_default.chk24
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/color_red_fore.chk24
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/color_set.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/color_start.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/copywin1.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/copywin10.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/copywin11.chk4
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/copywin12.chk4
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/copywin13.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/copywin14.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/copywin2.chk6
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/copywin3.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/copywin4.chk6
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/copywin5.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/copywin6.chk6
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/copywin7.chk6
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/copywin8.chk4
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/copywin9.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/curs_set1.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/curs_set2.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/curs_set3.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/curses_start.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/fill.chk23
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/home.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/timeout.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/wborder.chk6
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/wborder_refresh.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/wgetstr.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/wgetstr_refresh.chk2
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/window.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/wprintw_refresh.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/wscrl1.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/check_files/wscrl2.chk1
-rw-r--r--contrib/netbsd-tests/lib/libcurses/director/director.c279
-rw-r--r--contrib/netbsd-tests/lib/libcurses/director/returns.h66
-rw-r--r--contrib/netbsd-tests/lib/libcurses/director/testlang_conf.l437
-rw-r--r--contrib/netbsd-tests/lib/libcurses/director/testlang_parse.y1617
-rw-r--r--contrib/netbsd-tests/lib/libcurses/slave/command_table.h397
-rw-r--r--contrib/netbsd-tests/lib/libcurses/slave/commands.c243
-rw-r--r--contrib/netbsd-tests/lib/libcurses/slave/curses_commands.c7165
-rw-r--r--contrib/netbsd-tests/lib/libcurses/slave/curses_commands.h422
-rw-r--r--contrib/netbsd-tests/lib/libcurses/slave/slave.c177
-rw-r--r--contrib/netbsd-tests/lib/libcurses/slave/slave.h50
-rwxr-xr-xcontrib/netbsd-tests/lib/libcurses/t_curses.sh294
-rw-r--r--contrib/netbsd-tests/lib/libcurses/testframe.txt241
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/addch4
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/addchnstr5
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/addchstr4
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/addnstr5
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/addstr4
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/assume_default_colors19
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/attributes23
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/background23
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/beep5
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/box8
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/can_change_color3
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/cbreak18
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/chgat15
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/clear57
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/color_content12
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/color_set11
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/copywin81
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/curs_set7
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/fill_screen29
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/getch3
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/getstr6
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/mvwin12
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/start3
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/start_color5
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/std_defines138
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/termattrs3
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/timeout21
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/wborder6
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/window2
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/window_create4
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/wprintw6
-rw-r--r--contrib/netbsd-tests/lib/libcurses/tests/wscrl11
104 files changed, 12236 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/lib/libcurses/atf.terminfo b/contrib/netbsd-tests/lib/libcurses/atf.terminfo
new file mode 100644
index 0000000..fcd34b6
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/atf.terminfo
@@ -0,0 +1,44 @@
+# Based on xterm capabilities
+atf|atf automatic test frame pseudo terminal,
+ am, bce, ccc, km, mc5i, mir, msgr, npc, xenl,
+ colors#8, cols#80, it#8, lines#24, pairs#64,
+ acsc=++\,\,--..00``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
+ bel=bel, blink=blink, bold=bold, cbt=cbt, civis=civis, clear=clear,
+ cnorm=cnorm, cr=^M, csr=csr%i%p1%d;%p2%dX, cub=cub%p1%dX,
+ cub1=^H, cud=cud%p1%dX, cud1=^J, cuf=cuf%p1%dX, cuf1=,
+ cup=cup%i%p1%d;%p2%dX, cuu=cuu%p1%dX, cuu1=, cvvis=cvvis,
+ dch=dch%p1%dX, dch1=, dl=dl%p1%dX, dl1= , dim=dim, ech=ech%p1%dX,
+ ed=ed, el=el, el1=el1, enacs=enacs, flash=flash, home=home,
+ hpa=hpa%i%p1%dX, ht=^I, hts=hts, ich=ich%p1%dX, il=il%p1%dX,
+ il1=il1, ind=^M, indn=indn%p1%dX, invis=invis,
+ is2=is2, kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H,
+ kIC=\E[2;2~, kLFT=\E[1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~,
+ kRIT=\E[1;2C, kb2=\EOE, kbs=^H, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB,
+ kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kend=\EOF, kent=\EOM,
+ kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[1;2P,
+ kf14=\E[1;2Q, kf15=\E[1;2R, kf16=\E[1;2S, kf17=\E[15;2~,
+ kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~,
+ kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~,
+ kf25=\E[1;5P, kf26=\E[1;5Q, kf27=\E[1;5R, kf28=\E[1;5S,
+ kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~,
+ kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~,
+ kf36=\E[24;5~, kf37=\E[1;6P, kf38=\E[1;6Q, kf39=\E[1;6R, kf4=\EOS,
+ kf40=\E[1;6S, kf41=\E[15;6~, kf42=\E[17;6~, kf43=\E[18;6~,
+ kf44=\E[19;6~, kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~,
+ kf48=\E[24;6~, kf49=\E[1;3P, kf5=\E[15~, kf50=\E[1;3Q,
+ kf51=\E[1;3R, kf52=\E[1;3S, kf53=\E[15;3~, kf54=\E[17;3~,
+ kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~, kf58=\E[21;3~,
+ kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, kf61=\E[1;4P,
+ kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
+ khome=\EOH, kich1=\E[2~, kind=\E[1;2B, kmous=\E[M, knp=\E[6~,
+ kpp=\E[5~, kri=\E[1;2A, mc0=mc0, mc4=mc4, mc5=mc5,
+ op=op, rc=rc, rev=rev, ri=ri, rin=rin%p1%dX, rmacs=rmacs,
+ rmam=rmam, rmcup=rmcup, rmir=rmir, rmkx=rmkx,
+ rmm=rmm, rmso=rmso, rmul=rmul, rs1=rs1,
+ rs2=rs2, sc=sc, setab=setab%p1%dX,
+ setaf=setaf%p1%dX, setb=setb%p1%dX, setf=setf%p1%dX,
+ sgr=sgr%p1%d;%p2%d;%p3%d;%p4%d;%p5%d;%p6%d;%p7%d;%p8;%d;%p9%dX,
+ sgr0=sgr0, smacs=smacs, smam=smam, smcup=smcup,
+ smir=smir, smkx=smkx, smm=smm, smso=smso, smul=smul,
+ tbc=tbc, u6=u6%d;%dX, u7=u7, u8=u8, u9=u9,
+ vpa=vpa%p1%dX
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/addch.chk b/contrib/netbsd-tests/lib/libcurses/check_files/addch.chk
new file mode 100644
index 0000000..3e2c6bb
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/addch.chk
@@ -0,0 +1 @@
+smsotrmso \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/addchstr.chk b/contrib/netbsd-tests/lib/libcurses/check_files/addchstr.chk
new file mode 100644
index 0000000..42286d0
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/addchstr.chk
@@ -0,0 +1 @@
+revabcdehomesgr0 \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/addstr.chk b/contrib/netbsd-tests/lib/libcurses/check_files/addstr.chk
new file mode 100644
index 0000000..6a81654
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/addstr.chk
@@ -0,0 +1 @@
+abcde \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/attributes.chk b/contrib/netbsd-tests/lib/libcurses/check_files/attributes.chk
new file mode 100644
index 0000000..be35b56
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/attributes.chk
@@ -0,0 +1 @@
+smsoblinkhellormsosgr0 \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/background1.chk b/contrib/netbsd-tests/lib/libcurses/check_files/background1.chk
new file mode 100644
index 0000000..e52e439
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/background1.chk
@@ -0,0 +1 @@
+smulAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup2;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup3;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup4;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup5;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup6;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup7;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup8;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup9;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup10;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup11;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup12;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup13;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup14;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup15;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup16;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup17;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup18;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup19;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup20;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup21;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup22;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup23;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup24;1XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcup1;1Xrmul \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/background2.chk b/contrib/netbsd-tests/lib/libcurses/check_files/background2.chk
new file mode 100644
index 0000000..55a2163
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/background2.chk
@@ -0,0 +1 @@
+smula test stringrmul \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/background3.chk b/contrib/netbsd-tests/lib/libcurses/check_files/background3.chk
new file mode 100644
index 0000000..732f4cc
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/background3.chk
@@ -0,0 +1 @@
+cup3;6X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/background4.chk b/contrib/netbsd-tests/lib/libcurses/check_files/background4.chk
new file mode 100644
index 0000000..05698e2
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/background4.chk
@@ -0,0 +1,6 @@
+cup1;14Xcup3;6Xrevwindow
+B1BBBB
+BBBBBB
+BBBBBB
+BBBBBB
+BBBBBBcup4;8Xsgr0 \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/background5.chk b/contrib/netbsd-tests/lib/libcurses/check_files/background5.chk
new file mode 100644
index 0000000..6c37975
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/background5.chk
@@ -0,0 +1,3 @@
+cup1;14Xcup4;8Xrevhell
+o worl
+dsgr0 \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/bell.chk b/contrib/netbsd-tests/lib/libcurses/check_files/bell.chk
new file mode 100644
index 0000000..f4d3c21
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/bell.chk
@@ -0,0 +1 @@
+bel \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/box_standout.chk b/contrib/netbsd-tests/lib/libcurses/check_files/box_standout.chk
new file mode 100644
index 0000000..5bd91e1
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/box_standout.chk
@@ -0,0 +1,5 @@
+revsmacsqqqqrmacs
+sgr0smsosmacsxrmacssmacsxrmacs
+smacsxrmacssmacsxrmacs
+smacsxrmacssmacsxrmacs
+smacsxrmacssmacsxrmacscup8;7Xrmsorevsmacsqqqqrmacscup3;6Xsgr0 \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/chgat1.chk b/contrib/netbsd-tests/lib/libcurses/check_files/chgat1.chk
new file mode 100644
index 0000000..e9b8b58
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/chgat1.chk
@@ -0,0 +1 @@
+setaf7Xsetab0Xdsetaf3Xsetab6Xrev homesgr0 \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/chgat2.chk b/contrib/netbsd-tests/lib/libcurses/check_files/chgat2.chk
new file mode 100644
index 0000000..cadfb37
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/chgat2.chk
@@ -0,0 +1 @@
+setaf7Xsetab0Xeop \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/chgat3.chk b/contrib/netbsd-tests/lib/libcurses/check_files/chgat3.chk
new file mode 100644
index 0000000..7d57a90
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/chgat3.chk
@@ -0,0 +1 @@
+homesetaf3Xsetab6Xsmulde cup1;1Xrmulop \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/clear1.chk b/contrib/netbsd-tests/lib/libcurses/check_files/clear1.chk
new file mode 100644
index 0000000..9c7d34f
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/clear1.chk
@@ -0,0 +1 @@
+clear \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/clear10.chk b/contrib/netbsd-tests/lib/libcurses/check_files/clear10.chk
new file mode 100644
index 0000000..1baa2a5
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/clear10.chk
@@ -0,0 +1 @@
+cup7;7X EEEEE \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/clear2.chk b/contrib/netbsd-tests/lib/libcurses/check_files/clear2.chk
new file mode 100644
index 0000000..f25000b
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/clear2.chk
@@ -0,0 +1 @@
+cup6;6Xabcdecup21;6Xfghijcup11;6X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/clear3.chk b/contrib/netbsd-tests/lib/libcurses/check_files/clear3.chk
new file mode 100644
index 0000000..dfdd90d
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/clear3.chk
@@ -0,0 +1 @@
+cup21;6Xelcup11;6X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/clear4.chk b/contrib/netbsd-tests/lib/libcurses/check_files/clear4.chk
new file mode 100644
index 0000000..abe5be8
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/clear4.chk
@@ -0,0 +1 @@
+elhome \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/clear5.chk b/contrib/netbsd-tests/lib/libcurses/check_files/clear5.chk
new file mode 100644
index 0000000..d9df62d
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/clear5.chk
@@ -0,0 +1,23 @@
+homeel
+el
+el
+el
+el
+el
+el
+el
+el
+el
+el
+el
+el
+el
+el
+el
+el
+el
+el
+el
+el
+el
+elhome \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/clear6.chk b/contrib/netbsd-tests/lib/libcurses/check_files/clear6.chk
new file mode 100644
index 0000000..ff815d3
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/clear6.chk
@@ -0,0 +1 @@
+abccup7;7Xefgcup4;6X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/clear7.chk b/contrib/netbsd-tests/lib/libcurses/check_files/clear7.chk
new file mode 100644
index 0000000..8b392c3
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/clear7.chk
@@ -0,0 +1 @@
+cup7;7Xelcup4;6X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/clear8.chk b/contrib/netbsd-tests/lib/libcurses/check_files/clear8.chk
new file mode 100644
index 0000000..9c9354e
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/clear8.chk
@@ -0,0 +1,6 @@
+cup4;6X
+EEEEE
+EEEEE
+EEEEE
+EEEEE
+EEEEE cup3;6X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/clear9.chk b/contrib/netbsd-tests/lib/libcurses/check_files/clear9.chk
new file mode 100644
index 0000000..c5834a1
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/clear9.chk
@@ -0,0 +1,6 @@
+cup3;6X
+EEEEE
+EEEEE
+EEEEE
+EEEEE
+EEEEE cup3;6X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/color_blank_draw.chk b/contrib/netbsd-tests/lib/libcurses/check_files/color_blank_draw.chk
new file mode 100644
index 0000000..42ad0e2
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/color_blank_draw.chk
@@ -0,0 +1,24 @@
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xel
+opsetaf7Xsetab0Xelhomeop \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/color_blue_back.chk b/contrib/netbsd-tests/lib/libcurses/check_files/color_blue_back.chk
new file mode 100644
index 0000000..5c02e4d
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/color_blue_back.chk
@@ -0,0 +1,24 @@
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xel
+opopsetab4Xelhome \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/color_default.chk b/contrib/netbsd-tests/lib/libcurses/check_files/color_default.chk
new file mode 100644
index 0000000..d23ddaf
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/color_default.chk
@@ -0,0 +1,24 @@
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopel
+opopelhomeop \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/color_red_fore.chk b/contrib/netbsd-tests/lib/libcurses/check_files/color_red_fore.chk
new file mode 100644
index 0000000..3ad4513
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/color_red_fore.chk
@@ -0,0 +1,24 @@
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xel
+opopsetaf1Xelhomeop \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/color_set.chk b/contrib/netbsd-tests/lib/libcurses/check_files/color_set.chk
new file mode 100644
index 0000000..d8363b7
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/color_set.chk
@@ -0,0 +1 @@
+setaf1Xsetab2Xtestingop \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/color_start.chk b/contrib/netbsd-tests/lib/libcurses/check_files/color_start.chk
new file mode 100644
index 0000000..d314d07
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/color_start.chk
@@ -0,0 +1 @@
+op \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/copywin1.chk b/contrib/netbsd-tests/lib/libcurses/check_files/copywin1.chk
new file mode 100644
index 0000000..826062a
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/copywin1.chk
@@ -0,0 +1 @@
+cup11;15X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/copywin10.chk b/contrib/netbsd-tests/lib/libcurses/check_files/copywin10.chk
new file mode 100644
index 0000000..d5c8ea5
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/copywin10.chk
@@ -0,0 +1 @@
+cup11;15Xt s i cup12;15Xg e t cup13;15Xn t s cup14;15X n t scup15;15Xt n t cup16;15X t n t \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/copywin11.chk b/contrib/netbsd-tests/lib/libcurses/check_files/copywin11.chk
new file mode 100644
index 0000000..9315b76
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/copywin11.chk
@@ -0,0 +1,4 @@
+cup3;6Xel
+ el
+ elcup6;7Xel
+ elcup8;7Xelcup3;6Xcup11;15Xelcup12;15Xelcup13;15Xelcup14;16Xelcup15;15Xelcup16;16Xelcup11;15X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/copywin12.chk b/contrib/netbsd-tests/lib/libcurses/check_files/copywin12.chk
new file mode 100644
index 0000000..bc1a526
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/copywin12.chk
@@ -0,0 +1,4 @@
+cup3;6Xt s i
+ g e t
+ n t scup6;7Xn t s
+ t n tcup8;7Xt n tcup8;11X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/copywin13.chk b/contrib/netbsd-tests/lib/libcurses/check_files/copywin13.chk
new file mode 100644
index 0000000..f2a8913
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/copywin13.chk
@@ -0,0 +1 @@
+cup11;16Xe t ncup12;16Xt s icup13;16Xg e tcup14;15Xi g ecup15;16Xi g ecup16;15Xs i g \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/copywin14.chk b/contrib/netbsd-tests/lib/libcurses/check_files/copywin14.chk
new file mode 100644
index 0000000..e7fd505
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/copywin14.chk
@@ -0,0 +1 @@
+cup11;15Xtesticup12;15Xgtestcup13;15Xngtescup14;16Xngtescup15;15Xtingtcup16;16Xtingt \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/copywin2.chk b/contrib/netbsd-tests/lib/libcurses/check_files/copywin2.chk
new file mode 100644
index 0000000..aac0671
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/copywin2.chk
@@ -0,0 +1,6 @@
+cup3;6Xtestin
+ gtesti
+ ngtest
+ ingtes
+ tingte
+ stingtcup8;11X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/copywin3.chk b/contrib/netbsd-tests/lib/libcurses/check_files/copywin3.chk
new file mode 100644
index 0000000..317cd93
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/copywin3.chk
@@ -0,0 +1 @@
+cup12;16Xtestincup13;16Xgtesticup14;16Xngtestcup15;16Xingtescup16;16Xtingtecup17;16Xstingt \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/copywin4.chk b/contrib/netbsd-tests/lib/libcurses/check_files/copywin4.chk
new file mode 100644
index 0000000..4fa78a9
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/copywin4.chk
@@ -0,0 +1,6 @@
+cup3;6Xel
+ el
+ el
+ el
+ el
+ elcup12;16Xelcup13;16Xelcup14;16Xelcup15;16Xelcup16;16Xelcup17;16Xelcup11;15X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/copywin5.chk b/contrib/netbsd-tests/lib/libcurses/check_files/copywin5.chk
new file mode 100644
index 0000000..4f0d7da
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/copywin5.chk
@@ -0,0 +1 @@
+testingtecup12;15Xstingtestcup13;15Xingtestincup14;15Xgtestingtcup15;15Xestingtescup16;15Xtingtesticup16;23X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/copywin6.chk b/contrib/netbsd-tests/lib/libcurses/check_files/copywin6.chk
new file mode 100644
index 0000000..314dac8
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/copywin6.chk
@@ -0,0 +1,6 @@
+cup3;6Xtestin
+ stingt
+ ingtes
+ gtesti
+ esting
+ tingtecup8;11X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/copywin7.chk b/contrib/netbsd-tests/lib/libcurses/check_files/copywin7.chk
new file mode 100644
index 0000000..d10a7c2
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/copywin7.chk
@@ -0,0 +1,6 @@
+cup3;6Xel
+ el
+ el
+ el
+ el
+ elcup11;15Xelcup12;15Xelcup13;15Xelcup14;15Xelcup15;15Xelcup16;15Xel \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/copywin8.chk b/contrib/netbsd-tests/lib/libcurses/check_files/copywin8.chk
new file mode 100644
index 0000000..bc1a526
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/copywin8.chk
@@ -0,0 +1,4 @@
+cup3;6Xt s i
+ g e t
+ n t scup6;7Xn t s
+ t n tcup8;7Xt n tcup8;11X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/copywin9.chk b/contrib/netbsd-tests/lib/libcurses/check_files/copywin9.chk
new file mode 100644
index 0000000..f2a8913
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/copywin9.chk
@@ -0,0 +1 @@
+cup11;16Xe t ncup12;16Xt s icup13;16Xg e tcup14;15Xi g ecup15;16Xi g ecup16;15Xs i g \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/curs_set1.chk b/contrib/netbsd-tests/lib/libcurses/check_files/curs_set1.chk
new file mode 100644
index 0000000..81a818c
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/curs_set1.chk
@@ -0,0 +1 @@
+civis \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/curs_set2.chk b/contrib/netbsd-tests/lib/libcurses/check_files/curs_set2.chk
new file mode 100644
index 0000000..7682463
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/curs_set2.chk
@@ -0,0 +1 @@
+cnorm \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/curs_set3.chk b/contrib/netbsd-tests/lib/libcurses/check_files/curs_set3.chk
new file mode 100644
index 0000000..0f3e744
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/curs_set3.chk
@@ -0,0 +1 @@
+cvvis \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/curses_start.chk b/contrib/netbsd-tests/lib/libcurses/check_files/curses_start.chk
new file mode 100644
index 0000000..7c4f92c
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/curses_start.chk
@@ -0,0 +1 @@
+enacsenacssmcupcnormclearclear \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/fill.chk b/contrib/netbsd-tests/lib/libcurses/check_files/fill.chk
new file mode 100644
index 0000000..2d89374
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/fill.chk
@@ -0,0 +1,23 @@
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEhome
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/home.chk b/contrib/netbsd-tests/lib/libcurses/check_files/home.chk
new file mode 100644
index 0000000..0247178
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/home.chk
@@ -0,0 +1 @@
+home \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/timeout.chk b/contrib/netbsd-tests/lib/libcurses/check_files/timeout.chk
new file mode 100644
index 0000000..6463b1e
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/timeout.chk
@@ -0,0 +1 @@
+asmkx
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/wborder.chk b/contrib/netbsd-tests/lib/libcurses/check_files/wborder.chk
new file mode 100644
index 0000000..50857fa
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/wborder.chk
@@ -0,0 +1,6 @@
+smacslqqqqkrmacs
+ smacsxrmacs smacsxrmacs
+ smacsxrmacs smacsxrmacs
+ smacsxrmacs smacsxrmacs
+ smacsxrmacs smacsxrmacs
+ smacsmqqqqjrmacscup3;6X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/wborder_refresh.chk b/contrib/netbsd-tests/lib/libcurses/check_files/wborder_refresh.chk
new file mode 100644
index 0000000..0247178
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/wborder_refresh.chk
@@ -0,0 +1 @@
+home \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/wgetstr.chk b/contrib/netbsd-tests/lib/libcurses/check_files/wgetstr.chk
new file mode 100644
index 0000000..770eab4
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/wgetstr.chk
@@ -0,0 +1 @@
+input \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/wgetstr_refresh.chk b/contrib/netbsd-tests/lib/libcurses/check_files/wgetstr_refresh.chk
new file mode 100644
index 0000000..e8bbed5
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/wgetstr_refresh.chk
@@ -0,0 +1,2 @@
+
+ \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/window.chk b/contrib/netbsd-tests/lib/libcurses/check_files/window.chk
new file mode 100644
index 0000000..732f4cc
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/window.chk
@@ -0,0 +1 @@
+cup3;6X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/wprintw_refresh.chk b/contrib/netbsd-tests/lib/libcurses/check_files/wprintw_refresh.chk
new file mode 100644
index 0000000..53794ad
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/wprintw_refresh.chk
@@ -0,0 +1 @@
+cup3;6Xhellocup3;10X \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/wscrl1.chk b/contrib/netbsd-tests/lib/libcurses/check_files/wscrl1.chk
new file mode 100644
index 0000000..627141d
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/wscrl1.chk
@@ -0,0 +1 @@
+cup4;7Xxxxxhome \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/check_files/wscrl2.chk b/contrib/netbsd-tests/lib/libcurses/check_files/wscrl2.chk
new file mode 100644
index 0000000..ee36e55
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/check_files/wscrl2.chk
@@ -0,0 +1 @@
+cup4;7Xelcup6;7Xxxxxhome \ No newline at end of file
diff --git a/contrib/netbsd-tests/lib/libcurses/director/director.c b/contrib/netbsd-tests/lib/libcurses/director/director.c
new file mode 100644
index 0000000..c73ddae
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/director/director.c
@@ -0,0 +1,279 @@
+/* $NetBSD: director.c,v 1.10 2012/06/03 23:19:11 joerg Exp $ */
+
+/*-
+ * Copyright 2009 Brett Lymn <blymn@NetBSD.org>
+ *
+ * All rights reserved.
+ *
+ * This code has been donated to The NetBSD Foundation by the Author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ */
+
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <termios.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <util.h>
+#include <err.h>
+#include "returns.h"
+
+void yyparse(void);
+#define DEF_TERMPATH "."
+#define DEF_TERM "atf"
+#define DEF_SLAVE "./slave"
+
+const char *def_check_path = "./"; /* default check path */
+const char *def_include_path = "./"; /* default include path */
+
+extern size_t nvars; /* In testlang_conf.y */
+saved_data_t saved_output; /* In testlang_conf.y */
+int cmdpipe[2]; /* command pipe between director and slave */
+int slvpipe[2]; /* reply pipe back from slave */
+int master; /* pty to the slave */
+int verbose; /* control verbosity of tests */
+const char *check_path; /* path to prepend to check files for output
+ validation */
+const char *include_path; /* path to prepend to include files */
+char *cur_file; /* name of file currently being read */
+
+void init_parse_variables(int); /* in testlang_parse.y */
+
+/*
+ * Handle the slave exiting unexpectedly, try to recover the exit message
+ * and print it out.
+ */
+static void
+slave_died(int param)
+{
+ char last_words[256];
+ size_t count;
+
+ fprintf(stderr, "ERROR: Slave has exited\n");
+ if (saved_output.count > 0) {
+ fprintf(stderr, "output from slave: ");
+ for (count = 0; count < saved_output.count; count ++) {
+ if (isprint((unsigned char)saved_output.data[count]))
+ fprintf(stderr, "%c", saved_output.data[count]);
+ }
+ fprintf(stderr, "\n");
+ }
+
+ if ((count = read(master, &last_words, 255)) > 0) {
+ last_words[count] = '\0';
+ fprintf(stderr, "slave exited with message \"%s\"\n",
+ last_words);
+ }
+
+ exit(2);
+}
+
+
+static void
+usage(void)
+{
+ fprintf(stderr, "Usage: %s [-v] [-I include-path] [-C check-path] "
+ "[-T terminfo-file] [-s pathtoslave] [-t term] "
+ "commandfile\n", getprogname());
+ fprintf(stderr, " where:\n");
+ fprintf(stderr, " -v enables verbose test output\n");
+ fprintf(stderr, " -T is a directory containing the terminfo.cdb "
+ "file, or a file holding the terminfo description n");
+ fprintf(stderr, " -s is the path to the slave executable\n");
+ fprintf(stderr, " -t is value to set TERM to for the test\n");
+ fprintf(stderr, " -I is the directory to include files\n");
+ fprintf(stderr, " -C is the directory for config files\n");
+ fprintf(stderr, " commandfile is a file of test directives\n");
+ exit(1);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ extern char *optarg;
+ extern int optind;
+ const char *termpath, *term, *slave;
+ int ch;
+ pid_t slave_pid;
+ extern FILE *yyin;
+ char *arg1, *arg2, *arg3, *arg4;
+ struct termios term_attr;
+ struct stat st;
+
+ termpath = term = slave = NULL;
+ verbose = 0;
+
+ while ((ch = getopt(argc, argv, "vC:I:p:s:t:T:")) != -1) {
+ switch(ch) {
+ case 'I':
+ include_path = optarg;
+ break;
+ case 'C':
+ check_path = optarg;
+ break;
+ case 'T':
+ termpath = optarg;
+ break;
+ case 'p':
+ termpath = optarg;
+ break;
+ case 's':
+ slave = optarg;
+ break;
+ case 't':
+ term = optarg;
+ break;
+ case 'v':
+ verbose = 1;
+ break;
+ case '?':
+ default:
+ usage();
+ break;
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+ if (argc < 1)
+ usage();
+
+ if (termpath == NULL)
+ termpath = DEF_TERMPATH;
+
+ if (slave == NULL)
+ slave = DEF_SLAVE;
+
+ if (term == NULL)
+ term = DEF_TERM;
+
+ if (check_path == NULL)
+ check_path = getenv("CHECK_PATH");
+ if ((check_path == NULL) || (check_path[0] == '\0')) {
+ warn("$CHECK_PATH not set, defaulting to %s", def_check_path);
+ check_path = def_check_path;
+ }
+
+ if (include_path == NULL)
+ include_path = getenv("INCLUDE_PATH");
+ if ((include_path == NULL) || (include_path[0] == '\0')) {
+ warn("$INCLUDE_PATH not set, defaulting to %s",
+ def_include_path);
+ include_path = def_include_path;
+ }
+
+ signal(SIGCHLD, slave_died);
+
+ if (setenv("TERM", term, 1) != 0)
+ err(2, "Failed to set TERM variable");
+
+ if (stat(termpath, &st) == -1)
+ err(1, "Cannot stat %s", termpath);
+
+ if (S_ISDIR(st.st_mode)) {
+ char tinfo[MAXPATHLEN];
+ int l = snprintf(tinfo, sizeof(tinfo), "%s/%s", termpath,
+ "terminfo.cdb");
+ if (stat(tinfo, &st) == -1)
+ err(1, "Cannot stat `%s'", tinfo);
+ if (l >= 4)
+ tinfo[l - 4] = '\0';
+ if (setenv("TERMINFO", tinfo, 1) != 0)
+ err(1, "Failed to set TERMINFO variable");
+ } else {
+ int fd;
+ char *tinfo;
+ if ((fd = open(termpath, O_RDONLY)) == -1)
+ err(1, "Cannot open `%s'", termpath);
+ if ((tinfo = mmap(NULL, (size_t)st.st_size, PROT_READ, MAP_FILE,
+ fd, 0)) == MAP_FAILED)
+ err(1, "Cannot map `%s'", termpath);
+ if (setenv("TERMINFO", tinfo, 1) != 0)
+ err(1, "Failed to set TERMINFO variable");
+ close(fd);
+ munmap(tinfo, (size_t)st.st_size);
+ }
+
+ if (pipe(cmdpipe) < 0)
+ err(1, "Command pipe creation failed");
+
+ if (pipe(slvpipe) < 0)
+ err(1, "Slave pipe creation failed");
+
+ /*
+ * Create default termios settings for later use
+ */
+ memset(&term_attr, 0, sizeof(term_attr));
+ term_attr.c_iflag = TTYDEF_IFLAG;
+ term_attr.c_oflag = TTYDEF_OFLAG;
+ term_attr.c_cflag = TTYDEF_CFLAG;
+ term_attr.c_lflag = TTYDEF_LFLAG;
+ cfsetspeed(&term_attr, TTYDEF_SPEED);
+ term_attr.c_cc[VERASE] = '\b';
+ term_attr.c_cc[VKILL] = '\025'; /* ^U */
+
+ if ((slave_pid = forkpty(&master, NULL, &term_attr, NULL)) < 0)
+ err(1, "Fork of pty for slave failed\n");
+
+ if (slave_pid == 0) {
+ /* slave side, just exec the slave process */
+ if (asprintf(&arg1, "%d", cmdpipe[0]) < 0)
+ err(1, "arg1 conversion failed");
+
+ if (asprintf(&arg2, "%d", cmdpipe[1]) < 0)
+ err(1, "arg2 conversion failed");
+
+ if (asprintf(&arg3, "%d", slvpipe[0]) < 0)
+ err(1, "arg3 conversion failed");
+
+ if (asprintf(&arg4, "%d", slvpipe[1]) < 0)
+ err(1, "arg4 conversion failed");
+
+ if (execl(slave, slave, arg1, arg2, arg3, arg4, NULL) < 0)
+ err(1, "Exec of slave %s failed", slave);
+
+ /* NOT REACHED */
+ }
+
+ fcntl(master, F_SETFL, O_NONBLOCK);
+
+ if ((yyin = fopen(argv[0], "r")) == NULL)
+ err(1, "Cannot open command file %s", argv[0]);
+
+ if ((cur_file = strdup(argv[0])) == NULL)
+ err(2, "Failed to alloc memory for test file name");
+
+ init_parse_variables(1);
+
+ yyparse();
+ fclose(yyin);
+
+ exit(0);
+}
diff --git a/contrib/netbsd-tests/lib/libcurses/director/returns.h b/contrib/netbsd-tests/lib/libcurses/director/returns.h
new file mode 100644
index 0000000..150e358
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/director/returns.h
@@ -0,0 +1,66 @@
+/* $NetBSD: returns.h,v 1.1 2011/04/10 09:55:09 blymn Exp $ */
+
+/*-
+ * Copyright 2009 Brett Lymn <blymn@NetBSD.org>
+ *
+ * All rights reserved.
+ *
+ * This code has been donated to The NetBSD Foundation by the Author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ */
+#ifndef CTF_RETURNS_H
+#define CTF_RETURNS_H 1
+
+
+typedef enum {
+ ret_number = 1,
+ ret_string,
+ ret_byte,
+ ret_err,
+ ret_ok,
+ ret_null,
+ ret_nonnull,
+ ret_var,
+ ret_ref,
+ ret_count,
+ ret_slave_error
+} returns_enum_t;
+
+typedef struct {
+ returns_enum_t return_type;
+ void *return_value; /* used if return_type is ret_num or
+ or ret_byte or ret_string */
+ size_t return_len; /* number of bytes in return_value iff
+ return_type is ret_byte */
+ int return_index; /* index into var array for return
+ if return_type is ret_var */
+} returns_t;
+
+typedef struct {
+ size_t count;
+ size_t allocated;
+ size_t readp;
+ char *data;
+} saved_data_t;
+
+#endif /* CTF_RETURNS_H */
diff --git a/contrib/netbsd-tests/lib/libcurses/director/testlang_conf.l b/contrib/netbsd-tests/lib/libcurses/director/testlang_conf.l
new file mode 100644
index 0000000..a732afc
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/director/testlang_conf.l
@@ -0,0 +1,437 @@
+%{
+/* $NetBSD: testlang_conf.l,v 1.7 2013/11/21 11:06:04 blymn Exp $ */
+
+/*-
+ * Copyright 2009 Brett Lymn <blymn@NetBSD.org>
+ *
+ * All rights reserved.
+ *
+ * This code has been donated to The NetBSD Foundation by the Author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ */
+
+#include <curses.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/param.h>
+#include <err.h>
+#include "returns.h"
+#include "testlang_parse.h"
+
+#define MAX_INCLUDES 32 /* limit for the number of nested includes */
+
+int yylex(void);
+
+extern size_t line;
+extern char *include_path; /* from director.c */
+extern char *cur_file; /* from director.c */
+
+static int include_stack[MAX_INCLUDES];
+static char *include_files[MAX_INCLUDES];
+static int include_ptr = 0;
+
+static char *
+dequote(const char *s, size_t *len)
+{
+ const unsigned char *p;
+ char *buf, *q;
+
+ *len = 0;
+ p = (const unsigned char *)s;
+ while (*p) {
+ if (*p == '\\' && *(p+1)) {
+ if (isdigit(*(p+1)) && *(p+2) && isdigit(*(p+2)) &&
+ *(p+3) && isdigit(*(p+3)))
+ p += 3;
+ else
+ ++p;
+ }
+ ++(*len);
+ ++p;
+ }
+
+ buf = malloc(*len + 1);
+ if (buf == NULL)
+ return NULL;
+
+ p = (const unsigned char *)s;
+ q = buf;
+ while (*p) {
+ if (*p == '\\' && *(p+1)) {
+ ++p;
+ if (isdigit(*p)) {
+ if (*(p+1) && isdigit(*(p+1)) && *(p+2) &&
+ isdigit(*(p+2))) {
+ *q++ = ((*p - '0') * 8 + (*(p+1) - '0')) * 8 + (*(p+2) - '0');
+ p += 3;
+ } else {
+ *q++ = *p++;
+ }
+ } else {
+ switch (*p) {
+ case 'e':
+ /* escape */
+ *q++ = '\e';
+ p++;
+ break;
+
+ case 'n':
+ /* newline */
+ *q++ = '\n';
+ p++;
+ break;
+
+ case 'r':
+ /* carriage return */
+ *q++ = '\r';
+ p++;
+ break;
+
+ case 't':
+ /* tab */
+ *q++ = '\t';
+ p++;
+ break;
+
+ case '\\':
+ /* backslash */
+ *q++ = '\\';
+ p++;
+ break;
+
+ default:
+ *q++ = *p++;
+ }
+ }
+ } else
+ *q++ = *p++;
+ }
+ *q++ = '\0';
+
+ return buf;
+}
+%}
+
+HEX 0[xX][0-9a-zA-Z]+
+STRING [0-9a-z!#-&(-^ \t%._\\]+
+numeric [-0-9]+
+PCHAR (\\.|[^ \t\n])
+ASSIGN [aA][sS][sS][iI][gG][nN]
+CALL2 [cC][aA][lL][lL]2
+CALL3 [cC][aA][lL][lL]3
+CALL4 [cC][aA][lL][lL]4
+CALL [cC][aA][lL][lL]
+CHECK [cC][hH][eE][cC][kK]
+DELAY [dD][eE][lL][aA][yY]
+INPUT [iI][nN][pP][uU][tT]
+NOINPUT [nN][oO][iI][nN][pP][uU][tT]
+OK_RET [oO][kK]
+ERR_RET [eE][rR][rR]
+COMPARE [cC][oO][mM][pP][aA][rR][eE]
+COMPAREND [cC][oO][mM][pP][aA][rR][eE][Nn][Dd]
+FILENAME [A-Za-z0-9.][A-Za-z0-9./_-]+
+VARNAME [A-Za-z][A-Za-z0-9_-]+
+NULL_RET NULL
+NON_NULL NON_NULL
+BYTE BYTE
+OR \|
+LHB \(
+RHB \)
+
+%x incl
+%option noinput nounput
+
+%%
+
+include BEGIN(incl);
+
+<incl>[ \t]* /* eat the whitespace */
+<incl>[^ \t\n]+ { /* got the include file name */
+ char inc_file[MAXPATHLEN];
+
+ if (include_ptr > MAX_INCLUDES) {
+ fprintf(stderr,
+ "Maximum number of nested includes exceeded "
+ "at line %zu of file %s\n", line, cur_file);
+ exit(2);
+ }
+
+ if (yytext[0] != '/') {
+ if (strlcpy(inc_file, include_path, sizeof(inc_file))
+ >= sizeof(inc_file))
+ err(2, "CHECK_PATH too long");
+ if ((include_path[strlen(include_path) - 1] != '/') &&
+ ((strlcat(inc_file, "/", sizeof(inc_file))
+ >= sizeof(inc_file))))
+ err(2, "Could not append / to include file path");
+ } else {
+ inc_file[0] = '\0';
+ }
+
+ if (strlcat(inc_file, yytext, sizeof(inc_file))
+ >= sizeof(inc_file))
+ err(2, "Path to include file path overflowed");
+
+ yyin = fopen(inc_file, "r" );
+
+ if (!yyin)
+ err(1, "Error opening %s", inc_file);
+
+ yypush_buffer_state(yy_create_buffer(yyin, YY_BUF_SIZE));
+
+ include_stack[include_ptr] = line;
+ include_files[include_ptr++] = cur_file;
+ cur_file = strdup(inc_file);
+ if (cur_file == NULL)
+ err(2, "Cannot allocate new include file string");
+ line = 0;
+ BEGIN(INITIAL);
+ }
+
+<<EOF>> {
+ yypop_buffer_state();
+
+ if ( !YY_CURRENT_BUFFER )
+ {
+ yyterminate();
+ }
+
+ if (--include_ptr < 0)
+ err(2, "Include stack underflow");
+
+ free(cur_file);
+ cur_file = include_files[include_ptr];
+ line = include_stack[include_ptr];
+ }
+
+{ASSIGN} {
+ return ASSIGN;
+ }
+
+{CALL2} {
+ return CALL2;
+ }
+
+{CALL3} {
+ return CALL3;
+ }
+
+{CALL4} {
+ return CALL4;
+ }
+
+{CALL} {
+ return CALL;
+ }
+
+{CHECK} {
+ return CHECK;
+ }
+
+{DELAY} {
+ return DELAY;
+ }
+
+{INPUT} {
+ return INPUT;
+ }
+
+{NOINPUT} {
+ return NOINPUT;
+ }
+
+{COMPARE} {
+ return COMPARE;
+ }
+
+{COMPAREND} {
+ return COMPAREND;
+ }
+
+{NON_NULL} {
+ return NON_NULL;
+ }
+
+{NULL_RET} {
+ return NULL_RET;
+ }
+
+{OK_RET} {
+ return OK_RET;
+ }
+
+{ERR_RET} {
+ return ERR_RET;
+ }
+
+{OR} {
+ return OR;
+ }
+
+{LHB} {
+ return LHB;
+ }
+
+{RHB} {
+ return RHB;
+ }
+
+{HEX} {
+ /* Hex value, convert to decimal and return numeric */
+ unsigned long val;
+
+ if (sscanf(yytext, "%lx", &val) != 1)
+ err(1, "Bad hex conversion");
+
+ asprintf(&yylval.string, "%ld", val);
+ return numeric;
+ }
+
+
+{numeric} {
+ if ((yylval.string = strdup(yytext)) == NULL)
+ err(1, "Cannot allocate numeric string");
+ return numeric;
+}
+
+{VARNAME} {
+ if ((yylval.string = strdup(yytext)) == NULL)
+ err(1, "Cannot allocate string for varname");
+ return VARNAME;
+ }
+
+{FILENAME} {
+ size_t len;
+
+ if ((yylval.string = dequote(yytext, &len)) == NULL)
+ err(1, "Cannot allocate filename string");
+ return FILENAME;
+ }
+
+ /* path */
+\/{PCHAR}+ {
+ size_t len;
+ if ((yylval.string = dequote(yytext, &len)) == NULL)
+ err(1, "Cannot allocate string");
+ return PATH;
+ }
+
+\'{STRING}\' {
+ char *p;
+ size_t len;
+
+ if ((yylval.retval = malloc(sizeof(returns_t))) == NULL)
+ err(1, "Cannot allocate return struct");
+ p = yytext;
+ p++; /* skip the leading ' */
+ if ((yylval.retval->return_value = dequote(p, &len))
+ == NULL)
+ err(1, "Cannot allocate string");
+
+ yylval.retval->return_type = ret_byte;
+ /* trim trailing ' */
+ yylval.retval->return_len = len - 1;
+ return BYTE;
+ }
+
+\`{STRING}\` {
+ char *p, *str;
+ size_t len, chlen;
+ size_t i;
+ chtype *rv;
+
+ if ((yylval.retval = malloc(sizeof(returns_t))) == NULL)
+ err(1, "Cannot allocate return struct");
+ p = yytext;
+ p++; /* skip the leading ' */
+ if ((str = dequote(p, &len)) == NULL)
+ err(1, "Cannot allocate string");
+ len--; /* trim trailing ` */
+ if ((len % 2) != 0)
+ len--;
+
+ chlen = ((len / 2) + 1) * sizeof(chtype);
+ if ((yylval.retval->return_value = malloc(chlen))
+ == NULL)
+ err(1, "Cannot allocate chtype array");
+
+ rv = yylval.retval->return_value;
+ for (i = 0; i < len; i += 2)
+ *rv++ = (str[i] << 8) | str[i+1];
+ *rv = __NORMAL | '\0'; /* terminates chtype array */
+ yylval.retval->return_type = ret_byte;
+ yylval.retval->return_len = chlen;
+ return BYTE;
+ }
+
+\"{STRING}\" {
+ char *p;
+ size_t len;
+
+ p = yytext;
+ p++; /* skip the leading " */
+ if ((yylval.string = dequote(p, &len)) == NULL)
+ err(1, "Cannot allocate string");
+
+ /* remove trailing " */
+ yylval.string[len - 1] = '\0';
+ return STRING;
+ }
+
+\${VARNAME} {
+ char *p;
+
+ p = yytext;
+ p++; /* skip $ before var name */
+ if ((yylval.string = strdup(p)) == NULL)
+ err(1, "Cannot allocate string for varname");
+ return VARIABLE;
+ }
+
+ /* comments, white-outs */
+[ \t\r] |
+#.* ;
+^#.*\n |
+#.*\n |
+\\\n |
+^\n {
+line++; }
+
+ /* eol on a line with data. need to process, return eol */
+\n {
+ line++;
+ return EOL;
+ }
+
+. {
+ }
+
+%%
+
+int
+yywrap(void)
+{
+ return 1;
+}
diff --git a/contrib/netbsd-tests/lib/libcurses/director/testlang_parse.y b/contrib/netbsd-tests/lib/libcurses/director/testlang_parse.y
new file mode 100644
index 0000000..37c813f
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/director/testlang_parse.y
@@ -0,0 +1,1617 @@
+%{
+/* $NetBSD: testlang_parse.y,v 1.13 2012/09/19 11:51:56 blymn Exp $ */
+
+/*-
+ * Copyright 2009 Brett Lymn <blymn@NetBSD.org>
+ *
+ * All rights reserved.
+ *
+ * This code has been donated to The NetBSD Foundation by the Author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ */
+#include <assert.h>
+#include <curses.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <err.h>
+#include <unistd.h>
+#include <poll.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/syslimits.h>
+#include <time.h>
+#include <vis.h>
+#include <stdint.h>
+#include "returns.h"
+
+#define YYDEBUG 1
+
+extern int verbose;
+extern int cmdpipe[2];
+extern int slvpipe[2];
+extern int master;
+extern struct pollfd readfd;
+extern char *check_path;
+extern char *cur_file; /* from director.c */
+
+int yylex(void);
+
+size_t line;
+
+static int input_delay;
+
+/* time delay between inputs chars - default to 0.1ms minimum to prevent
+ * problems with input tests
+ */
+#define DELAY_MIN 0.1
+
+/* time delay after a function call - allows the slave time to
+ * run the function and output data before we do other actions.
+ * Set this to 50ms.
+ */
+#define POST_CALL_DELAY 50
+
+static struct timespec delay_spec = {0, 1000 * DELAY_MIN};
+static struct timespec delay_post_call = {0, 1000 * POST_CALL_DELAY};
+
+static char *input_str; /* string to feed in as input */
+static bool no_input; /* don't need more input */
+
+#define READ_PIPE 0
+#define WRITE_PIPE 1
+
+const char *returns_enum_names[] = {
+ "unused", "numeric", "string", "byte", "ERR", "OK", "NULL", "not NULL",
+ "variable", "reference", "returns count", "slave error"
+};
+
+typedef enum {
+ arg_static,
+ arg_byte,
+ arg_var,
+ arg_null
+} args_state_t;
+
+static const char *args_enum_names[] = {
+ "static", "byte", "var", "NULL"
+};
+
+typedef struct {
+ args_state_t arg_type;
+ size_t arg_len;
+ char *arg_string;
+ int var_index;
+} args_t;
+
+typedef struct {
+ char *function;
+ int nrets; /* number of returns */
+ returns_t *returns; /* array of expected returns */
+ int nargs; /* number of arguments */
+ args_t *args; /* arguments for the call */
+} cmd_line_t;
+
+static cmd_line_t command;
+
+typedef struct {
+ char *name;
+ size_t len;
+ returns_enum_t type;
+ void *value;
+} var_t;
+
+static size_t nvars; /* Number of declared variables */
+static var_t *vars; /* Variables defined during the test. */
+
+static int check_function_table(char *, const char *[], int);
+static int find_var_index(const char *);
+static void assign_arg(args_state_t, void *);
+static int assign_var(char *);
+void init_parse_variables(int);
+static void validate(int, void *);
+static void validate_return(const char *, const char *, int);
+static void validate_variable(int, returns_enum_t, const void *, int, int);
+static void validate_byte(returns_t *, returns_t *, int);
+static void write_cmd_pipe(char *);
+static void write_cmd_pipe_args(args_state_t, void *);
+static void read_cmd_pipe(returns_t *);
+static void write_func_and_args(void);
+static void compare_streams(char *, bool);
+static void do_function_call(size_t);
+static void save_slave_output(bool);
+static void validate_type(returns_enum_t, returns_t *, int);
+static void set_var(returns_enum_t, char *, void *);
+static void validate_reference(int, void *);
+static char *numeric_or(char *, char *);
+static char *get_numeric_var(const char *);
+static void perform_delay(struct timespec *);
+
+static const char *input_functions[] = {
+ "getch", "getnstr", "getstr", "mvgetnstr", "mvgetstr", "mvgetnstr",
+ "mvgetstr", "mvscanw", "mvwscanw", "scanw", "wgetch", "wgetnstr",
+ "wgetstr"
+};
+
+static const unsigned ninput_functions =
+ sizeof(input_functions) / sizeof(char *);
+
+saved_data_t saved_output;
+
+%}
+
+%union {
+ char *string;
+ returns_t *retval;
+}
+
+%token <string> PATH
+%token <string> STRING
+%token <retval> BYTE
+%token <string> VARNAME
+%token <string> FILENAME
+%token <string> VARIABLE
+%token <string> REFERENCE
+%token <string> NULL_RET
+%token <string> NON_NULL
+%token <string> ERR_RET
+%token <string> OK_RET
+%token <string> numeric
+%token <string> DELAY
+%token <string> INPUT
+%token <string> COMPARE
+%token <string> COMPAREND
+%token <string> ASSIGN
+%token EOL CALL CHECK NOINPUT OR LHB RHB
+%token CALL2 CALL3 CALL4 DRAIN
+
+%nonassoc OR
+
+%%
+
+statement : /* empty */
+ | assign statement
+ | call statement
+ | call2 statement
+ | call3 statement
+ | call4 statement
+ | check statement
+ | delay statement
+ | input statement
+ | noinput statement
+ | compare statement
+ | comparend statement
+ | eol statement
+ ;
+
+assign : ASSIGN VARNAME numeric {set_var(ret_number, $2, $3);} eol
+ | ASSIGN VARNAME LHB expr RHB {set_var(ret_number, $2, $<string>4);} eol
+ | ASSIGN VARNAME STRING {set_var(ret_string, $2, $3);} eol
+ | ASSIGN VARNAME BYTE {set_var(ret_byte, $2, $3);} eol
+ ;
+
+call : CALL result fn_name args eol {
+ do_function_call(1);
+}
+ ;
+
+call2 : CALL2 result result fn_name args eol {
+ do_function_call(2);
+}
+ ;
+
+call3 : CALL3 result result result fn_name args eol {
+ do_function_call(3);
+}
+ ;
+
+call4 : CALL4 result result result result fn_name args eol {
+ do_function_call(4);
+ }
+ ;
+
+check : CHECK var returns eol {
+ returns_t retvar;
+ var_t *vptr;
+ if (command.returns[0].return_index == -1)
+ err(1, "Undefined variable in check statement, line %zu"
+ " of file %s", line, cur_file);
+
+ if (verbose) {
+ fprintf(stderr, "Checking contents of variable %s for %s\n",
+ vars[command.returns[0].return_index].name,
+ returns_enum_names[command.returns[1].return_type]);
+ }
+
+ if (((command.returns[1].return_type == ret_byte) &&
+ (vars[command.returns[0].return_index].type != ret_byte)) ||
+ vars[command.returns[0].return_index].type != ret_string)
+ err(1, "Var type %s (%d) does not match return type %s (%d)",
+ returns_enum_names[
+ vars[command.returns[0].return_index].type],
+ vars[command.returns[0].return_index].type,
+ returns_enum_names[command.returns[1].return_type],
+ command.returns[1].return_type);
+
+ switch (command.returns[1].return_type) {
+ case ret_err:
+ validate_variable(0, ret_string, "ERR",
+ command.returns[0].return_index, 0);
+ break;
+
+ case ret_ok:
+ validate_variable(0, ret_string, "OK",
+ command.returns[0].return_index, 0);
+ break;
+
+ case ret_null:
+ validate_variable(0, ret_string, "NULL",
+ command.returns[0].return_index, 0);
+ break;
+
+ case ret_nonnull:
+ validate_variable(0, ret_string, "NULL",
+ command.returns[0].return_index, 1);
+ break;
+
+ case ret_string:
+ case ret_number:
+ if (verbose) {
+ fprintf(stderr, " %s == returned %s\n",
+ (const char *)command.returns[1].return_value,
+ (const char *)
+ vars[command.returns[0].return_index].value);
+ }
+ validate_variable(0, ret_string,
+ command.returns[1].return_value,
+ command.returns[0].return_index, 0);
+ break;
+
+ case ret_byte:
+ vptr = &vars[command.returns[0].return_index];
+ retvar.return_len = vptr->len;
+ retvar.return_type = vptr->type;
+ retvar.return_value = vptr->value;
+ validate_byte(&retvar, &command.returns[1], 0);
+ break;
+
+ default:
+ err(1, "Malformed check statement at line %zu "
+ "of file %s", line, cur_file);
+ break;
+ }
+
+ init_parse_variables(0);
+ }
+ ;
+
+delay : DELAY numeric eol {
+ /* set the inter-character delay */
+ if (sscanf($2, "%d", &input_delay) == 0)
+ err(1, "delay specification %s could not be converted to "
+ "numeric at line %zu of file %s", $2, line, cur_file);
+ if (verbose) {
+ fprintf(stderr, "Set input delay to %d ms\n", input_delay);
+ }
+
+ if (input_delay < DELAY_MIN)
+ input_delay = DELAY_MIN;
+ /*
+ * Fill in the timespec structure now ready for use later.
+ * The delay is specified in milliseconds so convert to timespec
+ * values
+ */
+ delay_spec.tv_sec = input_delay / 1000;
+ delay_spec.tv_nsec = (input_delay - 1000 * delay_spec.tv_sec) * 1000;
+ if (verbose) {
+ fprintf(stderr, "set delay to %jd.%jd\n",
+ (intmax_t)delay_spec.tv_sec,
+ (intmax_t)delay_spec.tv_nsec);
+ }
+
+ init_parse_variables(0);
+ }
+ ;
+
+input : INPUT STRING eol {
+ if (input_str != NULL) {
+ warnx("%s, %zu: Discarding unused input string",
+ cur_file, line);
+ free(input_str);
+ }
+
+ if ((input_str = malloc(strlen($2) + 1)) == NULL)
+ err(2, "Cannot allocate memory for input string");
+
+ strlcpy(input_str, $2, strlen($2) + 1);
+}
+ ;
+
+
+noinput : NOINPUT eol {
+ if (input_str != NULL) {
+ warnx("%s, %zu: Discarding unused input string",
+ cur_file, line);
+ free(input_str);
+ }
+
+ no_input = true;
+ }
+
+compare : COMPARE PATH eol
+ | COMPARE FILENAME eol
+{
+ compare_streams($2, true);
+}
+ ;
+
+
+comparend : COMPAREND PATH eol
+ | COMPAREND FILENAME eol
+{
+ compare_streams($2, false);
+}
+ ;
+
+
+result : returns
+ | var
+ | reference
+ ;
+
+returns : numeric { assign_rets(ret_number, $1); }
+ | LHB expr RHB { assign_rets(ret_number, $<string>2); }
+ | STRING { assign_rets(ret_string, $1); }
+ | BYTE { assign_rets(ret_byte, (void *) $1); }
+ | ERR_RET { assign_rets(ret_err, NULL); }
+ | OK_RET { assign_rets(ret_ok, NULL); }
+ | NULL_RET { assign_rets(ret_null, NULL); }
+ | NON_NULL { assign_rets(ret_nonnull, NULL); }
+ ;
+
+var : VARNAME {
+ assign_rets(ret_var, $1);
+ }
+ ;
+
+reference : VARIABLE {
+ assign_rets(ret_ref, $1);
+ }
+
+fn_name : VARNAME {
+ if (command.function != NULL)
+ free(command.function);
+
+ command.function = malloc(strlen($1) + 1);
+ if (command.function == NULL)
+ err(1, "Could not allocate memory for function name");
+ strcpy(command.function, $1);
+ }
+ ;
+
+expr : numeric
+ | VARIABLE
+ { $<string>$ = get_numeric_var($1); }
+ | expr OR expr
+ { $<string>$ = numeric_or($<string>1, $<string>3); }
+ ;
+
+args : /* empty */
+ | LHB expr RHB { assign_arg(arg_static, $<string>2); } args
+ | numeric { assign_arg(arg_static, $1); } args
+ | STRING { assign_arg(arg_static, $1); } args
+ | BYTE { assign_arg(arg_byte, $1); } args
+ | PATH { assign_arg(arg_static, $1); } args
+ | FILENAME { assign_arg(arg_static, $1); } args
+ | VARNAME { assign_arg(arg_static, $1); } args
+ | VARIABLE { assign_arg(arg_var, $1); } args
+ | NULL_RET { assign_arg(arg_null, $1); } args
+ ;
+
+eol : EOL
+ ;
+
+%%
+
+static void
+excess(const char *fname, size_t lineno, const char *func, const char *comment,
+ const void *data, size_t datalen)
+{
+ size_t dstlen = datalen * 4 + 1;
+ char *dst = malloc(dstlen);
+
+ if (dst == NULL)
+ err(1, "malloc");
+
+ if (strnvisx(dst, dstlen, data, datalen, VIS_WHITE | VIS_OCTAL) == -1)
+ err(1, "strnvisx");
+
+ warnx("%s, %zu: [%s] Excess %zu bytes%s [%s]",
+ fname, lineno, func, datalen, comment, dst);
+ free(dst);
+}
+
+/*
+ * Get the value of a variable, error if the variable has not been set or
+ * is not a numeric type.
+ */
+static char *
+get_numeric_var(const char *var)
+{
+ int i;
+
+ if ((i = find_var_index(var)) < 0)
+ err(1, "Variable %s is undefined", var);
+
+ if (vars[i].type != ret_number)
+ err(1, "Variable %s is not a numeric type", var);
+
+ return vars[i].value;
+}
+
+/*
+ * Perform a bitwise OR on two numbers and return the result.
+ */
+static char *
+numeric_or(char *n1, char *n2)
+{
+ unsigned long i1, i2, result;
+ char *ret;
+
+ i1 = strtoul(n1, NULL, 10);
+ i2 = strtoul(n2, NULL, 10);
+
+ result = i1 | i2;
+ asprintf(&ret, "%lu", result);
+
+ if (verbose) {
+ fprintf(stderr, "numeric or of 0x%lx (%s) and 0x%lx (%s)"
+ " results in 0x%lx (%s)\n",
+ i1, n1, i2, n2, result, ret);
+ }
+
+ return ret;
+}
+
+/*
+ * Sleep for the specified time, handle the sleep getting interrupted
+ * by a signal.
+ */
+static void
+perform_delay(struct timespec *ts)
+{
+ struct timespec delay_copy, delay_remainder;
+
+ delay_copy = *ts;
+ while (nanosleep(&delay_copy, &delay_remainder) < 0) {
+ if (errno != EINTR)
+ err(2, "nanosleep returned error");
+ delay_copy = delay_remainder;
+ }
+}
+
+/*
+ * Assign the value given to the named variable.
+ */
+static void
+set_var(returns_enum_t type, char *name, void *value)
+{
+ int i;
+ char *number;
+ returns_t *ret;
+
+ i = find_var_index(name);
+ if (i < 0)
+ i = assign_var(name);
+
+ vars[i].type = type;
+ if ((type == ret_number) || (type == ret_string)) {
+ number = value;
+ vars[i].len = strlen(number) + 1;
+ vars[i].value = malloc(vars[i].len + 1);
+ if (vars[i].value == NULL)
+ err(1, "Could not malloc memory for assign string");
+ strcpy(vars[i].value, number);
+ } else {
+ /* can only be a byte value */
+ ret = value;
+ vars[i].len = ret->return_len;
+ vars[i].value = malloc(vars[i].len);
+ if (vars[i].value == NULL)
+ err(1, "Could not malloc memory to assign byte string");
+ memcpy(vars[i].value, ret->return_value, vars[i].len);
+ }
+}
+
+/*
+ * Add a new variable to the vars array, the value will be assigned later,
+ * when a test function call returns.
+ */
+static int
+assign_var(char *varname)
+{
+ var_t *temp;
+ char *name;
+
+ if ((name = malloc(strlen(varname) + 1)) == NULL)
+ err(1, "Alloc of varname failed");
+
+ if ((temp = realloc(vars, sizeof(*temp) * (nvars + 1))) == NULL) {
+ free(name);
+ err(1, "Realloc of vars array failed");
+ }
+
+ strcpy(name, varname);
+ vars = temp;
+ vars[nvars].name = name;
+ vars[nvars].len = 0;
+ vars[nvars].value = NULL;
+ nvars++;
+
+ return (nvars - 1);
+}
+
+/*
+ * Allocate and assign a new argument of the given type.
+ */
+static void
+assign_arg(args_state_t arg_type, void *arg)
+{
+ args_t *temp, cur;
+ char *str = arg;
+ returns_t *ret;
+
+ if (verbose) {
+ fprintf(stderr, "function is >%s<, adding arg >%s< type %s\n",
+ command.function, str, args_enum_names[arg_type]);
+ }
+
+ cur.arg_type = arg_type;
+ switch (arg_type) {
+ case arg_var:
+ cur.var_index = find_var_index(arg);
+ if (cur.var_index < 0)
+ err(1, "Invalid variable %s at line %zu of file %s",
+ str, line, cur_file);
+ cur.arg_type = ret_string;
+ break;
+
+ case arg_byte:
+ ret = arg;
+ cur.arg_len = ret->return_len;
+ cur.arg_string = malloc(cur.arg_len);
+ if (cur.arg_string == NULL)
+ err(1, "Could not malloc memory for arg bytes");
+ memcpy(cur.arg_string, ret->return_value, cur.arg_len);
+ break;
+
+ case arg_null:
+ cur.arg_len = 0;
+ cur.arg_string = NULL;
+ break;
+
+ default:
+ cur.arg_len = strlen(str);
+ cur.arg_string = malloc(cur.arg_len + 1);
+ if (cur.arg_string == NULL)
+ err(1, "Could not malloc memory for arg string");
+ strcpy(cur.arg_string, arg);
+ }
+
+ temp = realloc(command.args, sizeof(*temp) * (command.nargs + 1));
+ if (temp == NULL)
+ err(1, "Failed to reallocate args");
+ command.args = temp;
+ memcpy(&command.args[command.nargs], &cur, sizeof(args_t));
+ command.nargs++;
+}
+
+/*
+ * Allocate and assign a new return.
+ */
+static void
+assign_rets(returns_enum_t ret_type, void *ret)
+{
+ returns_t *temp, cur;
+ char *ret_str;
+ returns_t *ret_ret;
+
+ cur.return_type = ret_type;
+ if (ret_type != ret_var) {
+ if ((ret_type == ret_number) || (ret_type == ret_string)) {
+ ret_str = ret;
+ cur.return_len = strlen(ret_str) + 1;
+ cur.return_value = malloc(cur.return_len + 1);
+ if (cur.return_value == NULL)
+ err(1,
+ "Could not malloc memory for arg string");
+ strcpy(cur.return_value, ret_str);
+ } else if (ret_type == ret_byte) {
+ ret_ret = ret;
+ cur.return_len = ret_ret->return_len;
+ cur.return_value = malloc(cur.return_len);
+ if (cur.return_value == NULL)
+ err(1,
+ "Could not malloc memory for byte string");
+ memcpy(cur.return_value, ret_ret->return_value,
+ cur.return_len);
+ } else if (ret_type == ret_ref) {
+ if ((cur.return_index = find_var_index(ret)) < 0)
+ err(1, "Undefined variable reference");
+ }
+ } else {
+ cur.return_index = find_var_index(ret);
+ if (cur.return_index < 0)
+ cur.return_index = assign_var(ret);
+ }
+
+ temp = realloc(command.returns, sizeof(*temp) * (command.nrets + 1));
+ if (temp == NULL)
+ err(1, "Failed to reallocate returns");
+ command.returns = temp;
+ memcpy(&command.returns[command.nrets], &cur, sizeof(returns_t));
+ command.nrets++;
+}
+
+/*
+ * Find the given variable name in the var array and return the i
+ * return -1 if var is not found.
+ */
+static int
+find_var_index(const char *var_name)
+{
+ int result;
+ size_t i;
+
+ result = -1;
+
+ for (i = 0; i < nvars; i++) {
+ if (strcmp(var_name, vars[i].name) == 0) {
+ result = i;
+ break;
+ }
+ }
+
+ return result;
+}
+
+/*
+ * Check the given function name in the given table of names, return 1 if
+ * there is a match.
+ */
+static int check_function_table(char *function, const char *table[],
+ int nfunctions)
+{
+ int i;
+
+ for (i = 0; i < nfunctions; i++) {
+ if ((strlen(function) == strlen(table[i])) &&
+ (strcmp(function, table[i]) == 0))
+ return 1;
+ }
+
+ return 0;
+}
+
+/*
+ * Compare the output from the slave against the given file and report
+ * any differences.
+ */
+static void
+compare_streams(char *filename, bool discard)
+{
+ char check_file[PATH_MAX], drain[100], ref, data;
+ struct pollfd fds[2];
+ int nfd, check_fd;
+ ssize_t result;
+ size_t offs;
+
+ /*
+ * Don't prepend check path iff check file has an absolute
+ * path.
+ */
+ if (filename[0] != '/') {
+ if (strlcpy(check_file, check_path, sizeof(check_file))
+ >= sizeof(check_file))
+ err(2, "CHECK_PATH too long");
+
+ if (strlcat(check_file, "/", sizeof(check_file))
+ >= sizeof(check_file))
+ err(2, "Could not append / to check file path");
+ } else {
+ check_file[0] = '\0';
+ }
+
+ if (strlcat(check_file, filename, sizeof(check_file))
+ >= sizeof(check_file))
+ err(2, "Path to check file path overflowed");
+
+ if ((check_fd = open(check_file, O_RDONLY, 0)) < 0)
+ err(2, "failed to open file %s line %zu of file %s",
+ check_file, line, cur_file);
+
+ fds[0].fd = check_fd;
+ fds[0].events = POLLIN;
+ fds[1].fd = master;
+ fds[1].events = POLLIN;
+
+ nfd = 2;
+ /*
+ * if we have saved output then only check for data in the
+ * reference file since the slave data may already be drained.
+ */
+ if (saved_output.count > 0)
+ nfd = 1;
+
+ offs = 0;
+ while (poll(fds, nfd, 500) == nfd) {
+ if (fds[0].revents & POLLIN) {
+ if ((result = read(check_fd, &ref, 1)) < 1) {
+ if (result != 0) {
+ err(2,
+ "Bad read on file %s", check_file);
+ } else {
+ break;
+ }
+ }
+ }
+
+ if (saved_output.count > 0) {
+ data = saved_output.data[saved_output.readp];
+ saved_output.count--;
+ saved_output.readp++;
+ /* run out of saved data, switch to file */
+ if (saved_output.count == 0)
+ nfd = 2;
+ } else {
+ if (fds[0].revents & POLLIN) {
+ if (read(master, &data, 1) < 1)
+ err(2, "Bad read on slave pty");
+ } else
+ continue;
+ }
+
+ if (verbose) {
+ fprintf(stderr, "Comparing reference byte 0x%x (%c)"
+ " against slave byte 0x%x (%c)\n",
+ ref, (ref >= ' ') ? ref : '-',
+ data, (data >= ' ' )? data : '-');
+ }
+
+ if (ref != data) {
+ errx(2, "%s, %zu: refresh data from slave does "
+ "not match expected from file %s offs %zu "
+ "[reference 0x%x (%c) != slave 0x%x (%c)]",
+ cur_file, line, check_file, offs,
+ ref, (ref >= ' ') ? ref : '-',
+ data, (data >= ' ') ? data : '-');
+ }
+
+ offs++;
+ }
+
+
+ if (saved_output.count > 0)
+ excess(cur_file, line, __func__, " from slave",
+ &saved_output.data[saved_output.readp], saved_output.count);
+
+ /* discard any excess saved output if required */
+ if (discard) {
+ saved_output.count = 0;
+ saved_output.readp = 0;
+ }
+
+ if ((result = poll(&fds[0], 2, 0)) != 0) {
+ if (result == -1)
+ err(2, "poll of file descriptors failed");
+
+ if ((fds[1].revents & POLLIN) == POLLIN) {
+ save_slave_output(true);
+ } else if ((fds[0].revents & POLLIN) == POLLIN) {
+ /*
+ * handle excess in file if it exists. Poll
+ * says there is data until EOF is read.
+ * Check next read is EOF, if it is not then
+ * the file really has more data than the
+ * slave produced so flag this as a warning.
+ */
+ result = read(check_fd, drain, sizeof(drain));
+ if (result == -1)
+ err(1, "read of data file failed");
+
+ if (result > 0) {
+ excess(check_file, 0, __func__, "", drain,
+ result);
+ }
+ }
+ }
+
+ close(check_fd);
+}
+
+/*
+ * Pass a function call and arguments to the slave and wait for the
+ * results. The variable nresults determines how many returns we expect
+ * back from the slave. These results will be validated against the
+ * expected returns or assigned to variables.
+ */
+static void
+do_function_call(size_t nresults)
+{
+#define MAX_RESULTS 4
+ char *p;
+ int do_input;
+ size_t i;
+ struct pollfd fds[3];
+ returns_t response[MAX_RESULTS], returns_count;
+ assert(nresults <= MAX_RESULTS);
+
+ do_input = check_function_table(command.function, input_functions,
+ ninput_functions);
+
+ write_func_and_args();
+
+ /*
+ * We should get the number of returns back here, grab it before
+ * doing input otherwise it will confuse the input poll
+ */
+ read_cmd_pipe(&returns_count);
+ if (returns_count.return_type != ret_count)
+ err(2, "expected return type of ret_count but received %s",
+ returns_enum_names[returns_count.return_type]);
+
+ perform_delay(&delay_post_call); /* let slave catch up */
+
+ if (verbose) {
+ fprintf(stderr, "Expect %zu results from slave, slave "
+ "reported %zu\n", nresults, returns_count.return_len);
+ }
+
+ if ((no_input == false) && (do_input == 1)) {
+ if (verbose) {
+ fprintf(stderr, "doing input with inputstr >%s<\n",
+ input_str);
+ }
+
+ if (input_str == NULL)
+ errx(2, "%s, %zu: Call to input function "
+ "but no input defined", cur_file, line);
+
+ fds[0].fd = slvpipe[READ_PIPE];
+ fds[0].events = POLLIN;
+ fds[1].fd = master;
+ fds[1].events = POLLOUT;
+ p = input_str;
+ save_slave_output(false);
+ while(*p != '\0') {
+ perform_delay(&delay_spec);
+
+ if (poll(fds, 2, 0) < 0)
+ err(2, "poll failed");
+ if (fds[0].revents & POLLIN) {
+ warnx("%s, %zu: Slave function "
+ "returned before end of input string",
+ cur_file, line);
+ break;
+ }
+ if ((fds[1].revents & POLLOUT) == 0)
+ continue;
+ if (verbose) {
+ fprintf(stderr, "Writing char >%c< to slave\n",
+ *p);
+ }
+ if (write(master, p, 1) != 1) {
+ warn("%s, %zu: Slave function write error",
+ cur_file, line);
+ break;
+ }
+ p++;
+
+ }
+ save_slave_output(false);
+
+ if (verbose) {
+ fprintf(stderr, "Input done.\n");
+ }
+
+ /* done with the input string, free the resources */
+ free(input_str);
+ input_str = NULL;
+ }
+
+ if (verbose) {
+ fds[0].fd = slvpipe[READ_PIPE];
+ fds[0].events = POLLIN;
+
+ fds[1].fd = slvpipe[WRITE_PIPE];
+ fds[1].events = POLLOUT;
+
+ fds[2].fd = master;
+ fds[2].events = POLLIN | POLLOUT;
+
+ i = poll(&fds[0], 3, 1000);
+ fprintf(stderr, "Poll returned %zu\n", i);
+ for (i = 0; i < 3; i++) {
+ fprintf(stderr, "revents for fd[%zu] = 0x%x\n",
+ i, fds[i].revents);
+ }
+ }
+
+ /* drain any trailing output */
+ save_slave_output(false);
+
+ for (i = 0; i < returns_count.return_len; i++) {
+ read_cmd_pipe(&response[i]);
+ }
+
+ /*
+ * Check for a slave error in the first return slot, if the
+ * slave errored then we may not have the number of returns we
+ * expect but in this case we should report the slave error
+ * instead of a return count mismatch.
+ */
+ if ((returns_count.return_len > 0) &&
+ (response[0].return_type == ret_slave_error))
+ err(2, "Slave returned error: %s",
+ (const char *)response[0].return_value);
+
+ if (returns_count.return_len != nresults)
+ err(2, "Incorrect number of returns from slave, expected %zu "
+ "but received %zu", nresults, returns_count.return_len);
+
+ if (verbose) {
+ for (i = 0; i < nresults; i++) {
+ if ((response[i].return_type != ret_byte) &&
+ (response[i].return_type != ret_err) &&
+ (response[i].return_type != ret_ok))
+ fprintf(stderr,
+ "received response >%s< "
+ "expected",
+ (const char *)response[i].return_value);
+ else
+ fprintf(stderr, "received");
+
+ fprintf(stderr, " return_type %s\n",
+ returns_enum_names[command.returns[i].return_type]);
+ }
+ }
+
+ for (i = 0; i < nresults; i++) {
+ if (command.returns[i].return_type != ret_var) {
+ validate(i, &response[i]);
+ } else {
+ vars[command.returns[i].return_index].len =
+ response[i].return_len;
+ vars[command.returns[i].return_index].value =
+ response[i].return_value;
+ vars[command.returns[i].return_index].type =
+ response[i].return_type;
+ }
+ }
+
+ if (verbose && (saved_output.count > 0))
+ excess(cur_file, line, __func__, " from slave",
+ &saved_output.data[saved_output.readp], saved_output.count);
+
+ init_parse_variables(0);
+}
+
+/*
+ * Write the function and command arguments to the command pipe.
+ */
+static void
+write_func_and_args(void)
+{
+ int i;
+
+ if (verbose) {
+ fprintf(stderr, "calling function >%s<\n", command.function);
+ }
+
+ write_cmd_pipe(command.function);
+ for (i = 0; i < command.nargs; i++) {
+ if (command.args[i].arg_type == arg_var)
+ write_cmd_pipe_args(command.args[i].arg_type,
+ &vars[command.args[i].var_index]);
+ else
+ write_cmd_pipe_args(command.args[i].arg_type,
+ &command.args[i]);
+ }
+
+ write_cmd_pipe(NULL); /* signal end of arguments */
+}
+
+/*
+ * Initialise the command structure - if initial is non-zero then just set
+ * everything to sane values otherwise free any memory that was allocated
+ * when building the structure.
+ */
+void
+init_parse_variables(int initial)
+{
+ int i, result;
+ struct pollfd slave_pty;
+
+ if (initial == 0) {
+ free(command.function);
+ for (i = 0; i < command.nrets; i++) {
+ if (command.returns[i].return_type == ret_number)
+ free(command.returns[i].return_value);
+ }
+ free(command.returns);
+
+ for (i = 0; i < command.nargs; i++) {
+ if (command.args[i].arg_type != arg_var)
+ free(command.args[i].arg_string);
+ }
+ free(command.args);
+ } else {
+ line = 0;
+ input_delay = 0;
+ vars = NULL;
+ nvars = 0;
+ input_str = NULL;
+ saved_output.allocated = 0;
+ saved_output.count = 0;
+ saved_output.readp = 0;
+ saved_output.data = NULL;
+ }
+
+ no_input = false;
+ command.function = NULL;
+ command.nargs = 0;
+ command.args = NULL;
+ command.nrets = 0;
+ command.returns = NULL;
+
+ /*
+ * Check the slave pty for stray output from the slave, at this
+ * point we should not see any data as it should have been
+ * consumed by the test functions. If we see data then we have
+ * either a bug or are not handling an output generating function
+ * correctly.
+ */
+ slave_pty.fd = master;
+ slave_pty.events = POLLIN;
+ result = poll(&slave_pty, 1, 0);
+
+ if (result < 0)
+ err(2, "Poll of slave pty failed");
+ else if (result > 0)
+ warnx("%s, %zu: Unexpected data from slave", cur_file, line);
+}
+
+/*
+ * Validate the response against the expected return. The variable
+ * i is the i into the rets array in command.
+ */
+static void
+validate(int i, void *data)
+{
+ char *response;
+ returns_t *byte_response;
+
+ byte_response = data;
+ if ((command.returns[i].return_type != ret_byte) &&
+ (command.returns[i].return_type != ret_err) &&
+ (command.returns[i].return_type != ret_ok)) {
+ if ((byte_response->return_type == ret_byte) ||
+ (byte_response->return_type == ret_err) ||
+ (byte_response->return_type == ret_ok))
+ err(1, "%s: expecting type %s, received type %s"
+ " at line %zu of file %s", __func__,
+ returns_enum_names[command.returns[i].return_type],
+ returns_enum_names[byte_response->return_type],
+ line, cur_file);
+
+ response = byte_response->return_value;
+ }
+
+ switch (command.returns[i].return_type) {
+ case ret_err:
+ validate_type(ret_err, byte_response, 0);
+ break;
+
+ case ret_ok:
+ validate_type(ret_ok, byte_response, 0);
+ break;
+
+ case ret_null:
+ validate_return("NULL", response, 0);
+ break;
+
+ case ret_nonnull:
+ validate_return("NULL", response, 1);
+ break;
+
+ case ret_string:
+ case ret_number:
+ validate_return(command.returns[i].return_value,
+ response, 0);
+ break;
+
+ case ret_ref:
+ validate_reference(i, response);
+ break;
+
+ case ret_byte:
+ validate_byte(&command.returns[i], byte_response, 0);
+ break;
+
+ default:
+ err(1, "Malformed statement at line %zu of file %s",
+ line, cur_file);
+ break;
+ }
+}
+
+/*
+ * Validate the return against the contents of a variable.
+ */
+static void
+validate_reference(int i, void *data)
+{
+ char *response;
+ returns_t *byte_response;
+ var_t *varp;
+
+ varp = &vars[command.returns[i].return_index];
+
+ byte_response = data;
+ if (command.returns[i].return_type != ret_byte)
+ response = data;
+
+ if (verbose) {
+ fprintf(stderr,
+ "%s: return type of %s, value %s \n", __func__,
+ returns_enum_names[varp->type],
+ (const char *)varp->value);
+ }
+
+ switch (varp->type) {
+ case ret_string:
+ case ret_number:
+ validate_return(varp->value, response, 0);
+ break;
+
+ case ret_byte:
+ validate_byte(varp->value, byte_response, 0);
+ break;
+
+ default:
+ err(1,
+ "Invalid return type for reference at line %zu of file %s",
+ line, cur_file);
+ break;
+ }
+}
+
+/*
+ * Validate the return type against the expected type, throw an error
+ * if they don't match.
+ */
+static void
+validate_type(returns_enum_t expected, returns_t *value, int check)
+{
+ if (((check == 0) && (expected != value->return_type)) ||
+ ((check == 1) && (expected == value->return_type)))
+ err(1, "Validate expected type %s %s %s line %zu of file %s",
+ returns_enum_names[expected],
+ (check == 0)? "matching" : "not matching",
+ returns_enum_names[value->return_type], line, cur_file);
+
+ if (verbose) {
+ fprintf(stderr, "Validate expected type %s %s %s line %zu"
+ " of file %s\n",
+ returns_enum_names[expected],
+ (check == 0)? "matching" : "not matching",
+ returns_enum_names[value->return_type], line, cur_file);
+ }
+}
+
+/*
+ * Validate the return value against the expected value, throw an error
+ * if they don't match.
+ */
+static void
+validate_return(const char *expected, const char *value, int check)
+{
+ if (((check == 0) && strcmp(expected, value) != 0) ||
+ ((check == 1) && strcmp(expected, value) == 0))
+ errx(1, "Validate expected %s %s %s line %zu of file %s",
+ expected,
+ (check == 0)? "matching" : "not matching", value,
+ line, cur_file);
+ if (verbose) {
+ fprintf(stderr, "Validated expected value %s %s %s "
+ "at line %zu of file %s\n", expected,
+ (check == 0)? "matches" : "does not match",
+ value, line, cur_file);
+ }
+}
+
+/*
+ * Validate the return value against the expected value, throw an error
+ * if they don't match expectations.
+ */
+static void
+validate_byte(returns_t *expected, returns_t *value, int check)
+{
+ char *ch;
+ size_t i;
+
+ if (verbose) {
+ ch = value->return_value;
+ fprintf(stderr, "checking returned byte stream: ");
+ for (i = 0; i < value->return_len; i++)
+ fprintf(stderr, "%s0x%x", (i != 0)? ", " : "", ch[i]);
+ fprintf(stderr, "\n");
+
+ fprintf(stderr, "%s byte stream: ",
+ (check == 0)? "matches" : "does not match");
+ ch = (char *) expected->return_value;
+ for (i = 0; i < expected->return_len; i++)
+ fprintf(stderr, "%s0x%x", (i != 0)? ", " : "", ch[i]);
+ fprintf(stderr, "\n");
+ }
+
+ /*
+ * No chance of a match if lengths differ...
+ */
+ if ((check == 0) && (expected->return_len != value->return_len))
+ errx(1, "Byte validation failed, length mismatch, expected %zu,"
+ "received %zu", expected->return_len, value->return_len);
+
+ /*
+ * If check is 0 then we want to throw an error IFF the byte streams
+ * do not match, if check is 1 then throw an error if the byte
+ * streams match.
+ */
+ if (((check == 0) && memcmp(expected->return_value, value->return_value,
+ value->return_len) != 0) ||
+ ((check == 1) && (expected->return_len == value->return_len) &&
+ memcmp(expected->return_value, value->return_value,
+ value->return_len) == 0))
+ errx(1, "Validate expected %s byte stream at line %zu"
+ "of file %s",
+ (check == 0)? "matching" : "not matching", line, cur_file);
+ if (verbose) {
+ fprintf(stderr, "Validated expected %s byte stream "
+ "at line %zu of file %s\n",
+ (check == 0)? "matching" : "not matching",
+ line, cur_file);
+ }
+}
+
+/*
+ * Validate the variable at i against the expected value, throw an
+ * error if they don't match, if check is non-zero then the match is
+ * negated.
+ */
+static void
+validate_variable(int ret, returns_enum_t type, const void *value, int i,
+ int check)
+{
+ returns_t *retval;
+ var_t *varptr;
+
+ retval = &command.returns[ret];
+ varptr = &vars[command.returns[ret].return_index];
+
+ if (varptr->value == NULL)
+ err(1, "Variable %s has no value assigned to it", varptr->name);
+
+
+ if (varptr->type != type)
+ err(1, "Variable %s is not the expected type", varptr->name);
+
+ if (type != ret_byte) {
+ if ((((check == 0) && strcmp(value, varptr->value) != 0))
+ || ((check == 1) && strcmp(value, varptr->value) == 0))
+ err(1, "Variable %s contains %s instead of %s"
+ " value %s at line %zu of file %s",
+ varptr->name, (const char *)varptr->value,
+ (check == 0)? "expected" : "not matching",
+ (const char *)value,
+ line, cur_file);
+ if (verbose) {
+ fprintf(stderr, "Variable %s contains %s value "
+ "%s at line %zu of file %s\n",
+ varptr->name,
+ (check == 0)? "expected" : "not matching",
+ (const char *)varptr->value, line, cur_file);
+ }
+ } else {
+ if ((check == 0) && (retval->return_len != varptr->len))
+ err(1, "Byte validation failed, length mismatch");
+
+ /*
+ * If check is 0 then we want to throw an error IFF
+ * the byte streams do not match, if check is 1 then
+ * throw an error if the byte streams match.
+ */
+ if (((check == 0) && memcmp(retval->return_value, varptr->value,
+ varptr->len) != 0) ||
+ ((check == 1) && (retval->return_len == varptr->len) &&
+ memcmp(retval->return_value, varptr->value,
+ varptr->len) == 0))
+ err(1, "Validate expected %s byte stream at line %zu"
+ " of file %s",
+ (check == 0)? "matching" : "not matching",
+ line, cur_file);
+ if (verbose) {
+ fprintf(stderr, "Validated expected %s byte stream "
+ "at line %zu of file %s\n",
+ (check == 0)? "matching" : "not matching",
+ line, cur_file);
+ }
+ }
+}
+
+/*
+ * Write a string to the command pipe - we feed the number of bytes coming
+ * down first to allow storage allocation and then follow up with the data.
+ * If cmd is NULL then feed a -1 down the pipe to say the end of the args.
+ */
+static void
+write_cmd_pipe(char *cmd)
+{
+ args_t arg;
+ size_t len;
+
+ if (cmd == NULL)
+ len = 0;
+ else
+ len = strlen(cmd);
+
+ arg.arg_type = arg_static;
+ arg.arg_len = len;
+ arg.arg_string = cmd;
+ write_cmd_pipe_args(arg.arg_type, &arg);
+
+}
+
+static void
+write_cmd_pipe_args(args_state_t type, void *data)
+{
+ var_t *var_data;
+ args_t *arg_data;
+ int len, send_type;
+ void *cmd;
+
+ arg_data = data;
+ switch (type) {
+ case arg_var:
+ var_data = data;
+ len = var_data->len;
+ cmd = var_data->value;
+ if (type == arg_byte)
+ send_type = ret_byte;
+ else
+ send_type = ret_string;
+ break;
+
+ case arg_null:
+ send_type = ret_null;
+ len = 0;
+ break;
+
+ default:
+ if ((arg_data->arg_len == 0) && (arg_data->arg_string == NULL))
+ len = -1;
+ else
+ len = arg_data->arg_len;
+ cmd = arg_data->arg_string;
+ if (type == arg_byte)
+ send_type = ret_byte;
+ else
+ send_type = ret_string;
+ }
+
+ if (verbose) {
+ fprintf(stderr, "Writing type %s to command pipe\n",
+ returns_enum_names[send_type]);
+ }
+
+ if (write(cmdpipe[WRITE_PIPE], &send_type, sizeof(int)) < 0)
+ err(1, "command pipe write for type failed");
+
+ if (verbose) {
+ fprintf(stderr, "Writing length %d to command pipe\n", len);
+ }
+
+ if (write(cmdpipe[WRITE_PIPE], &len, sizeof(int)) < 0)
+ err(1, "command pipe write for length failed");
+
+ if (len > 0) {
+ if (verbose) {
+ fprintf(stderr, "Writing data >%s< to command pipe\n",
+ (const char *)cmd);
+ }
+ if (write(cmdpipe[WRITE_PIPE], cmd, len) < 0)
+ err(1, "command pipe write of data failed");
+ }
+}
+
+/*
+ * Read a response from the command pipe, first we will receive the
+ * length of the response then the actual data.
+ */
+static void
+read_cmd_pipe(returns_t *response)
+{
+ int len, type;
+ struct pollfd rfd[2];
+ char *str;
+
+ /*
+ * Check if there is data to read - just in case slave has died, we
+ * don't want to block on the read and just hang. We also check
+ * output from the slave because the slave may be blocked waiting
+ * for a flush on its stdout.
+ */
+ rfd[0].fd = slvpipe[READ_PIPE];
+ rfd[0].events = POLLIN;
+ rfd[1].fd = master;
+ rfd[1].events = POLLIN;
+
+ do {
+ if (poll(rfd, 2, 4000) == 0)
+ errx(2, "%s, %zu: Command pipe read timeout",
+ cur_file, line);
+
+ if ((rfd[1].revents & POLLIN) == POLLIN) {
+ if (verbose) {
+ fprintf(stderr,
+ "draining output from slave\n");
+ }
+ save_slave_output(false);
+ }
+ }
+ while((rfd[1].revents & POLLIN) == POLLIN);
+
+ if (read(slvpipe[READ_PIPE], &type, sizeof(int)) < 0)
+ err(1, "command pipe read for type failed");
+ response->return_type = type;
+
+ if ((type != ret_ok) && (type != ret_err) && (type != ret_count)) {
+ if (read(slvpipe[READ_PIPE], &len, sizeof(int)) < 0)
+ err(1, "command pipe read for length failed");
+ response->return_len = len;
+
+ if (verbose) {
+ fprintf(stderr,
+ "Reading %d bytes from command pipe\n", len);
+ }
+
+ if ((response->return_value = malloc(len + 1)) == NULL)
+ err(1, "Failed to alloc memory for cmd pipe read");
+
+ if (read(slvpipe[READ_PIPE], response->return_value, len) < 0)
+ err(1, "command pipe read of data failed");
+
+ if (response->return_type != ret_byte) {
+ str = response->return_value;
+ str[len] = '\0';
+
+ if (verbose) {
+ fprintf(stderr, "Read data >%s< from pipe\n",
+ (const char *)response->return_value);
+ }
+ }
+ } else {
+ response->return_value = NULL;
+ if (type == ret_count) {
+ if (read(slvpipe[READ_PIPE], &len, sizeof(int)) < 0)
+ err(1, "command pipe read for number of "
+ "returns failed");
+ response->return_len = len;
+ }
+
+ if (verbose) {
+ fprintf(stderr, "Read type %s from pipe\n",
+ returns_enum_names[type]);
+ }
+ }
+}
+
+/*
+ * Check for writes from the slave on the pty, save the output into a
+ * buffer for later checking if discard is false.
+ */
+#define MAX_DRAIN 256
+
+static void
+save_slave_output(bool discard)
+{
+ char *new_data, drain[MAX_DRAIN];
+ size_t to_allocate;
+ ssize_t result;
+ size_t i;
+
+ result = 0;
+ for (;;) {
+ if (result == -1)
+ err(2, "poll of slave pty failed");
+ result = MAX_DRAIN;
+ if ((result = read(master, drain, result)) < 0) {
+ if (errno == EAGAIN)
+ break;
+ else
+ err(2, "draining slave pty failed");
+ }
+ if (result == 0)
+ abort();
+
+ if (!discard) {
+ if ((size_t)result >
+ (saved_output.allocated - saved_output.count)) {
+ to_allocate = 1024 * ((result / 1024) + 1);
+
+ if ((new_data = realloc(saved_output.data,
+ saved_output.allocated + to_allocate))
+ == NULL)
+ err(2, "Realloc of saved_output failed");
+ saved_output.data = new_data;
+ saved_output.allocated += to_allocate;
+ }
+
+ if (verbose) {
+ fprintf(stderr, "count = %zu, "
+ "allocated = %zu\n", saved_output.count,
+ saved_output.allocated);
+ for (i = 0; i < (size_t)result; i++) {
+ fprintf(stderr, "Saving slave output "
+ "at %zu: 0x%x (%c)\n",
+ saved_output.count + i, drain[i],
+ (drain[i] >= ' ')? drain[i] : '-');
+ }
+ }
+
+ memcpy(&saved_output.data[saved_output.count], drain,
+ result);
+ saved_output.count += result;
+
+ if (verbose) {
+ fprintf(stderr, "count = %zu, "
+ "allocated = %zu\n", saved_output.count,
+ saved_output.allocated);
+ }
+ } else {
+ if (verbose) {
+ for (i = 0; i < (size_t)result; i++) {
+ fprintf(stderr, "Discarding slave "
+ "output 0x%x (%c)\n",
+ drain[i],
+ (drain[i] >= ' ')? drain[i] : '-');
+ }
+ }
+ }
+ }
+}
+
+static void
+yyerror(const char *msg)
+{
+ warnx("%s in line %zu of file %s", msg, line, cur_file);
+}
diff --git a/contrib/netbsd-tests/lib/libcurses/slave/command_table.h b/contrib/netbsd-tests/lib/libcurses/slave/command_table.h
new file mode 100644
index 0000000..ef57a00
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/slave/command_table.h
@@ -0,0 +1,397 @@
+/* $NetBSD: command_table.h,v 1.3 2011/09/15 11:46:19 blymn Exp $ */
+
+/*-
+ * Copyright 2009 Brett Lymn <blymn@NetBSD.org>
+ *
+ * All rights reserved.
+ *
+ * This code has been donated to The NetBSD Foundation by the Author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ */
+
+#ifndef _COMMAND_TABLE_H_
+#define _COMMAND_TABLE_H_
+
+#include "curses_commands.h"
+
+/*
+ * Curses commands
+ */
+struct command_def commands[] = {
+ {"DRAIN", cmd_DRAIN},
+ {"addbytes", cmd_addbytes},
+ {"addch", cmd_addch},
+ {"addchnstr", cmd_addchnstr},
+ {"addchstr", cmd_addchstr},
+ {"addnstr", cmd_addnstr},
+ {"addstr", cmd_addstr},
+ {"attr_get", cmd_attr_get},
+ {"attr_off", cmd_attr_off},
+ {"attr_on", cmd_attr_on},
+ {"attr_set", cmd_attr_set},
+ {"attroff", cmd_attroff},
+ {"attron", cmd_attron},
+ {"attrset", cmd_attrset},
+ {"bkgd", cmd_bkgd},
+ {"bkgdset", cmd_bkgdset},
+ {"border", cmd_border},
+ {"clear", cmd_clear},
+ {"clrtobot", cmd_clrtobot},
+ {"clrtoeol", cmd_clrtoeol},
+ {"color_set", cmd_color_set},
+ {"delch", cmd_delch},
+ {"deleteln", cmd_deleteln},
+ {"echochar", cmd_echochar},
+ {"erase", cmd_erase},
+ {"getch", cmd_getch},
+ {"getnstr", cmd_getnstr},
+ {"getstr", cmd_getstr},
+ {"inch", cmd_inch},
+ {"inchnstr", cmd_inchnstr},
+ {"inchstr", cmd_inchstr},
+ {"innstr", cmd_innstr},
+ {"insch", cmd_insch},
+ {"insdelln", cmd_insdelln},
+ {"insertln", cmd_insertln},
+ {"instr", cmd_instr},
+ {"move", cmd_move},
+ {"refresh", cmd_refresh},
+ {"scrl", cmd_scrl},
+ {"setscrreg", cmd_setscrreg},
+ {"standend", cmd_standend},
+ {"standout", cmd_standout},
+ {"timeout", cmd_timeout},
+ {"underscore", cmd_underscore},
+ {"underend", cmd_underend},
+ {"waddbytes", cmd_waddbytes},
+ {"waddstr", cmd_waddstr},
+ {"mvaddbytes", cmd_mvaddbytes},
+ {"mvaddch", cmd_mvaddch},
+ {"mvaddchnstr", cmd_mvaddchnstr},
+ {"mvaddchstr", cmd_mvaddchstr},
+ {"mvaddnstr", cmd_mvaddnstr},
+ {"mvaddstr", cmd_mvaddstr},
+ {"mvdelch", cmd_mvdelch},
+ {"mvgetch", cmd_mvgetch},
+ {"mvgetnstr", cmd_mvgetnstr},
+ {"mvgetstr", cmd_mvgetstr},
+ {"mvinch", cmd_mvinch},
+ {"mvinchnstr", cmd_mvinchnstr},
+ {"mvinchstr", cmd_mvinchstr},
+ {"mvinnstr", cmd_mvinnstr},
+ {"mvinsch", cmd_mvinsch},
+ {"mvinstr", cmd_mvinstr},
+ {"mvwaddbytes", cmd_mvwaddbytes},
+ {"mvwaddch", cmd_mvwaddch},
+ {"mvwaddchnstr", cmd_mvwaddchnstr},
+ {"mvwaddchstr", cmd_mvwaddchstr},
+ {"mvwaddnstr", cmd_mvwaddnstr},
+ {"mvwaddstr", cmd_mvwaddstr},
+ {"mvwdelch", cmd_mvwdelch},
+ {"mvwgetch", cmd_mvwgetch},
+ {"mvwgetnstr", cmd_mvwgetnstr},
+ {"mvwgetstr", cmd_mvwgetstr},
+ {"mvwinch", cmd_mvwinch},
+ {"mvwinsch", cmd_mvwinsch},
+ {"assume_default_colors", cmd_assume_default_colors},
+ {"baudrate", cmd_baudrate},
+ {"beep", cmd_beep},
+ {"box", cmd_box},
+ {"can_change_color", cmd_can_change_color},
+ {"cbreak", cmd_cbreak},
+ {"clearok", cmd_clearok},
+ {"color_content", cmd_color_content},
+ {"copywin", cmd_copywin},
+ {"curs_set", cmd_curs_set},
+ {"def_prog_mode", cmd_def_prog_mode},
+ {"def_shell_mode", cmd_def_shell_mode},
+ {"define_key", cmd_define_key},
+ {"delay_output", cmd_delay_output},
+ {"delscreen", cmd_delscreen},
+ {"delwin", cmd_delwin},
+ {"derwin", cmd_derwin},
+ {"dupwin", cmd_dupwin},
+ {"doupdate", cmd_doupdate},
+ {"echo", cmd_echo},
+ {"endwin", cmd_endwin},
+ {"erasechar", cmd_erasechar},
+ {"flash", cmd_flash},
+ {"flushinp", cmd_flushinp},
+ {"flushok", cmd_flushok},
+ {"fullname", cmd_fullname},
+ {"getattrs", cmd_getattrs},
+ {"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},
+ {"has_colors", cmd_has_colors},
+ {"has_ic", cmd_has_ic},
+ {"has_il", cmd_has_il},
+ {"hline", cmd_hline},
+ {"idcok", cmd_idcok},
+ {"idlok", cmd_idlok},
+ {"init_color", cmd_init_color},
+ {"init_pair", cmd_init_pair},
+ {"initscr", cmd_initscr},
+ {"intrflush", cmd_intrflush},
+ {"isendwin", cmd_isendwin},
+ {"is_linetouched", cmd_is_linetouched},
+ {"is_wintouched", cmd_is_wintouched},
+ {"keyok", cmd_keyok},
+ {"keypad", cmd_keypad},
+ {"keyname", cmd_keyname},
+ {"killchar", cmd_killchar},
+ {"leaveok", cmd_leaveok},
+ {"meta", cmd_meta},
+ {"mvcur", cmd_mvcur},
+ {"mvderwin", cmd_mvderwin},
+ {"mvhline", cmd_mvhline},
+ {"mvprintw", cmd_mvprintw},
+ {"mvscanw", cmd_mvscanw},
+ {"mvvline", cmd_mvvline},
+ {"mvwhline", cmd_mvwhline},
+ {"mvwvline", cmd_mvwvline},
+ {"mvwin", cmd_mvwin},
+ {"mvwinchnstr", cmd_mvwinchnstr},
+ {"mvwinchstr", cmd_mvwinchstr},
+ {"mvwinnstr", cmd_mvwinnstr},
+ {"mvwinstr", cmd_mvwinstr},
+ {"mvwprintw", cmd_mvwprintw},
+ {"mvwscanw", cmd_mvwscanw},
+ {"napms", cmd_napms},
+ {"newpad", cmd_newpad},
+ {"newterm", cmd_newterm},
+ {"newwin", cmd_newwin},
+ {"nl", cmd_nl},
+ {"no_color_attributes", cmd_no_color_attributes},
+ {"nocbreak", cmd_nocbreak},
+ {"nodelay", cmd_nodelay},
+ {"noecho", cmd_noecho},
+ {"nonl", cmd_nonl},
+ {"noqiflush", cmd_noqiflush},
+ {"noraw", cmd_noraw},
+ {"notimeout", cmd_notimeout},
+ {"overlay", cmd_overlay},
+ {"overwrite", cmd_overwrite},
+ {"pair_content", cmd_pair_content},
+ {"pechochar", cmd_pechochar},
+ {"pnoutrefresh", cmd_pnoutrefresh},
+ {"prefresh", cmd_prefresh},
+ {"printw", cmd_printw},
+ {"putwin", cmd_putwin},
+ {"qiflush", cmd_qiflush},
+ {"raw", cmd_raw},
+ {"redrawwin", cmd_redrawwin},
+ {"reset_prog_mode", cmd_reset_prog_mode},
+ {"reset_shell_mode", cmd_reset_shell_mode},
+ {"resetty", cmd_resetty},
+ {"resizeterm", cmd_resizeterm},
+ {"savetty", cmd_savetty},
+ {"scanw", cmd_scanw},
+ {"scroll", cmd_scroll},
+ {"scrollok", cmd_scrollok},
+ {"setterm", cmd_setterm},
+ {"set_term", cmd_set_term},
+ {"start_color", cmd_start_color},
+ {"subpad", cmd_subpad},
+ {"subwin", cmd_subwin},
+ {"termattrs", cmd_termattrs},
+ {"term_attrs", cmd_term_attrs},
+ {"touchline", cmd_touchline},
+ {"touchoverlap", cmd_touchoverlap},
+ {"touchwin", cmd_touchwin},
+ {"ungetch", cmd_ungetch},
+ {"untouchwin", cmd_untouchwin},
+ {"use_default_colors", cmd_use_default_colors},
+ {"vline", cmd_vline},
+ {"vw_printw", cmd_vw_printw},
+ {"vw_scanw", cmd_vw_scanw},
+ {"vwprintw", cmd_vwprintw},
+ {"vwscanw", cmd_vwscanw},
+ {"waddch", cmd_waddch},
+ {"waddchnstr", cmd_waddchnstr},
+ {"waddchstr", cmd_waddchstr},
+ {"waddnstr", cmd_waddnstr},
+ {"wattr_get", cmd_wattr_get},
+ {"wattr_off", cmd_wattr_off},
+ {"wattr_on", cmd_wattr_on},
+ {"wattr_set", cmd_wattr_set},
+ {"wattroff", cmd_wattroff},
+ {"wattron", cmd_wattron},
+ {"wattrset", cmd_wattrset},
+ {"wbkgd", cmd_wbkgd},
+ {"wbkgdset", cmd_wbkgdset},
+ {"wborder", cmd_wborder},
+ {"wclear", cmd_wclear},
+ {"wclrtobot", cmd_wclrtobot},
+ {"wclrtoeol", cmd_wclrtoeol},
+ {"wcolor_set", cmd_wcolor_set},
+ {"wdelch", cmd_wdelch},
+ {"wdeleteln", cmd_wdeleteln},
+ {"wechochar", cmd_wechochar},
+ {"werase", cmd_werase},
+ {"wgetch", cmd_wgetch},
+ {"wgetnstr", cmd_wgetnstr},
+ {"wgetstr", cmd_wgetstr},
+ {"whline", cmd_whline},
+ {"winch", cmd_winch},
+ {"winchnstr", cmd_winchnstr},
+ {"winchstr", cmd_winchstr},
+ {"winnstr", cmd_winnstr},
+ {"winsch", cmd_winsch},
+ {"winsdelln", cmd_winsdelln},
+ {"winsertln", cmd_winsertln},
+ {"winstr", cmd_winstr},
+ {"wmove", cmd_wmove},
+ {"wnoutrefresh", cmd_wnoutrefresh},
+ {"wprintw", cmd_wprintw},
+ {"wredrawln", cmd_wredrawln},
+ {"wrefresh", cmd_wrefresh},
+ {"wresize", cmd_wresize},
+ {"wscanw", cmd_wscanw},
+ {"wscrl", cmd_wscrl},
+ {"wsetscrreg", cmd_wsetscrreg},
+ {"wstandend", cmd_wstandend},
+ {"wstandout", cmd_wstandout},
+ {"wtimeout", cmd_wtimeout},
+ {"wtouchln", cmd_wtouchln},
+ {"wunderend", cmd_wunderend},
+ {"wunderscore", cmd_wunderscore},
+ {"wvline", cmd_wvline},
+ {"insnstr", cmd_insnstr},
+ {"insstr", cmd_insstr},
+ {"mvinsnstr", cmd_mvinsnstr},
+ {"mvinsstr", cmd_mvinsstr},
+ {"mvwinsnstr", cmd_mvwinsnstr},
+ {"mvwinsstr", cmd_mvwinsstr},
+ {"winsnstr", cmd_winsnstr},
+ {"winsstr", cmd_winsstr},
+ {"chgat", cmd_chgat},
+ {"wchgat", cmd_wchgat},
+ {"mvchgat", cmd_mvchgat},
+ {"mvwchgat", cmd_mvwchgat},
+ {"add_wch", cmd_add_wch},
+ {"wadd_wch", cmd_wadd_wch},
+ {"mvadd_wch", cmd_mvadd_wch},
+ {"mvwadd_wch", cmd_mvwadd_wch},
+ {"add_wchnstr", cmd_add_wchnstr},
+ {"add_wchstr", cmd_add_wchstr},
+ {"wadd_wchnstr", cmd_wadd_wchnstr},
+ {"wadd_wchstr", cmd_wadd_wchstr},
+ {"mvadd_wchnstr", cmd_mvadd_wchnstr},
+ {"mvadd_wchstr", cmd_mvadd_wchstr},
+ {"mvwadd_wchnstr", cmd_mvwadd_wchnstr},
+ {"mvwadd_wchstr", cmd_mvwadd_wchstr},
+ {"addnwstr", cmd_addnwstr},
+ {"addwstr", cmd_addwstr},
+ {"mvaddnwstr", cmd_mvaddnwstr},
+ {"mvaddwstr", cmd_mvaddwstr},
+ {"mvwaddnwstr", cmd_mvwaddnwstr},
+ {"mvwaddwstr", cmd_mvwaddwstr},
+ {"waddnwstr", cmd_waddnwstr},
+ {"waddwstr", cmd_waddwstr},
+ {"echo_wchar", cmd_echo_wchar},
+ {"wecho_wchar", cmd_wecho_wchar},
+ {"pecho_wchar", cmd_pecho_wchar},
+ {"ins_wch", cmd_ins_wch},
+ {"wins_wch", cmd_wins_wch},
+ {"mvins_wch", cmd_mvins_wch},
+ {"mvwins_wch", cmd_mvwins_wch},
+ {"ins_nwstr", cmd_ins_nwstr},
+ {"ins_wstr", cmd_ins_wstr},
+ {"mvins_nwstr", cmd_mvins_nwstr},
+ {"mvins_wstr", cmd_mvins_wstr},
+ {"mvwins_nwstr", cmd_mvwins_nwstr},
+ {"mvwins_wstr", cmd_mvwins_wstr},
+ {"wins_nwstr", cmd_wins_nwstr},
+ {"wins_wstr", cmd_wins_wstr},
+ {"get_wch", cmd_get_wch},
+ {"unget_wch", cmd_unget_wch},
+ {"mvget_wch", cmd_mvget_wch},
+ {"mvwget_wch", cmd_mvwget_wch},
+ {"wget_wch", cmd_wget_wch},
+ {"getn_wstr", cmd_getn_wstr},
+ {"get_wstr", cmd_get_wstr},
+ {"mvgetn_wstr", cmd_mvgetn_wstr},
+ {"mvget_wstr", cmd_mvget_wstr},
+ {"mvwgetn_wstr", cmd_mvwgetn_wstr},
+ {"mvwget_wstr", cmd_mvwget_wstr},
+ {"wgetn_wstr", cmd_wgetn_wstr},
+ {"wget_wstr", cmd_wget_wstr},
+ {"in_wch", cmd_in_wch},
+ {"mvin_wch", cmd_mvin_wch},
+ {"mvwin_wch", cmd_mvwin_wch},
+ {"win_wch", cmd_win_wch},
+ {"in_wchnstr", cmd_in_wchnstr},
+ {"in_wchstr", cmd_in_wchstr},
+ {"mvin_wchnstr", cmd_mvin_wchnstr},
+ {"mvin_wchstr", cmd_mvin_wchstr},
+ {"mvwin_wchnstr", cmd_mvwin_wchnstr},
+ {"mvwin_wchstr", cmd_mvwin_wchstr},
+ {"win_wchnstr", cmd_win_wchnstr},
+ {"win_wchstr", cmd_win_wchstr},
+ {"innwstr", cmd_innwstr},
+ {"inwstr", cmd_inwstr},
+ {"mvinnwstr", cmd_mvinnwstr},
+ {"mvinwstr", cmd_mvinwstr},
+ {"mvwinnwstr", cmd_mvwinnwstr},
+ {"mvwinwstr", cmd_mvwinwstr},
+ {"winnwstr", cmd_winnwstr},
+ {"winwstr", cmd_winwstr},
+ {"setcchar", cmd_setcchar},
+ {"getcchar", cmd_getcchar},
+ {"key_name", cmd_key_name},
+ {"border_set", cmd_border_set},
+ {"wborder_set", cmd_wborder_set},
+ {"box_set", cmd_box_set},
+ {"erasewchar", cmd_erasewchar},
+ {"killwchar", cmd_killwchar},
+ {"hline_set", cmd_hline_set},
+ {"mvhline_set", cmd_mvhline_set},
+ {"mvvline_set", cmd_mvvline_set},
+ {"mvwhline_set", cmd_mvwhline_set},
+ {"mvwvline_set", cmd_mvwvline_set},
+ {"vline_set", cmd_vline_set},
+ {"whline_set", cmd_whline_set},
+ {"wvline_set", cmd_wvline_set},
+ {"bkgrnd", cmd_bkgrnd},
+ {"bkgrndset", cmd_bkgrndset},
+ {"getbkgrnd", cmd_getbkgrnd},
+ {"wbkgrnd", cmd_wbkgrnd},
+ {"wbkgrndset", cmd_wbkgrndset},
+ {"wgetbkgrnd", cmd_wgetbkgrnd},
+};
+
+size_t ncmds = sizeof(commands) / sizeof(struct command_def);
+
+#endif /* _COMMAND_TABLE_H */
diff --git a/contrib/netbsd-tests/lib/libcurses/slave/commands.c b/contrib/netbsd-tests/lib/libcurses/slave/commands.c
new file mode 100644
index 0000000..2f26024
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/slave/commands.c
@@ -0,0 +1,243 @@
+/* $NetBSD: commands.c,v 1.4 2011/09/15 11:46:19 blymn Exp $ */
+
+/*-
+ * Copyright 2009 Brett Lymn <blymn@NetBSD.org>
+ *
+ * All rights reserved.
+ *
+ * This code has been donated to The NetBSD Foundation by the Author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ */
+
+#include <curses.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <err.h>
+#include <sys/types.h>
+#include "returns.h"
+#include "slave.h"
+#include "command_table.h"
+
+extern int cmdpipe[2];
+extern int slvpipe[2];
+
+static void report_type(returns_enum_t);
+static void report_message(int, const char *);
+
+/*
+ * Match the passed command string and execute the associated test
+ * function.
+ */
+void
+command_execute(char *func, int nargs, char **args)
+{
+ size_t i;
+
+ i = 0;
+ while (i < ncmds) {
+ if (strcasecmp(func, commands[i].name) == 0) {
+ /* matched function */
+ commands[i].func(nargs, args);
+ return;
+ }
+ i++;
+ }
+
+ report_status("UNKNOWN_FUNCTION");
+}
+
+/*
+ * Report an pointer value back to the director
+ */
+void
+report_ptr(void *ptr)
+{
+ char *string;
+
+ if (ptr == NULL)
+ asprintf(&string, "NULL");
+ else
+ asprintf(&string, "%p", ptr);
+ report_status(string);
+ free(string);
+}
+
+/*
+ * Report an integer value back to the director
+ */
+void
+report_int(int value)
+{
+ char *string;
+
+ asprintf(&string, "%d", value);
+ report_status(string);
+ free(string);
+}
+
+/*
+ * Report either an ERR or OK back to the director
+ */
+void
+report_return(int status)
+{
+ if (status == ERR)
+ report_type(ret_err);
+ else if (status == OK)
+ report_type(ret_ok);
+ else
+ report_status("INVALID_RETURN");
+}
+
+/*
+ * Report the type back to the director via the command pipe
+ */
+static void
+report_type(returns_enum_t return_type)
+{
+ int type;
+
+ type = return_type;
+ if (write(slvpipe[WRITE_PIPE], &type, sizeof(int)) < 0)
+ err(1, "command pipe write for status type failed");
+
+}
+
+/*
+ * Report the number of returns back to the director via the command pipe
+ */
+void
+report_count(int count)
+{
+ int type;
+
+ type = ret_count;
+ if (write(slvpipe[WRITE_PIPE], &type, sizeof(int)) < 0)
+ err(1, "command pipe write for count type failed");
+
+ if (write(slvpipe[WRITE_PIPE], &count, sizeof(int)) < 0)
+ err(1, "command pipe write for count");
+}
+
+/*
+ * Report the status back to the director via the command pipe
+ */
+void
+report_status(const char *status)
+{
+ report_message(ret_string, status);
+}
+
+/*
+ * Report an error message back to the director via the command pipe.
+ */
+void
+report_error(const char *status)
+{
+ report_message(ret_slave_error, status);
+}
+
+/*
+ * Report the message with the given type back to the director via the
+ * command pipe.
+ */
+static void
+report_message(int type, const char *status)
+{
+ int len;
+
+ len = strlen(status);
+
+ if (write(slvpipe[WRITE_PIPE], &type, sizeof(int)) < 0)
+ err(1, "command pipe write for message type failed");
+
+ if (write(slvpipe[WRITE_PIPE], &len, sizeof(int)) < 0)
+ err(1, "command pipe write for message length failed");
+
+ if (write(slvpipe[WRITE_PIPE], status, len) < 0)
+ err(1, "command pipe write of message data failed");
+}
+
+/*
+ * 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;
+ chtype *p;
+
+ len = 0;
+ p = string;
+
+ while ((*p++ & __CHARTEXT) != 0) {
+ 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",
+ __func__);
+
+ if (write(slvpipe[WRITE_PIPE], &len, sizeof(int)) < 0)
+ err(1, "%s: command pipe write for status length failed",
+ __func__);
+
+ if (write(slvpipe[WRITE_PIPE], string, len) < 0)
+ err(1, "%s: command pipe write of status data failed",
+ __func__);
+}
+
+/*
+ * Check the number of args we received are what we expect. Return an
+ * error if they do not match.
+ */
+int
+check_arg_count(int nargs, int expected)
+{
+ if (nargs != expected) {
+ report_count(1);
+ report_error("INCORRECT_ARGUMENT_NUMBER");
+ return(1);
+ }
+
+ return(0);
+}
diff --git a/contrib/netbsd-tests/lib/libcurses/slave/curses_commands.c b/contrib/netbsd-tests/lib/libcurses/slave/curses_commands.c
new file mode 100644
index 0000000..9a6679a
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/slave/curses_commands.c
@@ -0,0 +1,7165 @@
+/* $NetBSD: curses_commands.c,v 1.7 2012/09/19 11:51:08 blymn Exp $ */
+
+/*-
+ * Copyright 2009 Brett Lymn <blymn@NetBSD.org>
+ *
+ * All rights reserved.
+ *
+ * This code has been donated to The NetBSD Foundation by the Author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ */
+
+#include <curses.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <termios.h>
+#include <stdarg.h>
+
+#include "slave.h"
+#include "curses_commands.h"
+
+void
+cmd_DRAIN(int nargs, char **args)
+{
+ while (getch() != ERR);
+ report_count(1);
+ report_return(OK);
+}
+
+void
+cmd_addbytes(int nargs, char **args)
+{
+ int count;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[1], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(addbytes(args[0], count));
+}
+
+
+void
+cmd_addch(int nargs, char **args)
+{
+ chtype *ch;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ ch = (chtype *) args[0];
+ report_count(1);
+ report_return(addch(ch[0]));
+}
+
+
+void
+cmd_addchnstr(int nargs, char **args)
+{
+ int count;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[1], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(addchnstr((chtype *) args[0], count));
+}
+
+
+void
+cmd_addchstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_return(addchstr((chtype *) args[0]));
+}
+
+
+void
+cmd_addnstr(int nargs, char **args)
+{
+ int count;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[1], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(addnstr(args[0], count));
+}
+
+
+void
+cmd_addstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_return(addstr(args[0]));
+}
+
+
+void
+cmd_attr_get(int nargs, char **args)
+{
+ attr_t attrs;
+ short colours;
+ int retval;
+
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ retval = attr_get(&attrs, &colours, NULL);
+
+ /* XXXX - call3 */
+ report_count(3);
+ report_return(retval);
+ report_int(attrs);
+ report_int(colours);
+}
+
+
+void
+cmd_attr_off(int nargs, char **args)
+{
+ int attrib;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &attrib) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(attr_off(attrib, NULL));
+}
+
+
+void
+cmd_attr_on(int nargs, char **args)
+{
+ int attrib;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &attrib) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(attr_on(attrib, NULL));
+}
+
+
+void
+cmd_attr_set(int nargs, char **args)
+{
+ int attrib;
+ short pair;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &attrib) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%hd", &pair) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(attr_set(attrib, pair, NULL));
+}
+
+
+void
+cmd_attroff(int nargs, char **args)
+{
+ int attrib;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &attrib) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(attroff(attrib));
+}
+
+
+void
+cmd_attron(int nargs, char **args)
+{
+ int attrib;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &attrib) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(attron(attrib));
+}
+
+
+void
+cmd_attrset(int nargs, char **args)
+{
+ int attrib;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &attrib) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(attrset(attrib));
+}
+
+
+void
+cmd_bkgd(int nargs, char **args)
+{
+ chtype *ch;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ ch = (chtype *) args[0];
+ report_count(1);
+ report_return(bkgd(ch[0]));
+}
+
+
+void
+cmd_bkgdset(int nargs, char **args)
+{
+ chtype *ch;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ ch = (chtype *) args[0];
+ bkgdset(ch[0]); /* returns void */
+ report_count(1);
+ report_return(OK);
+}
+
+
+void
+cmd_border(int nargs, char **args)
+{
+ int ls, rs, ts, bs, tl, tr, bl, br;
+
+ if (check_arg_count(nargs, 8) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &ls) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+ if (sscanf(args[1], "%d", &rs) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+ if (sscanf(args[2], "%d", &ts) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+ if (sscanf(args[3], "%d", &bs) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+ if (sscanf(args[4], "%d", &tl) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+ if (sscanf(args[5], "%d", &tr) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+ if (sscanf(args[6], "%d", &bl) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+ if (sscanf(args[7], "%d", &br) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(border(ls, rs, ts, bs, tl, tr, bl, br));
+}
+
+
+void
+cmd_clear(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(clear());
+}
+
+
+void
+cmd_clrtobot(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(clrtobot());
+}
+
+
+void
+cmd_clrtoeol(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(clrtoeol());
+}
+
+
+void
+cmd_color_set(int nargs, char **args)
+{
+ short colour_pair;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%hd", &colour_pair) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(color_set(colour_pair, NULL));
+}
+
+
+void
+cmd_delch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(delch());
+}
+
+
+void
+cmd_deleteln(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(deleteln());
+}
+
+
+void
+cmd_echochar(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ /* XXX causes refresh */
+ report_count(1);
+ report_return(echochar(args[0][0]));
+}
+
+
+void
+cmd_erase(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(erase());
+}
+
+
+void
+cmd_getch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ /* XXX causes refresh */
+ report_count(1);
+ report_int(getch());
+}
+
+
+void
+cmd_getnstr(int nargs, char **args)
+{
+ int limit;
+ char *string;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &limit) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if ((string = malloc(limit + 1)) == NULL) {
+ report_count(1);
+ report_error("MALLOC_FAILED");
+ return;
+ }
+
+ /* XXX call2 */
+ report_count(2);
+ report_return(getnstr(string, limit));
+ report_status(string);
+ free(string);
+}
+
+
+void
+cmd_getstr(int nargs, char **args)
+{
+ char string[256];
+
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ /* XXX call2 */
+ report_count(2);
+ report_return(getstr(string));
+ report_status(string);
+}
+
+
+void
+cmd_inch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+
+ report_count(1);
+ report_byte(inch());
+}
+
+
+void
+cmd_inchnstr(int nargs, char **args)
+{
+ int limit;
+ chtype *string;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &limit) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if ((string = malloc((limit + 1) * sizeof(chtype))) == NULL) {
+ report_count(1);
+ report_error("MALLOC_FAILED");
+ return;
+ }
+
+ /* XXX call2 */
+ report_count(2);
+ report_return(inchnstr(string, limit));
+ report_nstr(string);
+ free(string);
+}
+
+
+void
+cmd_inchstr(int nargs, char **args)
+{
+ chtype string[256];
+
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ /* XXX call2 */
+ report_count(2);
+ report_return(inchstr(string));
+ report_nstr(string);
+}
+
+
+void
+cmd_innstr(int nargs, char **args)
+{
+ int limit;
+ char *string;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &limit) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if ((string = malloc(limit + 1)) == NULL) {
+ report_count(1);
+ report_error("MALLOC_FAILED");
+ return;
+ }
+
+ /* XXX call2 */
+ report_count(2);
+ report_int(innstr(string, limit));
+ report_status(string);
+ free(string);
+}
+
+
+void
+cmd_insch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_return(insch(args[0][0]));
+}
+
+
+void
+cmd_insdelln(int nargs, char **args)
+{
+ int nlines;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &nlines) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(insdelln(nlines));
+}
+
+
+void
+cmd_insertln(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(insertln());
+}
+
+
+void
+cmd_instr(int nargs, char **args)
+{
+ char string[256];
+
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ /* XXX call2 */
+ report_count(2);
+ report_return(instr(string));
+ report_status(string);
+}
+
+
+void
+cmd_move(int nargs, char **args)
+{
+ int y, x;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(move(y, x));
+}
+
+
+void
+cmd_refresh(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(refresh());
+}
+
+
+void
+cmd_scrl(int nargs, char **args)
+{
+ int nlines;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &nlines) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(scrl(nlines));
+}
+
+
+void
+cmd_setscrreg(int nargs, char **args)
+{
+ int top, bottom;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &top) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &bottom) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(setscrreg(top, bottom));
+}
+
+
+void
+cmd_standend(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(standend());
+}
+
+
+void
+cmd_standout(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(standout());
+}
+
+
+void
+cmd_timeout(int nargs, char **args)
+{
+ int tval;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &tval) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ timeout(tval); /* void return */
+ report_count(1);
+ report_return(OK);
+}
+
+
+void
+cmd_underscore(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(underscore());
+}
+
+
+void
+cmd_underend(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(underend());
+}
+
+
+void
+cmd_waddbytes(int nargs, char **args)
+{
+ WINDOW *win;
+ int count;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(waddbytes(win, args[1], count));
+}
+
+
+void
+cmd_waddstr(int nargs, char **args)
+{
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(waddstr(win, args[1]));
+}
+
+
+void
+cmd_mvaddbytes(int nargs, char **args)
+{
+ int y, x, count;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvaddbytes(y, x, args[2], count));
+}
+
+
+void
+cmd_mvaddch(int nargs, char **args)
+{
+ int y, x;
+ chtype *ch;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ ch = (chtype *) args[2];
+ report_count(1);
+ report_return(mvaddch(y, x, ch[0]));
+}
+
+
+void
+cmd_mvaddchnstr(int nargs, char **args)
+{
+ int y, x, count;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvaddchnstr(y, x, (chtype *) args[2], count));
+}
+
+
+void
+cmd_mvaddchstr(int nargs, char **args)
+{
+ int y, x;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvaddchstr(y, x, (chtype *) args[2]));
+}
+
+
+void
+cmd_mvaddnstr(int nargs, char **args)
+{
+ int y, x, count;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvaddnstr(y, x, args[2], count));
+}
+
+
+void
+cmd_mvaddstr(int nargs, char **args)
+{
+ int y, x;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvaddstr(y, x, args[2]));
+}
+
+
+void
+cmd_mvdelch(int nargs, char **args)
+{
+ int y, x;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvdelch(y, x));
+}
+
+
+void
+cmd_mvgetch(int nargs, char **args)
+{
+ int y, x;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_int(mvgetch(y, x));
+}
+
+
+void
+cmd_mvgetnstr(int nargs, char **args)
+{
+ int y, x, count;
+ char *string;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if ((string = malloc(count + 1)) == NULL) {
+ report_count(1);
+ report_error("MALLOC_FAILED");
+ return;
+ }
+
+ /* XXX call2 */
+ report_count(2);
+ report_return(mvgetnstr(y, x, string, count));
+ report_status(string);
+ free(string);
+}
+
+
+void
+cmd_mvgetstr(int nargs, char **args)
+{
+ int y, x;
+ char string[256];
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX call2 */
+ report_count(2);
+ report_return(mvgetstr(y, x, string));
+ report_status(string);
+}
+
+
+void
+cmd_mvinch(int nargs, char **args)
+{
+ int y, x;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_int(mvinch(y, x));
+}
+
+
+void
+cmd_mvinchnstr(int nargs, char **args)
+{
+ int y, x, count;
+ chtype *string;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if ((string = malloc((count + 1) * sizeof(chtype))) == NULL) {
+ report_count(1);
+ report_error("MALLOC_FAILED");
+ return;
+ }
+
+ /* XXX call2 */
+ report_count(2);
+ report_return(mvinchnstr(y, x, string, count));
+ report_nstr(string);
+ free(string);
+}
+
+
+void
+cmd_mvinchstr(int nargs, char **args)
+{
+ int y, x;
+ chtype string[256];
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX call2 */
+ report_count(2);
+ report_return(mvinchstr(y, x, string));
+ report_nstr(string);
+}
+
+
+void
+cmd_mvinnstr(int nargs, char **args)
+{
+ int y, x, count;
+ char *string;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if ((string = malloc(count + 1)) == NULL) {
+ report_count(1);
+ report_error("MALLOC_FAILED");
+ return;
+ }
+
+ /* XXX call2 */
+ report_count(2);
+ report_return(mvinnstr(y, x, string, count));
+ report_status(string);
+ free(string);
+}
+
+
+void
+cmd_mvinsch(int nargs, char **args)
+{
+ int y, x, ch;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &ch) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvinsch(y, x, ch));
+}
+
+
+void
+cmd_mvinstr(int nargs, char **args)
+{
+ int y, x;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvinstr(y, x, args[2]));
+}
+
+
+
+void
+cmd_mvwaddbytes(int nargs, char **args)
+{
+ int y, x, count;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 5) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[4], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvwaddbytes(win, y, x, args[3], count));
+}
+
+
+void
+cmd_mvwaddch(int nargs, char **args)
+{
+ int y, x;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvwaddch(win, y, x, args[3][0]));
+}
+
+
+void
+cmd_mvwaddchnstr(int nargs, char **args)
+{
+ int y, x, count;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 5) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[4], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvwaddchnstr(win, y, x, (chtype *) args[3], count));
+}
+
+
+void
+cmd_mvwaddchstr(int nargs, char **args)
+{
+ int y, x;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvwaddchstr(win, y, x, (chtype *) args[3]));
+}
+
+
+void
+cmd_mvwaddnstr(int nargs, char **args)
+{
+ int y, x, count;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 5) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[4], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvwaddnstr(win, y, x, args[3], count));
+}
+
+
+void
+cmd_mvwaddstr(int nargs, char **args)
+{
+ int y, x;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvwaddstr(win, y, x, args[3]));
+}
+
+
+void
+cmd_mvwdelch(int nargs, char **args)
+{
+ int y, x;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvwdelch(win, y, x));
+}
+
+
+void
+cmd_mvwgetch(int nargs, char **args)
+{
+ int y, x;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX - implicit refresh */
+ report_count(1);
+ report_int(mvwgetch(win, y, x));
+}
+
+
+void
+cmd_mvwgetnstr(int nargs, char **args)
+{
+ int y, x, count;
+ char *string;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if ((string = malloc(count + 1)) == NULL) {
+ report_count(1);
+ report_error("MALLOC_FAILED");
+ return;
+ }
+
+ /* XXX call2 */
+ report_count(2);
+ report_return(mvwgetnstr(win, y, x, string, count));
+ report_status(string);
+ free(string);
+}
+
+
+void
+cmd_mvwgetstr(int nargs, char **args)
+{
+ int y, x;
+ WINDOW *win;
+ char string[256];
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX - call2 */
+ report_count(2);
+ report_return(mvwgetstr(win, y, x, string));
+ report_status(string);
+}
+
+
+void
+cmd_mvwinch(int nargs, char **args)
+{
+ int y, x;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_int(mvwinch(win, y, x));
+}
+
+
+void
+cmd_mvwinsch(int nargs, char **args)
+{
+ int y, x;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_int(mvwinsch(win, y, x, args[3][0]));
+}
+
+
+void
+cmd_assume_default_colors(int nargs, char **args)
+{
+ short fore, back;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%hd", &fore) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%hd", &back) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(assume_default_colors(fore, back));
+}
+
+
+void
+cmd_baudrate(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_int(baudrate());
+}
+
+
+void
+cmd_beep(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(beep());
+}
+
+
+void
+cmd_box(int nargs, char **args)
+{
+ WINDOW *win;
+ chtype *vertical, *horizontal;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ vertical = (chtype *) args[1];
+ horizontal = (chtype *) args[2];
+ report_count(1);
+ report_return(box(win, vertical[0], horizontal[0]));
+}
+
+
+void
+cmd_can_change_color(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_int(can_change_color());
+}
+
+
+void
+cmd_cbreak(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(cbreak());
+}
+
+
+void
+cmd_clearok(int nargs, char **args)
+{
+ WINDOW *win;
+ int flag;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &flag) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(clearok(win, flag));
+}
+
+
+void
+cmd_color_content(int nargs, char **args)
+{
+ short colour, red, green, blue;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%hd", &colour) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX - call4 */
+ report_count(4);
+ report_return(color_content(colour, &red, &green, &blue));
+ report_int(red);
+ report_int(green);
+ report_int(blue);
+}
+
+
+void
+cmd_copywin(int nargs, char **args)
+{
+ int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol, ovlay;
+ WINDOW *source, *destination;
+
+ if (check_arg_count(nargs, 9) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &source) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%p", &destination) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &sminrow) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &smincol) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[4], "%d", &dminrow) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[5], "%d", &dmincol) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[6], "%d", &dmaxrow) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[7], "%d", &dmaxcol) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[8], "%d", &ovlay) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(copywin(source, destination, sminrow, smincol, dminrow,
+ dmincol, dmaxrow, dmaxcol, ovlay));
+}
+
+
+void
+cmd_curs_set(int nargs, char **args)
+{
+ int vis;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &vis) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_int(curs_set(vis));
+}
+
+
+void
+cmd_def_prog_mode(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(def_prog_mode());
+}
+
+
+void
+cmd_def_shell_mode(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(def_shell_mode());
+}
+
+
+void
+cmd_define_key(int nargs, char **args)
+{
+ int symbol;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[1], "%d", &symbol) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(define_key(args[0], symbol));
+}
+
+
+void
+cmd_delay_output(int nargs, char **args)
+{
+ int dtime;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &dtime) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(delay_output(dtime));
+}
+
+
+void
+cmd_delscreen(int nargs, char **args)
+{
+ SCREEN *scrn;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &scrn) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ delscreen(scrn); /* void return */
+ report_count(1);
+ report_return(OK);
+}
+
+
+void
+cmd_delwin(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_return(delwin(win));
+}
+
+
+void
+cmd_derwin(int nargs, char **args)
+{
+ int lines, cols, y, x;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 5) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &lines) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &cols) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[4], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_ptr(derwin(win, lines, cols, y, x));
+}
+
+
+void
+cmd_dupwin(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_ptr(dupwin(win));
+}
+
+
+void
+cmd_doupdate(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ /* XXX - implicit refresh */
+ report_count(1);
+ report_return(doupdate());
+}
+
+
+void
+cmd_echo(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(echo());
+}
+
+
+void
+cmd_endwin(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(endwin());
+}
+
+
+void
+cmd_erasechar(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_int(erasechar());
+}
+
+
+void
+cmd_flash(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(flash());
+}
+
+
+void
+cmd_flushinp(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(flushinp());
+}
+
+
+void
+cmd_flushok(int nargs, char **args)
+{
+ int flag;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &flag) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(flushok(win, flag));
+}
+
+
+void
+cmd_fullname(int nargs, char **args)
+{
+ char string[256];
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ /* XXX - call2 */
+ report_count(2);
+ report_status(fullname(args[0], string));
+ report_status(string);
+}
+
+
+void
+cmd_getattrs(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_int(getattrs(win));
+}
+
+
+void
+cmd_getbkgd(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_byte(getbkgd(win));
+}
+
+
+void
+cmd_getcury(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_int(getcury(win));
+}
+
+
+void
+cmd_getcurx(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_int(getcurx(win));
+}
+
+
+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;
+
+ 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(1);
+ report_int(getbegy(win));
+}
+
+
+void
+cmd_getbegx(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_int(getbegx(win));
+}
+
+
+void
+cmd_getmaxy(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_int(getmaxy(win));
+}
+
+
+void
+cmd_getmaxx(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_int(getmaxx(win));
+}
+
+
+void
+cmd_getpary(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_int(getpary(win));
+}
+
+
+void
+cmd_getparx(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_int(getparx(win));
+}
+
+
+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)
+ return;
+
+ report_count(1);
+ report_return(gettmode());
+}
+
+
+void
+cmd_getwin(int nargs, char **args)
+{
+ FILE *fp;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if ((fp = fopen(args[0], "r")) == NULL) {
+ report_count(1);
+ report_error("BAD FILE_ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_ptr(getwin(fp));
+ fclose(fp);
+}
+
+
+void
+cmd_halfdelay(int nargs, char **args)
+{
+ int ms;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &ms) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(halfdelay(ms));
+}
+
+
+void
+cmd_has_colors(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_int(has_colors());
+}
+
+
+void
+cmd_has_ic(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_int(has_ic());
+}
+
+
+void
+cmd_has_il(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_int(has_il());
+}
+
+
+void
+cmd_hline(int nargs, char **args)
+{
+ int count;
+ chtype *ch;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ ch = (chtype *) args[0];
+
+ if (sscanf(args[1], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(hline(ch[0], count));
+}
+
+
+void
+cmd_idcok(int nargs, char **args)
+{
+ int flag;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &flag) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(idcok(win, flag));
+}
+
+
+void
+cmd_idlok(int nargs, char **args)
+{
+ int flag;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &flag) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(idlok(win, flag));
+}
+
+
+void
+cmd_init_color(int nargs, char **args)
+{
+ short colour, red, green, blue;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%hd", &colour) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%hd", &red) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%hd", &green) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%hd", &blue) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(init_color(colour, red, green, blue));
+}
+
+
+void
+cmd_init_pair(int nargs, char **args)
+{
+ short pair, fore, back;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%hd", &pair) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%hd", &fore) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%hd", &back) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(init_pair(pair, fore, back));
+}
+
+
+void
+cmd_initscr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_ptr(initscr());
+}
+
+
+void
+cmd_intrflush(int nargs, char **args)
+{
+ int flag;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &flag) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(intrflush(win, flag));
+}
+
+
+void
+cmd_isendwin(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_int(isendwin());
+}
+
+
+void
+cmd_is_linetouched(int nargs, char **args)
+{
+ int line;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &line) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_int(is_linetouched(win, line));
+}
+
+
+void
+cmd_is_wintouched(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_int(is_wintouched(win));
+}
+
+
+void
+cmd_keyok(int nargs, char **args)
+{
+ int keysym, flag;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &keysym) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &flag) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(keyok(keysym, flag));
+}
+
+
+void
+cmd_keypad(int nargs, char **args)
+{
+ int flag;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &flag) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(keypad(win, flag));
+}
+
+
+void
+cmd_keyname(int nargs, char **args)
+{
+ unsigned int key;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &key) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_status(keyname(key));
+}
+
+
+void
+cmd_killchar(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_int(killchar());
+}
+
+
+void
+cmd_leaveok(int nargs, char **args)
+{
+ int flag;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &flag) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(leaveok(win, flag));
+}
+
+
+void
+cmd_meta(int nargs, char **args)
+{
+ int flag;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &flag) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(meta(win, flag));
+}
+
+
+void
+cmd_mvcur(int nargs, char **args)
+{
+ int oldy, oldx, y, x;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &oldy) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &oldx) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvcur(oldy, oldx, y, x));
+}
+
+
+void
+cmd_mvderwin(int nargs, char **args)
+{
+ int y, x;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvderwin(win, y, x));
+}
+
+
+void
+cmd_mvhline(int nargs, char **args)
+{
+ int y, x, n;
+ chtype *ch;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ ch = (chtype *) args[2];
+
+ if (sscanf(args[3], "%d", &n) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvhline(y, x, ch[0], n));
+}
+
+
+void
+cmd_mvprintw(int nargs, char **args)
+{
+ int y, x;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvprintw(y, x, args[2], args[3]));
+}
+
+
+void
+cmd_mvscanw(int nargs, char **args)
+{
+ int y, x;
+ char string[256];
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX - call2 */
+ report_count(2);
+ report_return(mvscanw(y, x, args[2], &string));
+ report_status(string);
+}
+
+
+void
+cmd_mvvline(int nargs, char **args)
+{
+ int y, x, n;
+ chtype *ch;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ ch = (chtype *) args[2];
+
+ if (sscanf(args[3], "%d", &n) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvvline(y, x, ch[0], n));
+}
+
+
+void
+cmd_mvwhline(int nargs, char **args)
+{
+ int y, x, ch, n;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 5) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &ch) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[4], "%d", &n) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvwhline(win, y, x, ch, n));
+}
+
+
+void
+cmd_mvwvline(int nargs, char **args)
+{
+ int y, x, n;
+ WINDOW *win;
+ chtype *ch;
+
+ if (check_arg_count(nargs, 5) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ ch = (chtype *) args[3];
+
+ if (sscanf(args[4], "%d", &n) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvwvline(win, y, x, ch[0], n));
+}
+
+
+void
+cmd_mvwin(int nargs, char **args)
+{
+ int y, x;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvwin(win, y, x));
+}
+
+
+void
+cmd_mvwinchnstr(int nargs, char **args)
+{
+ int y, x, count;
+ chtype *string;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if ((string = malloc((count + 1) * sizeof(chtype))) == NULL) {
+ report_count(1);
+ report_error("MALLOC_FAILED");
+ return;
+ }
+
+ /* XXX call2 */
+ report_count(2);
+ report_return(mvwinchnstr(win, y, x, string, count));
+ report_nstr(string);
+ free(string);
+}
+
+
+void
+cmd_mvwinchstr(int nargs, char **args)
+{
+ int y, x;
+ chtype string[256];
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX call2 */
+ report_count(2);
+ report_return(mvwinchstr(win, y, x, string));
+ report_nstr(string);
+}
+
+
+void
+cmd_mvwinnstr(int nargs, char **args)
+{
+ int y, x, count;
+ char *string;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if ((string = malloc(count + 1)) == NULL) {
+ report_count(1);
+ report_error("MALLOC_FAILED");
+ return;
+ }
+
+ /* XXX call2 */
+ report_count(2);
+ report_return(mvwinnstr(win, y, x, string, count));
+ report_status(string);
+ free(string);
+}
+
+
+void
+cmd_mvwinstr(int nargs, char **args)
+{
+ int y, x;
+ char string[256];
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX call2 */
+ report_count(2);
+ report_return(mvwinstr(win, y, x, string));
+ report_status(string);
+}
+
+
+void
+cmd_mvwprintw(int nargs, char **args)
+{
+ int y, x;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 5) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvwprintw(win, y, x, args[3], args[4]));
+}
+
+
+void
+cmd_mvwscanw(int nargs, char **args)
+{
+ int y, x;
+ WINDOW *win;
+ char string[256];
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX - call2 */
+ report_count(2);
+ report_int(mvwscanw(win, y, x, args[3], &string));
+ report_status(string);
+}
+
+
+void
+cmd_napms(int nargs, char **args)
+{
+ int naptime;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &naptime) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(napms(naptime));
+}
+
+
+void
+cmd_newpad(int nargs, char **args)
+{
+ int y, x;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_ptr(newpad(y, x));
+}
+
+
+void
+cmd_newterm(int nargs, char **args)
+{
+ FILE *in, *out;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if ((in = fopen(args[1], "rw")) == NULL) {
+ report_count(1);
+ report_error("BAD FILE_ARGUMENT");
+ return;
+ }
+
+
+ if ((out = fopen(args[2], "rw")) == NULL) {
+ report_count(1);
+ report_error("BAD FILE_ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_ptr(newterm(args[0], out, in));
+}
+
+
+void
+cmd_newwin(int nargs, char **args)
+{
+ int lines, cols, begin_y, begin_x;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &lines) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &cols) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &begin_y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &begin_x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_ptr(newwin(lines, cols, begin_y, begin_x));
+}
+
+
+void
+cmd_nl(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(nl());
+}
+
+
+void
+cmd_no_color_attributes(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_int(no_color_attributes());
+}
+
+
+void
+cmd_nocbreak(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(nocbreak());
+}
+
+
+void
+cmd_nodelay(int nargs, char **args)
+{
+ int flag;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &flag) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(nodelay(win, flag));
+}
+
+
+void
+cmd_noecho(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(noecho());
+}
+
+
+void
+cmd_nonl(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(nonl());
+}
+
+
+void
+cmd_noqiflush(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ noqiflush();
+ report_count(1);
+ report_return(OK); /* fake a return, the call returns void */
+}
+
+
+void
+cmd_noraw(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(noraw());
+}
+
+
+void
+cmd_notimeout(int nargs, char **args)
+{
+ int flag;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &flag) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(notimeout(win, flag));
+}
+
+
+void
+cmd_overlay(int nargs, char **args)
+{
+ WINDOW *source, *dest;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &source) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%p", &dest) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(overlay(source, dest));
+}
+
+
+void
+cmd_overwrite(int nargs, char **args)
+{
+ WINDOW *source, *dest;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &source) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%p", &dest) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(overwrite(source, dest));
+}
+
+
+void
+cmd_pair_content(int nargs, char **args)
+{
+ short pair, fore, back;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%hd", &pair) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX - call3 */
+ report_count(3);
+ report_return(pair_content(pair, &fore, &back));
+ report_int(fore);
+ report_int(back);
+}
+
+
+void
+cmd_pechochar(int nargs, char **args)
+{
+ int ch;
+ WINDOW *pad;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &pad) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &ch) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(pechochar(pad, ch));
+}
+
+
+void
+cmd_pnoutrefresh(int nargs, char **args)
+{
+ int pbeg_y, pbeg_x, sbeg_y, sbeg_x, smax_y, smax_x;
+ WINDOW *pad;
+
+ if (check_arg_count(nargs, 7) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &pad) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &pbeg_y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &pbeg_x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &sbeg_y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[4], "%d", &sbeg_x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[5], "%d", &smax_y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[6], "%d", &smax_x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(pnoutrefresh(pad, pbeg_y, pbeg_x, sbeg_y, sbeg_x, smax_y,
+ smax_x));
+}
+
+
+void
+cmd_prefresh(int nargs, char **args)
+{
+ int pbeg_y, pbeg_x, sbeg_y, sbeg_x, smax_y, smax_x;
+ WINDOW *pad;
+
+ if (check_arg_count(nargs, 7) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &pad) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &pbeg_y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &pbeg_x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &sbeg_y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[4], "%d", &sbeg_x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[5], "%d", &smax_y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[6], "%d", &smax_x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX causes refresh */
+ report_count(1);
+ report_return(prefresh(pad, pbeg_y, pbeg_x, sbeg_y, sbeg_x, smax_y,
+ smax_x));
+
+}
+
+
+void
+cmd_printw(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+
+ report_count(1);
+ report_return(printw(args[0], args[1]));
+}
+
+
+void
+cmd_putwin(int nargs, char **args)
+{
+ FILE *fp;
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if ((fp = fopen(args[1], "rw")) == NULL) {
+ report_count(1);
+ report_error("BAD FILE_ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(putwin(win, fp));
+}
+
+
+void
+cmd_qiflush(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ qiflush();
+ report_count(1);
+ report_return(OK); /* fake a return because call returns void */
+}
+
+
+void
+cmd_raw(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(raw());
+}
+
+
+void
+cmd_redrawwin(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_return(redrawwin(win));
+}
+
+
+void
+cmd_reset_prog_mode(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(reset_prog_mode());
+}
+
+
+void
+cmd_reset_shell_mode(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(reset_shell_mode());
+}
+
+
+void
+cmd_resetty(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(resetty());
+}
+
+
+void
+cmd_resizeterm(int nargs, char **args)
+{
+ int rows, cols;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &rows) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &cols) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(resizeterm(rows, cols));
+}
+
+
+void
+cmd_savetty(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(savetty());
+}
+
+
+void
+cmd_scanw(int nargs, char **args)
+{
+ char string[256];
+
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ /* XXX call2 */
+ report_count(2);
+ report_return(scanw("%s", string));
+ report_status(string);
+}
+
+
+void
+cmd_scroll(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_return(scroll(win));
+}
+
+
+void
+cmd_scrollok(int nargs, char **args)
+{
+ WINDOW *win;
+ int flag;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &flag) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(scrollok(win, flag));
+}
+
+
+void
+cmd_setterm(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_return(setterm(args[0]));
+}
+
+
+void
+cmd_set_term(int nargs, char **args)
+{
+ SCREEN *scrn;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &scrn) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_ptr(set_term(scrn));
+}
+
+
+void
+cmd_start_color(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(start_color());
+}
+
+
+void
+cmd_subpad(int nargs, char **args)
+{
+ WINDOW *pad;
+ int lines, cols, begin_y, begin_x;
+
+ if (check_arg_count(nargs, 5) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &pad) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &lines) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &cols) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &begin_y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[4], "%d", &begin_x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_ptr(subpad(pad, lines, cols, begin_y, begin_x));
+}
+
+
+void
+cmd_subwin(int nargs, char **args)
+{
+ WINDOW *win;
+ int lines, cols, begin_y, begin_x;
+
+ if (check_arg_count(nargs, 5) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &lines) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &cols) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &begin_y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[4], "%d", &begin_x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_ptr(subwin(win, lines, cols, begin_y, begin_x));
+}
+
+
+void
+cmd_termattrs(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_int(termattrs());
+}
+
+
+void
+cmd_term_attrs(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_int(term_attrs());
+}
+
+
+void
+cmd_touchline(int nargs, char **args)
+{
+ WINDOW *win;
+ int start, count;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &start) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(touchline(win, start, count));
+}
+
+
+void
+cmd_touchoverlap(int nargs, char **args)
+{
+ WINDOW *win1, *win2;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win1) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%p", &win2) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(touchoverlap(win1, win2));
+}
+
+
+void
+cmd_touchwin(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_return(touchwin(win));
+}
+
+
+void
+cmd_ungetch(int nargs, char **args)
+{
+ int ch;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &ch) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(ungetch(ch));
+}
+
+
+void
+cmd_untouchwin(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_return(untouchwin(win));
+}
+
+
+void
+cmd_use_default_colors(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ report_count(1);
+ report_return(use_default_colors());
+}
+
+
+void
+cmd_vline(int nargs, char **args)
+{
+ int count;
+ chtype *ch;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ ch = (chtype *) args[0];
+
+ if (sscanf(args[1], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(vline(ch[0], count));
+}
+
+
+static int
+internal_vw_printw(WINDOW *win, char *arg1, ...)
+{
+ va_list va;
+ int rv;
+
+ va_start(va, arg1);
+ rv = vw_printw(win, arg1, va);
+ va_end(va);
+
+ return rv;
+}
+
+void
+cmd_vw_printw(int nargs, char **args)
+{
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(internal_vw_printw(win, args[1], args[2]));
+}
+
+
+static int
+internal_vw_scanw(WINDOW *win, char *arg1, ...)
+{
+ va_list va;
+ int rv;
+
+ va_start(va, arg1);
+ rv = vw_scanw(win, arg1, va);
+ va_end(va);
+
+ return rv;
+}
+
+void
+cmd_vw_scanw(int nargs, char **args)
+{
+ WINDOW *win;
+ char string[256];
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX - call2 */
+ report_count(2);
+ report_int(internal_vw_scanw(win, args[1], string));
+ report_status(string);
+}
+
+
+void
+cmd_vwprintw(int nargs, char **args)
+{
+ cmd_vw_printw(nargs, args);
+}
+
+
+void
+cmd_vwscanw(int nargs, char **args)
+{
+ cmd_vw_scanw(nargs, args);
+}
+
+
+void
+cmd_waddch(int nargs, char **args)
+{
+ WINDOW *win;
+ chtype *ch;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ ch = (chtype *) args[1];
+
+ report_count(1);
+ report_return(waddch(win, ch[0]));
+}
+
+
+void
+cmd_waddchnstr(int nargs, char **args)
+{
+ WINDOW *win;
+ int count;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(waddchnstr(win, (chtype *) args[1], count));
+}
+
+
+void
+cmd_waddchstr(int nargs, char **args)
+{
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(waddchstr(win, (chtype *) args[1]));
+}
+
+
+void
+cmd_waddnstr(int nargs, char **args)
+{
+ WINDOW *win;
+ int count;
+
+ if (check_arg_count(nargs, 1) == 3)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(waddnstr(win, args[1], count));
+
+}
+
+
+void
+cmd_wattr_get(int nargs, char **args)
+{
+ WINDOW *win;
+ int attr;
+ short pair;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX - call3 */
+ report_count(3);
+ report_return(wattr_get(win, &attr, &pair, NULL));
+ report_int(attr);
+ report_int(pair);
+}
+
+
+void
+cmd_wattr_off(int nargs, char **args)
+{
+ WINDOW *win;
+ int attr;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &attr) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wattr_off(win, attr, NULL));
+}
+
+
+void
+cmd_wattr_on(int nargs, char **args)
+{
+ WINDOW *win;
+ int attr;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &attr) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wattr_on(win, attr, NULL));
+}
+
+
+void
+cmd_wattr_set(int nargs, char **args)
+{
+ WINDOW *win;
+ int attr;
+ short pair;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &attr) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%hd", &pair) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wattr_set(win, attr, pair, NULL));
+}
+
+
+void
+cmd_wattroff(int nargs, char **args)
+{
+ WINDOW *win;
+ int attr;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &attr) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wattroff(win, attr));
+}
+
+
+void
+cmd_wattron(int nargs, char **args)
+{
+ WINDOW *win;
+ int attr;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &attr) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wattron(win, attr));
+}
+
+
+void
+cmd_wattrset(int nargs, char **args)
+{
+ WINDOW *win;
+ int attr;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &attr) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wattrset(win, attr));
+}
+
+
+void
+cmd_wbkgd(int nargs, char **args)
+{
+ WINDOW *win;
+ chtype *ch;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ ch = (chtype *) args[1];
+ report_count(1);
+ report_return(wbkgd(win, ch[0]));
+}
+
+
+void
+cmd_wbkgdset(int nargs, char **args)
+{
+ WINDOW *win;
+ int ch;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &ch) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ wbkgdset(win, ch); /* void return */
+ report_count(1);
+ report_return(OK);
+}
+
+
+void
+cmd_wborder(int nargs, char **args)
+{
+ WINDOW *win;
+ int ls, rs, ts, bs, tl, tr, bl, br;
+
+ if (check_arg_count(nargs, 9) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &ls) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &rs) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &ts) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[4], "%d", &bs) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[5], "%d", &tl) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[6], "%d", &tr) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[7], "%d", &bl) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[8], "%d", &br) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wborder(win, ls, rs, ts, bs, tl, tr, bl, br));
+}
+
+
+void
+cmd_wclear(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_return(wclear(win));
+}
+
+
+void
+cmd_wclrtobot(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_return(wclrtobot(win));
+}
+
+
+void
+cmd_wclrtoeol(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_return(wclrtoeol(win));
+
+}
+
+
+void
+cmd_wcolor_set(int nargs, char **args)
+{
+ WINDOW *win;
+ short pair;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%hd", &pair) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wcolor_set(win, pair, NULL));
+}
+
+
+void
+cmd_wdelch(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_return(wdelch(win));
+}
+
+
+void
+cmd_wdeleteln(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_return(wdeleteln(win));
+
+}
+
+
+void
+cmd_wechochar(int nargs, char **args)
+{
+ WINDOW *win;
+ int ch;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &ch) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wechochar(win, ch));
+}
+
+
+void
+cmd_werase(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_return(werase(win));
+}
+
+
+void
+cmd_wgetch(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_int(wgetch(win));
+}
+
+
+void
+cmd_wgetnstr(int nargs, char **args)
+{
+ WINDOW *win;
+ int count;
+ char string[256];
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX - call2 */
+ report_count(2);
+ report_return(wgetnstr(win, string, count));
+ report_status(string);
+}
+
+
+void
+cmd_wgetstr(int nargs, char **args)
+{
+ WINDOW *win;
+ char string[256];
+
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ string[0] = '\0';
+
+ report_count(2);
+ report_return(wgetstr(win, string));
+ report_status(string);
+}
+
+
+void
+cmd_whline(int nargs, char **args)
+{
+ WINDOW *win;
+ int ch, count;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &ch) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(whline(win, ch, count));
+}
+
+
+void
+cmd_winch(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_int(winch(win));
+}
+
+
+void
+cmd_winchnstr(int nargs, char **args)
+{
+ WINDOW *win;
+ chtype string[256];
+ int count;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX - call2 */
+ report_count(2);
+ report_return(winchnstr(win, string, count));
+ report_nstr(string);
+}
+
+
+void
+cmd_winchstr(int nargs, char **args)
+{
+ WINDOW *win;
+ chtype string[256];
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX - call2 */
+ report_count(2);
+ report_return(winchstr(win, string));
+ report_nstr(string);
+}
+
+
+void
+cmd_winnstr(int nargs, char **args)
+{
+ WINDOW *win;
+ char string[256];
+ int count;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX - call2 */
+ report_count(2);
+ report_return(winnstr(win, string, count));
+ report_status(string);
+}
+
+
+void
+cmd_winsch(int nargs, char **args)
+{
+ WINDOW *win;
+ int ch;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &ch) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(winsch(win, ch));
+}
+
+
+void
+cmd_winsdelln(int nargs, char **args)
+{
+ WINDOW *win;
+ int count;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &count) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(winsdelln(win, count));
+}
+
+
+void
+cmd_winsertln(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_return(winsertln(win));
+}
+
+
+void
+cmd_winstr(int nargs, char **args)
+{
+ WINDOW *win;
+ char string[256];
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX - call2 */
+ report_count(2);
+ report_return(winstr(win, string));
+ report_status(string);
+}
+
+
+void
+cmd_wmove(int nargs, char **args)
+{
+ WINDOW *win;
+ int y, x;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wmove(win, y, x));
+}
+
+
+void
+cmd_wnoutrefresh(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_return(wnoutrefresh(win));
+}
+
+
+void
+cmd_wprintw(int nargs, char **args)
+{
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wprintw(win, args[1], args[2]));
+}
+
+
+void
+cmd_wredrawln(int nargs, char **args)
+{
+ WINDOW *win;
+ int beg_line, num_lines;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &beg_line) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &num_lines) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wredrawln(win, beg_line, num_lines));
+}
+
+
+void
+cmd_wrefresh(int nargs, char **args)
+{
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* XXX - generates output */
+ report_count(1);
+ report_return(wrefresh(win));
+}
+
+
+void
+cmd_wresize(int nargs, char **args)
+{
+ WINDOW *win;
+ int lines, cols;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &lines) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &cols) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wresize(win, lines, cols));
+}
+
+
+void
+cmd_wscanw(int nargs, char **args)
+{
+ WINDOW *win;
+ char string[256];
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wscanw(win, args[1], &string));
+}
+
+
+void
+cmd_wscrl(int nargs, char **args)
+{
+ WINDOW *win;
+ int n;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &n) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wscrl(win, n));
+}
+
+
+void
+cmd_wsetscrreg(int nargs, char **args)
+{
+ WINDOW *win;
+ int top, bottom;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &top) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &bottom) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wsetscrreg(win, top, bottom));
+}
+
+
+void
+cmd_wstandend(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_return(wstandend(win));
+}
+
+
+void
+cmd_wstandout(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_return(wstandout(win));
+}
+
+
+void
+cmd_wtimeout(int nargs, char **args)
+{
+ WINDOW *win;
+ int tval;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &tval) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ wtimeout(win, tval); /* void return */
+ report_count(1);
+ report_return(OK);
+}
+
+
+void
+cmd_wtouchln(int nargs, char **args)
+{
+ WINDOW *win;
+ int line, n, changed;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &line) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &n) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &changed) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wtouchln(win, line, n, changed));
+}
+
+
+void
+cmd_wunderend(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_return(wunderend(win));
+}
+
+
+void
+cmd_wunderscore(int nargs, char **args)
+{
+ WINDOW *win;
+
+ 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(1);
+ report_return(wunderscore(win));
+}
+
+
+void
+cmd_wvline(int nargs, char **args)
+{
+ WINDOW *win;
+ int n;
+ chtype *ch;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ ch = (chtype *) args[1];
+
+ if (sscanf(args[2], "%d", &n) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wvline(win, ch[0], n));
+}
+
+
+void
+cmd_insnstr(int nargs, char **args)
+{
+ int n;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[1], "%d", &n) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(insnstr(args[0], n));
+}
+
+
+void
+cmd_insstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_return(insstr(args[0]));
+}
+
+
+void
+cmd_mvinsnstr(int nargs, char **args)
+{
+ int y, x, n;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &n) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvinsnstr(y, x, args[2], n));
+}
+
+
+void
+cmd_mvinsstr(int nargs, char **args)
+{
+ int y, x;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvinsstr(y, x, args[2]));
+}
+
+
+void
+cmd_mvwinsnstr(int nargs, char **args)
+{
+ WINDOW *win;
+ int y, x, n;
+
+ if (check_arg_count(nargs, 5) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[4], "%d", &n) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvwinsnstr(win, y, x, args[3], n));
+
+}
+
+
+void
+cmd_mvwinsstr(int nargs, char **args)
+{
+ WINDOW *win;
+ int y, x;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvwinsstr(win, y, x, args[3]));
+}
+
+
+void
+cmd_winsnstr(int nargs, char **args)
+{
+ WINDOW *win;
+ int n;
+
+ if (check_arg_count(nargs, 3) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &n) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(winsnstr(win, args[1], n));
+}
+
+
+void
+cmd_winsstr(int nargs, char **args)
+{
+ WINDOW *win;
+
+ if (check_arg_count(nargs, 2) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(winsstr(win, args[1]));
+}
+
+
+
+void
+cmd_chgat(int nargs, char **args)
+{
+ int n, attr, colour;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &n) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &attr) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &colour) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ /* Note: 4th argument unused in current curses implementation */
+ report_count(1);
+ report_return(chgat(n, attr, colour, NULL));
+}
+
+
+void
+cmd_wchgat(int nargs, char **args)
+{
+ WINDOW *win;
+ int n, attr;
+ short colour;
+
+ if (check_arg_count(nargs, 4) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &n) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &attr) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%hd", &colour) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(wchgat(win, n, attr, colour, NULL));
+}
+
+
+void
+cmd_mvchgat(int nargs, char **args)
+{
+ int y, x, n, attr;
+ short colour;
+
+ if (check_arg_count(nargs, 6) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &n) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &attr) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[4], "%hd", &colour) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvchgat(y, x, n, attr, colour, NULL));
+}
+
+
+void
+cmd_mvwchgat(int nargs, char **args)
+{
+ WINDOW *win;
+ int y, x, n, attr, colour;
+
+ if (check_arg_count(nargs, 6) == 1)
+ return;
+
+ if (sscanf(args[0], "%p", &win) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[1], "%d", &y) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[2], "%d", &x) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[3], "%d", &n) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[4], "%d", &attr) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ if (sscanf(args[5], "%d", &colour) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_return(mvwchgat(win, y, x, n, attr, colour, NULL));
+}
+
+
+void
+cmd_add_wch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_wadd_wch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvadd_wch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwadd_wch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+
+void
+cmd_add_wchnstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_add_wchstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_wadd_wchnstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_wadd_wchstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvadd_wchnstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvadd_wchstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwadd_wchnstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwadd_wchstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+
+void
+cmd_addnwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_addwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvaddnwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvaddwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwaddnwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwaddwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_waddnwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_waddwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+
+void
+cmd_echo_wchar(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_wecho_wchar(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_pecho_wchar(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+
+/* insert */
+void
+cmd_ins_wch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_wins_wch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvins_wch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwins_wch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+
+void
+cmd_ins_nwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_ins_wstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvins_nwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvins_wstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwins_nwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwins_wstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_wins_nwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_wins_wstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+
+/* input */
+void
+cmd_get_wch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_unget_wch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvget_wch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwget_wch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_wget_wch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+
+void
+cmd_getn_wstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_get_wstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvgetn_wstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvget_wstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwgetn_wstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwget_wstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_wgetn_wstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_wget_wstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+
+void
+cmd_in_wch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvin_wch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwin_wch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_win_wch(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+
+void
+cmd_in_wchnstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_in_wchstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvin_wchnstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvin_wchstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwin_wchnstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwin_wchstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_win_wchnstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_win_wchstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+
+void
+cmd_innwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_inwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvinnwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvinwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwinnwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwinwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_winnwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_winwstr(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+
+/* cchar handlgin */
+void
+cmd_setcchar(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_getcchar(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+
+/* misc */
+void
+cmd_key_name(int nargs, char **args)
+{
+ int w;
+
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ if (sscanf(args[0], "%d", &w) == 0) {
+ report_count(1);
+ report_error("BAD ARGUMENT");
+ return;
+ }
+
+ report_count(1);
+ report_status(key_name(w));
+}
+
+
+void
+cmd_border_set(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_wborder_set(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_box_set(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_erasewchar(int nargs, char **args)
+{
+ wchar_t ch;
+
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ /* XXX - call2 */
+ report_count(2);
+ report_return(erasewchar(&ch));
+ report_int(ch);
+}
+
+
+void
+cmd_killwchar(int nargs, char **args)
+{
+ wchar_t ch;
+
+ if (check_arg_count(nargs, 0) == 1)
+ return;
+
+ /* XXX - call2 */
+ report_count(2);
+ report_return(erasewchar(&ch));
+ report_int(ch);
+}
+
+
+void
+cmd_hline_set(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvhline_set(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvvline_set(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwhline_set(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_mvwvline_set(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_vline_set(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_whline_set(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_wvline_set(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_bkgrnd(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_bkgrndset(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_getbkgrnd(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_wbkgrnd(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_wbkgrndset(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
+
+
+void
+cmd_wgetbkgrnd(int nargs, char **args)
+{
+ if (check_arg_count(nargs, 1) == 1)
+ return;
+
+ report_count(1);
+ report_error("UNSUPPORTED");
+}
diff --git a/contrib/netbsd-tests/lib/libcurses/slave/curses_commands.h b/contrib/netbsd-tests/lib/libcurses/slave/curses_commands.h
new file mode 100644
index 0000000..d7f2ad7
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/slave/curses_commands.h
@@ -0,0 +1,422 @@
+/* $NetBSD: curses_commands.h,v 1.3 2011/09/15 11:46:19 blymn Exp $ */
+
+/*-
+ * Copyright 2009 Brett Lymn <blymn@NetBSD.org>
+ *
+ * All rights reserved.
+ *
+ * This code has been donated to The NetBSD Foundation by the Author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ */
+
+#ifndef _CURSES_COMMANDS_H_
+#define _CURSES_COMMANDS_H_
+
+struct command_def {
+ const char *name;
+ void (*func)(int, char **);
+};
+
+/*
+ * prototypes for test commands
+ */
+void cmd_DRAIN(int, char **); /* not a curses function */
+
+void cmd_addbytes(int, char **);
+void cmd_addch(int, char **);
+void cmd_addchnstr(int, char **);
+void cmd_addchstr(int, char **);
+void cmd_addnstr(int, char **);
+void cmd_addstr(int, char **);
+void cmd_attr_get(int, char **);
+void cmd_attr_off(int, char **);
+void cmd_attr_on(int, char **);
+void cmd_attr_set(int, char **);
+void cmd_attroff(int, char **);
+void cmd_attron(int, char **);
+void cmd_attrset(int, char **);
+void cmd_bkgd(int, char **);
+void cmd_bkgdset(int, char **);
+void cmd_border(int, char **);
+void cmd_clear(int, char **);
+void cmd_clrtobot(int, char **);
+void cmd_clrtoeol(int, char **);
+void cmd_color_set(int, char **);
+void cmd_delch(int, char **);
+void cmd_deleteln(int, char **);
+void cmd_echochar(int, char **);
+void cmd_erase(int, char **);
+void cmd_getch(int, char **);
+void cmd_getnstr(int, char **);
+void cmd_getstr(int, char **);
+void cmd_inch(int, char **);
+void cmd_inchnstr(int, char **);
+void cmd_inchstr(int, char **);
+void cmd_innstr(int, char **);
+void cmd_insch(int, char **);
+void cmd_insdelln(int, char **);
+void cmd_insertln(int, char **);
+void cmd_instr(int, char **);
+void cmd_move(int, char **);
+void cmd_refresh(int, char **);
+void cmd_scrl(int, char **);
+void cmd_setscrreg(int, char **);
+void cmd_standend(int, char **);
+void cmd_standout(int, char **);
+void cmd_timeout(int, char **);
+void cmd_underscore(int, char **);
+void cmd_underend(int, char **);
+void cmd_waddbytes(int, char **);
+void cmd_waddstr(int, char **);
+void cmd_mvaddbytes(int, char **);
+void cmd_mvaddch(int, char **);
+void cmd_mvaddchnstr(int, char **);
+void cmd_mvaddchstr(int, char **);
+void cmd_mvaddnstr(int, char **);
+void cmd_mvaddstr(int, char **);
+void cmd_mvdelch(int, char **);
+void cmd_mvgetch(int, char **);
+void cmd_mvgetnstr(int, char **);
+void cmd_mvgetstr(int, char **);
+void cmd_mvinch(int, char **);
+void cmd_mvinchnstr(int, char **);
+void cmd_mvinchstr(int, char **);
+void cmd_mvinnstr(int, char **);
+void cmd_mvinsch(int, char **);
+void cmd_mvinstr(int, char **);
+
+void cmd_mvwaddbytes(int, char **);
+void cmd_mvwaddch(int, char **);
+void cmd_mvwaddchnstr(int, char **);
+void cmd_mvwaddchstr(int, char **);
+void cmd_mvwaddnstr(int, char **);
+void cmd_mvwaddstr(int, char **);
+void cmd_mvwdelch(int, char **);
+void cmd_mvwgetch(int, char **);
+void cmd_mvwgetnstr(int, char **);
+void cmd_mvwgetstr(int, char **);
+void cmd_mvwinch(int, char **);
+void cmd_mvwinsch(int, char **);
+void cmd_assume_default_colors(int, char **);
+void cmd_baudrate(int, char **);
+void cmd_beep(int, char **);
+void cmd_box(int, char **);
+void cmd_can_change_color(int, char **);
+void cmd_cbreak(int, char **);
+void cmd_chgat(int, char **);
+void cmd_clearok(int, char **);
+void cmd_color_content(int, char **);
+void cmd_copywin(int, char **);
+void cmd_curs_set(int, char **);
+void cmd_def_prog_mode(int, char **);
+void cmd_def_shell_mode(int, char **);
+void cmd_define_key(int, char **);
+void cmd_delay_output(int, char **);
+void cmd_delscreen(int, char **);
+void cmd_delwin(int, char **);
+void cmd_derwin(int, char **);
+void cmd_dupwin(int, char **);
+void cmd_doupdate(int, char **);
+void cmd_echo(int, char **);
+void cmd_endwin(int, char **);
+void cmd_erasechar(int, char **);
+void cmd_flash(int, char **);
+void cmd_flushinp(int, char **);
+void cmd_flushok(int, char **);
+void cmd_fullname(int, char **);
+void cmd_getattrs(int, char **);
+void cmd_getbkgd(int, char **);
+void cmd_getcury(int, char **);
+void cmd_getcurx(int, char **);
+void cmd_getyx(int, char **);
+void cmd_getbegy(int, char **);
+void cmd_getbegx(int, char **);
+void cmd_getmaxy(int, char **);
+void cmd_getmaxx(int, char **);
+void cmd_getpary(int, char **);
+void cmd_getparx(int, char **);
+void cmd_getparyx(int, char **);
+void cmd_gettmode(int, char **);
+void cmd_getwin(int, char **);
+void cmd_halfdelay(int, char **);
+void cmd_has_colors(int, char **);
+void cmd_has_ic(int, char **);
+void cmd_has_il(int, char **);
+void cmd_hline(int, char **);
+void cmd_idcok(int, char **);
+void cmd_idlok(int, char **);
+void cmd_init_color(int, char **);
+void cmd_init_pair(int, char **);
+void cmd_initscr(int, char **);
+void cmd_intrflush(int, char **);
+void cmd_isendwin(int, char **);
+void cmd_is_linetouched(int, char **);
+void cmd_is_wintouched(int, char **);
+void cmd_keyok(int, char **);
+void cmd_keypad(int, char **);
+void cmd_keyname(int, char **);
+void cmd_killchar(int, char **);
+void cmd_leaveok(int, char **);
+void cmd_meta(int, char **);
+void cmd_mvchgat(int, char **);
+void cmd_mvcur(int, char **);
+void cmd_mvderwin(int, char **);
+void cmd_mvhline(int, char **);
+void cmd_mvprintw(int, char **);
+void cmd_mvscanw(int, char **);
+void cmd_mvvline(int, char **);
+void cmd_mvwchgat(int, char **);
+void cmd_mvwhline(int, char **);
+void cmd_mvwvline(int, char **);
+void cmd_mvwin(int, char **);
+void cmd_mvwinchnstr(int, char **);
+void cmd_mvwinchstr(int, char **);
+void cmd_mvwinnstr(int, char **);
+void cmd_mvwinstr(int, char **);
+void cmd_mvwprintw(int, char **);
+void cmd_mvwscanw(int, char **);
+void cmd_napms(int, char **);
+void cmd_newpad(int, char **);
+void cmd_newterm(int, char **);
+void cmd_newwin(int, char **);
+void cmd_nl(int, char **);
+void cmd_no_color_attributes(int, char **);
+void cmd_nocbreak(int, char **);
+void cmd_nodelay(int, char **);
+void cmd_noecho(int, char **);
+void cmd_nonl(int, char **);
+void cmd_noqiflush(int, char **);
+void cmd_noraw(int, char **);
+void cmd_notimeout(int, char **);
+void cmd_overlay(int, char **);
+void cmd_overwrite(int, char **);
+void cmd_pair_content(int, char **);
+void cmd_pechochar(int, char **);
+void cmd_pnoutrefresh(int, char **);
+void cmd_prefresh(int, char **);
+void cmd_printw(int, char **);
+void cmd_putwin(int, char **);
+void cmd_qiflush(int, char **);
+void cmd_raw(int, char **);
+void cmd_redrawwin(int, char **);
+void cmd_reset_prog_mode(int, char **);
+void cmd_reset_shell_mode(int, char **);
+void cmd_resetty(int, char **);
+void cmd_resizeterm(int, char **);
+void cmd_savetty(int, char **);
+void cmd_scanw(int, char **);
+void cmd_scroll(int, char **);
+void cmd_scrollok(int, char **);
+void cmd_setterm(int, char **);
+void cmd_set_term(int, char **);
+void cmd_start_color(int, char **);
+void cmd_subpad(int, char **);
+void cmd_subwin(int, char **);
+void cmd_termattrs(int, char **);
+void cmd_term_attrs(int, char **);
+void cmd_touchline(int, char **);
+void cmd_touchoverlap(int, char **);
+void cmd_touchwin(int, char **);
+void cmd_ungetch(int, char **);
+void cmd_untouchwin(int, char **);
+void cmd_use_default_colors(int, char **);
+void cmd_vline(int, char **);
+void cmd_vw_printw(int, char **);
+void cmd_vw_scanw(int, char **);
+void cmd_vwprintw(int, char **);
+void cmd_vwscanw(int, char **);
+void cmd_waddch(int, char **);
+void cmd_waddchnstr(int, char **);
+void cmd_waddchstr(int, char **);
+void cmd_waddnstr(int, char **);
+void cmd_wattr_get(int, char **);
+void cmd_wattr_off(int, char **);
+void cmd_wattr_on(int, char **);
+void cmd_wattr_set(int, char **);
+void cmd_wattroff(int, char **);
+void cmd_wattron(int, char **);
+void cmd_wattrset(int, char **);
+void cmd_wbkgd(int, char **);
+void cmd_wbkgdset(int, char **);
+void cmd_wborder(int, char **);
+void cmd_wchgat(int, char **);
+void cmd_wclear(int, char **);
+void cmd_wclrtobot(int, char **);
+void cmd_wclrtoeol(int, char **);
+void cmd_wcolor_set(int, char **);
+void cmd_wdelch(int, char **);
+void cmd_wdeleteln(int, char **);
+void cmd_wechochar(int, char **);
+void cmd_werase(int, char **);
+void cmd_wgetch(int, char **);
+void cmd_wgetnstr(int, char **);
+void cmd_wgetstr(int, char **);
+void cmd_whline(int, char **);
+void cmd_winch(int, char **);
+void cmd_winchnstr(int, char **);
+void cmd_winchstr(int, char **);
+void cmd_winnstr(int, char **);
+void cmd_winsch(int, char **);
+void cmd_winsdelln(int, char **);
+void cmd_winsertln(int, char **);
+void cmd_winstr(int, char **);
+void cmd_wmove(int, char **);
+void cmd_wnoutrefresh(int, char **);
+void cmd_wprintw(int, char **);
+void cmd_wredrawln(int, char **);
+void cmd_wrefresh(int, char **);
+void cmd_wresize(int, char **);
+void cmd_wscanw(int, char **);
+void cmd_wscrl(int, char **);
+void cmd_wsetscrreg(int, char **);
+void cmd_wstandend(int, char **);
+void cmd_wstandout(int, char **);
+void cmd_wtimeout(int, char **);
+void cmd_wtouchln(int, char **);
+void cmd_wunderend(int, char **);
+void cmd_wunderscore(int, char **);
+void cmd_wvline(int, char **);
+void cmd_insnstr(int, char **);
+void cmd_insstr(int, char **);
+void cmd_mvinsnstr(int, char **);
+void cmd_mvinsstr(int, char **);
+void cmd_mvwinsnstr(int, char **);
+void cmd_mvwinsstr(int, char **);
+void cmd_winsnstr(int, char **);
+void cmd_winsstr(int, char **);
+
+void cmd_chgat(int, char **);
+void cmd_wchgat(int, char **);
+void cmd_mvchgat(int, char **);
+void cmd_mvwchgat(int, char **);
+void cmd_add_wch(int, char **);
+void cmd_wadd_wch(int, char **);
+void cmd_mvadd_wch(int, char **);
+void cmd_mvwadd_wch(int, char **);
+
+void cmd_add_wchnstr(int, char **);
+void cmd_add_wchstr(int, char **);
+void cmd_wadd_wchnstr(int, char **);
+void cmd_wadd_wchstr(int, char **);
+void cmd_mvadd_wchnstr(int, char **);
+void cmd_mvadd_wchstr(int, char **);
+void cmd_mvwadd_wchnstr(int, char **);
+void cmd_mvwadd_wchstr(int, char **);
+
+void cmd_addnwstr(int, char **);
+void cmd_addwstr(int, char **);
+void cmd_mvaddnwstr(int, char **);
+void cmd_mvaddwstr(int, char **);
+void cmd_mvwaddnwstr(int, char **);
+void cmd_mvwaddwstr(int, char **);
+void cmd_waddnwstr(int, char **);
+void cmd_waddwstr(int, char **);
+
+void cmd_echo_wchar(int, char **);
+void cmd_wecho_wchar(int, char **);
+void cmd_pecho_wchar(int, char **);
+
+/* insert */
+void cmd_ins_wch(int, char **);
+void cmd_wins_wch(int, char **);
+void cmd_mvins_wch(int, char **);
+void cmd_mvwins_wch(int, char **);
+
+void cmd_ins_nwstr(int, char **);
+void cmd_ins_wstr(int, char **);
+void cmd_mvins_nwstr(int, char **);
+void cmd_mvins_wstr(int, char **);
+void cmd_mvwins_nwstr(int, char **);
+void cmd_mvwins_wstr(int, char **);
+void cmd_wins_nwstr(int, char **);
+void cmd_wins_wstr(int, char **);
+
+/* input */
+void cmd_get_wch(int, char **);
+void cmd_unget_wch(int, char **);
+void cmd_mvget_wch(int, char **);
+void cmd_mvwget_wch(int, char **);
+void cmd_wget_wch(int, char **);
+
+void cmd_getn_wstr(int, char **);
+void cmd_get_wstr(int, char **);
+void cmd_mvgetn_wstr(int, char **);
+void cmd_mvget_wstr(int, char **);
+void cmd_mvwgetn_wstr(int, char **);
+void cmd_mvwget_wstr(int, char **);
+void cmd_wgetn_wstr(int, char **);
+void cmd_wget_wstr(int, char **);
+
+void cmd_in_wch(int, char **);
+void cmd_mvin_wch(int, char **);
+void cmd_mvwin_wch(int, char **);
+void cmd_win_wch(int, char **);
+
+void cmd_in_wchnstr(int, char **);
+void cmd_in_wchstr(int, char **);
+void cmd_mvin_wchnstr(int, char **);
+void cmd_mvin_wchstr(int, char **);
+void cmd_mvwin_wchnstr(int, char **);
+void cmd_mvwin_wchstr(int, char **);
+void cmd_win_wchnstr(int, char **);
+void cmd_win_wchstr(int, char **);
+
+void cmd_innwstr(int, char **);
+void cmd_inwstr(int, char **);
+void cmd_mvinnwstr(int, char **);
+void cmd_mvinwstr(int, char **);
+void cmd_mvwinnwstr(int, char **);
+void cmd_mvwinwstr(int, char **);
+void cmd_winnwstr(int, char **);
+void cmd_winwstr(int, char **);
+
+/* cchar handlgin */
+void cmd_setcchar(int, char **);
+void cmd_getcchar(int, char **);
+
+/* misc */
+void cmd_key_name(int, char **);
+void cmd_border_set(int, char **);
+void cmd_wborder_set(int, char **);
+void cmd_box_set(int, char **);
+void cmd_erasewchar(int, char **);
+void cmd_killwchar(int, char **);
+void cmd_hline_set(int, char **);
+void cmd_mvhline_set(int, char **);
+void cmd_mvvline_set(int, char **);
+void cmd_mvwhline_set(int, char **);
+void cmd_mvwvline_set(int, char **);
+void cmd_vline_set(int, char **);
+void cmd_whline_set(int, char **);
+void cmd_wvline_set(int, char **);
+void cmd_bkgrnd(int, char **);
+void cmd_bkgrndset(int, char **);
+void cmd_getbkgrnd(int, char **);
+void cmd_wbkgrnd(int, char **);
+void cmd_wbkgrndset(int, char **);
+void cmd_wgetbkgrnd(int, char **);
+
+
+
+
+#endif /* !_CURSES_COMMAND_H_ */
diff --git a/contrib/netbsd-tests/lib/libcurses/slave/slave.c b/contrib/netbsd-tests/lib/libcurses/slave/slave.c
new file mode 100644
index 0000000..b05a1da
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/slave/slave.c
@@ -0,0 +1,177 @@
+/* $NetBSD: slave.c,v 1.6 2011/09/15 11:46:19 blymn Exp $ */
+
+/*-
+ * Copyright 2009 Brett Lymn <blymn@NetBSD.org>
+ *
+ * All rights reserved.
+ *
+ * This code has been donated to The NetBSD Foundation by the Author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ */
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <curses.h>
+#include "returns.h"
+#include "slave.h"
+
+int cmdpipe[2];
+int slvpipe[2];
+
+#if 0
+static const char *returns_enum_names[] = {
+ "unused", "numeric", "string", "byte", "ERR", "OK", "NULL", "not NULL",
+ "variable"
+};
+#endif
+
+/*
+ * Read the command pipe for the function to execute, gather the args
+ * and then process the command.
+ */
+static void
+process_commands(WINDOW *mainscr)
+{
+ int len, maxlen, argslen, i, ret, type;
+ char *cmdbuf, *tmpbuf, **args, **tmpargs;
+
+ len = maxlen = 30;
+ if ((cmdbuf = malloc(maxlen)) == NULL)
+ err(1, "slave cmdbuf malloc failed");
+
+ while(1) {
+ if (read(cmdpipe[READ_PIPE], &type, sizeof(int)) < 0)
+ err(1, "slave command type read failed");
+
+ if (type != ret_string)
+ errx(1, "Unexpected type for command, got %d", type);
+
+ if (read(cmdpipe[READ_PIPE], &len, sizeof(int)) < 0)
+ err(1, "slave command len read failed");
+
+ if ((len + 1) > maxlen) {
+ maxlen = len + 1;
+ if ((tmpbuf = realloc(cmdbuf, maxlen)) == NULL)
+ err(1, "slave cmdbuf realloc to %d "
+ "bytes failed", maxlen);
+ cmdbuf = tmpbuf;
+ }
+
+ if (read(cmdpipe[READ_PIPE], cmdbuf, len) < 0)
+ err(1, "slave command read failed");
+ cmdbuf[len] = '\0';
+ argslen = 0;
+ args = NULL;
+
+ do {
+ if (read(cmdpipe[READ_PIPE], &type, sizeof(int)) < 0)
+ err(1, "slave arg type read failed");
+
+ if (read(cmdpipe[READ_PIPE], &len, sizeof(int)) < 0)
+ err(1, "slave arg len read failed");
+
+ if (len >= 0) {
+ tmpargs = realloc(args,
+ (argslen + 1) * sizeof(char *));
+ if (tmpargs == NULL)
+ err(1, "slave realloc of args array "
+ "failed");
+
+ args = tmpargs;
+ if (type != ret_null) {
+ args[argslen] = malloc(len + 1);
+
+ if (args[argslen] == NULL)
+ err(1, "slave alloc of %d bytes"
+ " for args failed", len);
+ }
+
+ if (len == 0) {
+ if (type == ret_null)
+ args[argslen] = NULL;
+ else
+ args[argslen][0] = '\0';
+ } else {
+ read(cmdpipe[READ_PIPE], args[argslen],
+ len);
+ if (type != ret_byte)
+ args[argslen][len] = '\0';
+
+ if (len == 6) {
+ if (strcmp(args[argslen],
+ "STDSCR") == 0) {
+ ret = asprintf(&tmpbuf,
+ "%p",
+ stdscr);
+ if (ret < 0)
+ err(2,
+ "asprintf of stdscr failed");
+ free(args[argslen]);
+ args[argslen] = tmpbuf;
+ }
+ }
+ }
+
+ argslen++;
+ }
+ }
+ while(len >= 0);
+
+ command_execute(cmdbuf, argslen, args);
+
+ if (args != NULL) {
+ for (i = 0; i < argslen; i++)
+ free(args[i]);
+
+ free(args);
+ }
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ WINDOW *mainscr;
+
+ if (argc != 5) {
+ fprintf(stderr, "Usage: %s <cmdin> <cmdout> <slvin> slvout>\n",
+ getprogname());
+ return 0;
+ }
+ sscanf(argv[1], "%d", &cmdpipe[0]);
+ sscanf(argv[2], "%d", &cmdpipe[1]);
+ sscanf(argv[3], "%d", &slvpipe[0]);
+ sscanf(argv[4], "%d", &slvpipe[1]);
+
+ mainscr = initscr();
+ if (mainscr == NULL)
+ err(1, "initscr failed");
+
+ process_commands(mainscr);
+
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libcurses/slave/slave.h b/contrib/netbsd-tests/lib/libcurses/slave/slave.h
new file mode 100644
index 0000000..98e9971
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/slave/slave.h
@@ -0,0 +1,50 @@
+/* $NetBSD: slave.h,v 1.3 2011/09/15 11:46:19 blymn Exp $ */
+
+/*-
+ * Copyright 2009 Brett Lymn <blymn@NetBSD.org>
+ *
+ * All rights reserved.
+ *
+ * This code has been donated to The NetBSD Foundation by the Author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author may not be used to endorse or promote products
+ * derived from this software withough specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ */
+#ifndef CURTEST_SLAVE_H
+#define CURTEST_SLAVE_H
+
+#include <curses.h>
+
+#define READ_PIPE 0
+#define WRITE_PIPE 1
+
+void command_execute(char *, int, char **);
+void report_count(int);
+void report_error(const char *);
+void report_int(int);
+void report_byte(chtype);
+void report_return(int);
+void report_nstr(chtype *);
+void report_status(const char *);
+void report_ptr(void *);
+int check_arg_count(int, int);
+
+#endif
diff --git a/contrib/netbsd-tests/lib/libcurses/t_curses.sh b/contrib/netbsd-tests/lib/libcurses/t_curses.sh
new file mode 100755
index 0000000..5ff9474
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/t_curses.sh
@@ -0,0 +1,294 @@
+
+h_run()
+{
+ file="$(atf_get_srcdir)/tests/${1}"
+
+ export COLUMNS=80
+ export LINES=24
+ $(atf_get_srcdir)/director \
+ -T $(atf_get_srcdir) \
+ -t atf \
+ -I $(atf_get_srcdir)/tests \
+ -C $(atf_get_srcdir)/check_files \
+ -s $(atf_get_srcdir)/slave $file || atf_fail "test ${file} failed"
+}
+
+atf_test_case startup
+startup_head()
+{
+ atf_set "descr" "Checks curses initialisation sequence"
+}
+startup_body()
+{
+ h_run start
+}
+
+atf_test_case addch
+addch_head()
+{
+ atf_set "descr" "Tests adding a chtype to stdscr"
+}
+addch_body()
+{
+ h_run addch
+}
+
+atf_test_case addchstr
+addchstr_head()
+{
+ atf_set "descr" "Tests adding a chtype string to stdscr"
+}
+addchstr_body()
+{
+ h_run addchstr
+}
+
+atf_test_case addchnstr
+addchnstr_head()
+{
+ atf_set "descr" "Tests adding bytes from a chtype string to stdscr"
+}
+addchnstr_body()
+{
+ h_run addchnstr
+}
+
+atf_test_case addstr
+addstr_head()
+{
+ atf_set "descr" "Tests adding bytes from a string to stdscr"
+}
+addstr_body()
+{
+ h_run addstr
+}
+
+atf_test_case addnstr
+addnstr_head()
+{
+ atf_set "descr" "Tests adding bytes from a string to stdscr"
+}
+addnstr_body()
+{
+ h_run addnstr
+}
+
+atf_test_case getch
+getch_head()
+{
+ atf_set "descr" "Checks reading a character input"
+}
+getch_body()
+{
+ h_run getch
+}
+
+atf_test_case timeout
+timeout_head()
+{
+ atf_set "descr" "Checks timeout when reading a character"
+}
+timeout_body()
+{
+ h_run timeout
+}
+
+atf_test_case window
+window_head()
+{
+ atf_set "descr" "Checks window creation"
+}
+window_body()
+{
+ h_run window
+}
+
+atf_test_case wborder
+wborder_head()
+{
+ atf_set "descr" "Checks drawing a border around a window"
+}
+wborder_body()
+{
+ h_run wborder
+}
+
+atf_test_case box
+box_head()
+{
+ atf_set "descr" "Checks drawing a box around a window"
+}
+box_body()
+{
+ h_run box
+}
+
+atf_test_case wprintw
+wprintw_head()
+{
+ atf_set "descr" "Checks printing to a window"
+}
+wprintw_body()
+{
+ h_run wprintw
+}
+
+atf_test_case wscrl
+wscrl_head()
+{
+ atf_set "descr" "Check window scrolling"
+}
+wscrl_body()
+{
+ h_run wscrl
+}
+
+atf_test_case mvwin
+mvwin_head()
+{
+ atf_set "descr" "Check moving a window"
+}
+mvwin_body()
+{
+ h_run mvwin
+}
+
+atf_test_case getstr
+getstr_head()
+{
+ atf_set "descr" "Check getting a string from input"
+}
+getstr_body()
+{
+ h_run getstr
+}
+
+atf_test_case termattrs
+termattrs_head()
+{
+ atf_set "descr" "Check the terminal attributes"
+}
+termattrs_body()
+{
+ h_run termattrs
+}
+
+atf_test_case assume_default_colors
+assume_default_colors_head()
+{
+ atf_set "descr" "Check setting the default color pair"
+}
+assume_default_colors_body()
+{
+ h_run assume_default_colors
+}
+
+atf_test_case attributes
+attributes_head()
+{
+ atf_set "descr" "Check setting, clearing and getting of attributes"
+}
+attributes_body()
+{
+ h_run attributes
+}
+
+atf_test_case beep
+beep_head()
+{
+ atf_set "descr" "Check sending a beep"
+}
+beep_body()
+{
+ h_run beep
+}
+
+atf_test_case background
+background_head()
+{
+ atf_set "descr" "Check setting background character and attributes for both stdscr and a window."
+}
+background_body()
+{
+ h_run background
+}
+
+atf_test_case can_change_color
+can_change_color_head()
+{
+ atf_set "descr" "Check if the terminal can change colours"
+}
+can_change_color_body()
+{
+ h_run can_change_color
+}
+
+atf_test_case cbreak
+cbreak_head()
+{
+ atf_set "descr" "Check cbreak mode works"
+}
+cbreak_body()
+{
+ h_run cbreak
+}
+
+atf_test_case clear
+clear_head()
+{
+ atf_set "descr" "Check clear and erase work"
+}
+clear_body()
+{
+ h_run clear
+}
+
+atf_test_case copywin
+copywin_head()
+{
+ atf_set "descr" "Check all the modes of copying a window work"
+}
+copywin_body()
+{
+ h_run copywin
+}
+
+atf_test_case curs_set
+curs_set_head()
+{
+ atf_set "descr" "Check setting the cursor visibility works"
+}
+curs_set_body()
+{
+ h_run curs_set
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case startup
+ atf_add_test_case addch
+ atf_add_test_case addchstr
+ atf_add_test_case addchnstr
+ atf_add_test_case addstr
+ atf_add_test_case addnstr
+ atf_add_test_case getch
+ atf_add_test_case timeout
+ atf_add_test_case window
+ atf_add_test_case wborder
+ atf_add_test_case box
+ atf_add_test_case wprintw
+ atf_add_test_case wscrl
+ atf_add_test_case mvwin
+ atf_add_test_case getstr
+ atf_add_test_case termattrs
+ atf_add_test_case can_change_color
+ atf_add_test_case assume_default_colors
+ atf_add_test_case attributes
+# atf_add_test_case beep # comment out for now - return is wrong
+ atf_add_test_case background
+ atf_add_test_case cbreak
+ atf_add_test_case clear
+ atf_add_test_case copywin
+ atf_add_test_case curs_set
+}
+
diff --git a/contrib/netbsd-tests/lib/libcurses/testframe.txt b/contrib/netbsd-tests/lib/libcurses/testframe.txt
new file mode 100644
index 0000000..19884d7
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/testframe.txt
@@ -0,0 +1,241 @@
+
+CURSES TESTFRAME
+----------------
+
+1. Introduction
+
+The curses library is a complex piece of software and, often, changes
+made to the library may introduce subtle bugs that are hidden by other
+actions so a visual check of the curses output may look correct in
+some circumstances and the bug only show itself after a certain
+sequence of actions. To assist with validating that changes made to
+the curses library have no undesired effects an automated test is
+needed to detect and highlight any changes in the curses application
+output stream. The programmer can then analyse the output changes and
+either correct a bug or update the automated test to accept the new
+output as valid.
+
+2. Architecture
+
+The curses testframe consists of two separate programs connected by a
+number of pipes and a pseudo-tty (pty). The programs are called the
+director and the slave. The director reads a configuration file of
+tests to perform, passes these commands to the slave over a pipe and
+reads the pty for any output from the slave. Data from the slave is
+compared against expected output held in a file and any differences
+are highlighted to the tester. The slave is a curses application that
+is forked by the director on start up. It reads commands from the
+director over a pipe, these commands are calls to curses routines
+along with the parameters required for the call. The slave takes the
+parameters and uses them as arguments for the requested curses routine
+call. The return value from the curses routine is passed back to the
+director over another pipe, if the curses routine updates any passed
+by reference arguments then these are also passed back to the director
+for analysis.
+
+3. Director
+
+The director has the following optional command line options:
+
+ -v enables verbose output to assist debugging
+ -s slave_path the director will execute slave_path as the slave
+ process. The default is ./slave
+ -t term Sets the TERM environment variable to term when
+ executing the slave. The default is atf
+
+There is one mandatory command line parameter, that is a file name
+that contains the test command file. The test command file holds the
+calls required to exercise a particular curses routine and validate
+both the return codes from the routines and the output from the
+slave. The test language has a small number of commands, they are:
+
+assign:
+ Assign a value to a variable. The syntax is:
+
+ assign var_name value
+
+ Where var_name is the name of the variable. Variable names are
+ an arbitrary sequence of alphanumeric characters, the variable
+ name must start with an alphabetic character. Value is the value
+ to be assigned. The value can either be a numeric or a string
+ type. Variables are created on first use and will be
+ overwritten on each subsequent use.
+
+call, call2, call3, call4:
+ All these are used to call curses routines, the only difference
+ between then is the number of expected return values. Call
+ expects one return value, call2 expects 2, call3 expects 3 and
+ call4 expects four. Any parameters that are passed by reference
+ and updated by the call are treated like returns. So, for
+ example, calling the function getyx() which has three
+ parameters, the window, a pointer to storage for y and a pointer
+ to storage for x would be called like this:
+
+ call3 OK 4 5 getyx $win1
+
+ Which calls getyx, the first (and possibly only) return is the
+ return status of the function call, in this case we expect "OK"
+ indicating that the call succeeded. The next two returns are
+ the values of y and x respectively, the parameter $win1 is a
+ variable that was assigned by a previous call. Any return can
+ be assigned to a variable by including the variable name in a
+ call return list. Variables are referenced in a call parameter
+ list by prefixing the name with a $ character. All returns are
+ validated against the expected values and an error raised if
+ there is a mismatch. The only exception to this is when the
+ return is assigned to a variable. Valid values for the returns
+ list are:
+
+ variable - assign the return to the given variable
+ name.
+ numeric - the value of the return must match the
+ number given.
+ string - an arbitrary sequence of characters
+ enclosed in double quotes.
+ ERR - expect an ERR return
+ OK - expect an OK return
+ NULL - expect a NULL pointer return
+ NON_NULL - expect a pointer that is not NULL valued
+
+ There is one special parameter that can be passed to a call,
+ that is the label STDSCR. This parameter will be substituted by
+ the value of stdscr when the function call is made.
+
+check:
+ Validate the value of a variable. This allows a variable to be
+ checked for an expected return after it has been assigned in a
+ previous call. The syntax is:
+
+ check var_name expected_result
+
+ Where var_name is a variable previously assigned and
+ expected_result is one of the valid return values listed in the
+ above call section.
+
+compare:
+ Compares the output stream from the slave against the contents
+ of a file that contains the expected
+ output. The syntax is:
+
+ compare filename
+
+ Where filename is the name of the file containing the expected
+ output. The file can either be an absolute path or relative
+ path. In the latter case the value of the environment variable
+ CHECK_PATH will be prepended to the argument to provide the path
+ to the file. The contents of this file will be compared byte by
+ byte against the output from the slave, any differences in the
+ output will be flagged. If the director is not in verbose mode
+ then the first mismatch in the byte stream will cause the
+ director to exit.
+
+comparend:
+ Performs the same function as the above compare except that
+ excess output from the slave is not discarded if there is more
+ data from the slave than there is in the check file. This
+ allows chaining of multiple check files.
+
+delay:
+ Defines an inter-character delay to be inserted between
+ characters being fed into the input of the slave. The syntax
+ is:
+
+ delay time
+
+ Where time is the amount of time to delay in milliseconds.
+
+include:
+ Include the contents of another test file, the parser will
+ suspend reading the current file and read commands from the
+ include file until the end of file of the include file is
+ reached at which point it will continue reading the original
+ file. Include files may be nested. The syntax is:
+
+ include filename
+
+ Where filename is the name of the file to include. If the
+ filename is not an absolute path then the contents of the
+ environment variable INCLUDE_PATH are prepended to the file
+ name.
+
+input:
+ Defines a string of characters that will be fed to the slave
+ when a call requires input. Any unused input will be discarded
+ after the call that required the input is called. The syntax
+ is:
+
+ input "string to pass"
+
+noinput:
+ Normally the director will error if an input function is called
+ without input being previously defined, this is to prevent input
+ functions causing the test to hang waiting for input that never
+ comes. If it is known that there is pending input for the slave
+ then the noinput keyword can be used to flag that the input
+ function has data available for it to read. The noinput command
+ only applies to the next function call then behaviour reverts to
+ the default.
+
+The testframe can define different types of strings, the type of string
+depends on the type of enclosing quotes. A null terminated string is
+indicated by enclosing double (") quotes. A byte string, one that is
+not null terminated and may contain the nul character within it is
+indicated by enclosing single (') quotes. A string of chtype
+character which are a combined attribute and character value is
+indicated by enclosing backticks (`), for this type of string pairs of
+bytes between the backticks are converted to an array of chtype, the
+first byte is the attribute and the second is the character.
+
+All strings defined will have a simple set of character substitutions
+performed on them when they are parsed. This allows the tester to
+embed some control characters into the string. Valid substitutions
+are:
+
+ \e escape
+ \n new line
+ \r carriage return
+ \t tab
+ \\ \ character
+ \nnn Where nnn is three octal digits, the character
+ represented by the octal number will be inserted into
+ the string.
+
+Any other invalid conversions will have the \ stripped and the
+subsequent characters inserted into the string.
+
+Integers may be specified by either a plain numeric (e.g. 12345) or by
+hexadecimal notation by prefixing the number with 0x (e.g. 0x3039).
+Internally, no distinction is made between the two formats and they
+can be freely intermixed.
+
+Integers and variables containing integers can have operations
+performed on them. Currently only bitwise ORing numbers together is
+supported. This can be done by separating a list of integers and
+variables with the pipe (|) symbol and enclosing the entire list in
+round brackets "()" like this:
+
+ ( $var1 | 0x0100 | $var2 | 512 )
+
+Variables and integer constants may be freely intermixed. The result
+of the operation can either be used as an argument for a call or can
+be used as an expected result for a call.
+
+In addition to all the curses calls being supported by the slave,
+there is one more special call called "drain". This call repeatedly
+called getch() until there are no more characters in stdin. The call
+assumes that the curses input is either in no delay or timed input
+mode otherwise the test will time out and fail. This call can be used
+to clear any pending input when testing testing a timed read to
+prevent the input being used in a later test.
+
+4. Slave
+
+The user has no direct interaction with the slave process. The slave
+is forked off by the director communicates to the director over a set
+of pipes and a pseudo-tty connected to its standard i/o file
+descriptors. The slave executes the passed curses calls and passes
+back return values to the director. The slave automatically calls
+initscr() on start up.
+
+
+
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/addch b/contrib/netbsd-tests/lib/libcurses/tests/addch
new file mode 100644
index 0000000..a67e385
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/addch
@@ -0,0 +1,4 @@
+include start
+call OK addch `\001t`
+call OK refresh
+compare addch.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/addchnstr b/contrib/netbsd-tests/lib/libcurses/tests/addchnstr
new file mode 100644
index 0000000..661bf74
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/addchnstr
@@ -0,0 +1,5 @@
+include start
+# note that there are more characters in the array, check we only get 5 out
+call OK addchnstr `\004a\004b\004c\004d\004e\004f\004g` 5
+call OK refresh
+compare addchstr.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/addchstr b/contrib/netbsd-tests/lib/libcurses/tests/addchstr
new file mode 100644
index 0000000..4ccf7b8
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/addchstr
@@ -0,0 +1,4 @@
+include start
+call OK addchstr `\004a\004b\004c\004d\004e`
+call OK refresh
+compare addchstr.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/addnstr b/contrib/netbsd-tests/lib/libcurses/tests/addnstr
new file mode 100644
index 0000000..9c40801
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/addnstr
@@ -0,0 +1,5 @@
+include start
+call OK addnstr "abcdefg" 5
+call OK refresh
+# should be the same as addstr
+compare addstr.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/addstr b/contrib/netbsd-tests/lib/libcurses/tests/addstr
new file mode 100644
index 0000000..8c1d24f
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/addstr
@@ -0,0 +1,4 @@
+include start
+call OK addstr "abcde"
+call OK refresh
+compare addstr.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/assume_default_colors b/contrib/netbsd-tests/lib/libcurses/tests/assume_default_colors
new file mode 100644
index 0000000..b6ccb09
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/assume_default_colors
@@ -0,0 +1,19 @@
+include start
+call OK start_color
+call OK assume_default_colors -1 -1
+call OK refresh
+compare color_start.chk
+# This should be the same as the default
+compare color_default.chk
+# default foreground, blue background
+call OK assume_default_colors -1 $COLOR_BLUE
+call OK refresh
+compare color_blue_back.chk
+# red foreground, default background
+call OK assume_default_colors $COLOR_RED -1
+call OK refresh
+compare color_red_fore.chk
+# back to default
+call OK assume_default_colors -1 -1
+call OK refresh
+compare color_default.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/attributes b/contrib/netbsd-tests/lib/libcurses/tests/attributes
new file mode 100644
index 0000000..b75d7d1
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/attributes
@@ -0,0 +1,23 @@
+include start
+# no attributes, no color
+call3 OK 0 0 attr_get
+# set reverse and bold
+call OK attr_set ($BOLD | $REVERSE) 2
+# returned attributes includes color information
+call3 OK ($ACS_IS_WACS | $BOLD | $REVERSE) 2 attr_get
+# turn off reverse
+call OK attr_off $REVERSE
+call3 OK ($ACS_IS_WACS | $BOLD) 2 attr_get
+# turn on standout
+call OK attr_on $STANDOUT
+call3 OK ($ACS_IS_WACS | $BOLD | $STANDOUT) 2 attr_get
+# turn on blink
+call OK attron $BLINK
+call3 OK ($ACS_IS_WACS | $BOLD | $STANDOUT | $BLINK) 2 attr_get
+# turn off bold
+call OK attroff $BOLD
+call3 OK ($ACS_IS_WACS | $STANDOUT | $BLINK) 2 attr_get
+# print out something to check our attributes are there, standout and blink
+call OK printw "%s" "hello"
+call OK refresh
+compare attributes.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/background b/contrib/netbsd-tests/lib/libcurses/tests/background
new file mode 100644
index 0000000..2c4a575
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/background
@@ -0,0 +1,23 @@
+include start
+call OK bkgd `\002A`
+call OK refresh
+# looks like a bug - bottom right char not filled
+compare background1.chk
+call OK printw "%s" "a test string"
+call OK refresh
+compare background2.chk
+call win1 newwin 6 6 2 5
+check win1 NON_NULL
+call OK wprintw $win1 "%s" "window 1"
+# call OK refresh
+call OK wrefresh $win1
+compare background3.chk
+call OK wbkgd $win1 `\004B`
+call OK refresh
+call OK wrefresh $win1
+compare background4.chk
+call OK wprintw $win1 "%s" "hello world"
+call OK refresh
+call OK wrefresh $win1
+compare background5.chk
+
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/beep b/contrib/netbsd-tests/lib/libcurses/tests/beep
new file mode 100644
index 0000000..832e87f
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/beep
@@ -0,0 +1,5 @@
+include start
+# SUSv2 says this should return OK but we return 1
+call 1 beep
+call OK refresh
+compare bell.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/box b/contrib/netbsd-tests/lib/libcurses/tests/box
new file mode 100644
index 0000000..bfd2e12
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/box
@@ -0,0 +1,8 @@
+include window
+call OK box $win1 `\000` `\000`
+call OK wrefresh $win1
+# default settings of box will output same as wborder
+compare wborder.chk
+call OK box $win1 `\001\000` `\004\000`
+call OK wrefresh $win1
+compare box_standout.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/can_change_color b/contrib/netbsd-tests/lib/libcurses/tests/can_change_color
new file mode 100644
index 0000000..aed622a
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/can_change_color
@@ -0,0 +1,3 @@
+include start
+# our test terminal can change colors so expect true.
+call 1 can_change_color
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/cbreak b/contrib/netbsd-tests/lib/libcurses/tests/cbreak
new file mode 100644
index 0000000..b8bf60e
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/cbreak
@@ -0,0 +1,18 @@
+include start
+# setting noecho stops getch setting cbreak itself so we should need
+# a newline before getch returns, check this works first.
+call OK noecho
+input "abcd\n"
+call 0x61 getch
+noinput
+call 0x62 getch
+noinput
+call 0x63 getch
+noinput
+call 0x64 getch
+noinput
+call 0x0a getch
+# set cbreak, getch should return without needing a newline
+input "ef"
+call OK cbreak
+call 0x65 getch
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/chgat b/contrib/netbsd-tests/lib/libcurses/tests/chgat
new file mode 100644
index 0000000..863ab11
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/chgat
@@ -0,0 +1,15 @@
+include start_color
+call OK init_pair 3 $COLOR_YELLOW $COLOR_CYAN
+call OK addch `\000d`
+call OK chgat 5 $REVERSE 3 0
+call OK refresh
+compare chgat1.chk
+call OK addch `\000e`
+call OK refresh
+compare chgat2.chk
+call OK move 0 0
+# The following should apply the attribute and colour to the whole line
+call OK chgat -1 $UNDERSCORE 3 0
+call OK refresh
+compare chgat3.chk
+
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/clear b/contrib/netbsd-tests/lib/libcurses/tests/clear
new file mode 100644
index 0000000..5aad934
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/clear
@@ -0,0 +1,57 @@
+include addstr
+call OK clear
+call OK refresh
+compare clear1.chk
+call OK move 5 5
+call OK addstr "abcde"
+call OK move 20 5
+call OK addstr "fghij"
+call OK move 10 5
+call OK refresh
+compare clear2.chk
+call OK clrtobot
+call OK refresh
+compare clear3.chk
+call OK erase
+call OK refresh
+compare clear4.chk
+include fill_screen
+compare fill.chk
+call OK erase
+call OK refresh
+compare clear5.chk
+# create a window to play with, defines win1 var
+include window_create
+call OK waddstr $win1 "abc"
+call OK mvwaddstr $win1 4 1 "efg"
+call OK wmove $win1 1 0
+call OK wrefresh $win1
+compare clear6.chk
+call OK wclrtobot $win1
+call OK wrefresh $win1
+compare clear7.chk
+include fill_screen
+comparend home.chk
+compare fill.chk
+call OK wrefresh $win1
+call OK wclear $win1
+call OK wrefresh $win1
+compare clear8.chk
+call OK clear
+call OK refresh
+compare clear1.chk
+include fill_screen
+compare fill.chk
+call OK werase $win1
+call OK wrefresh $win1
+compare clear9.chk
+call OK waddstr $win1 "abc"
+call OK mvwaddstr $win1 4 1 "efg"
+call OK wmove $win1 1 0
+call OK wrefresh $win1
+compare clear6.chk
+call OK wmove $win1 4 0
+call OK wclrtoeol $win1
+call OK wrefresh $win1
+compare clear10.chk
+
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/color_content b/contrib/netbsd-tests/lib/libcurses/tests/color_content
new file mode 100644
index 0000000..0db66e5
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/color_content
@@ -0,0 +1,12 @@
+include start
+call OK start_color
+call4 OK 0 0 0 color_content $COLOR_BLACK
+call4 OK 1000 0 0 color_content $COLOR_RED
+call4 OK 0 1000 0 color_content $COLOR_GREEN
+call4 OK 1000 1000 0 color_content $COLOR_YELLOW
+call4 OK 0 0 1000 color_content $COLOR_BLUE
+call4 OK 1000 0 1000 color_content $COLOR_MAGENTA
+call4 OK 0 1000 1000 color_content $COLOR_CYAN
+call4 OK 1000 1000 1000 color_content $COLOR_WHITE
+
+
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/color_set b/contrib/netbsd-tests/lib/libcurses/tests/color_set
new file mode 100644
index 0000000..07cd1c5
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/color_set
@@ -0,0 +1,11 @@
+include start
+call OK start_color
+call OK refresh
+comparend color_start.chk
+compare color_blank_draw.chk
+call OK init_pair 4 $COLOR_RED $COLOR_GREEN
+call OK color_set 4 0
+call OK printw "%s" "testing"
+call OK refresh
+compare color_set.chk
+
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/copywin b/contrib/netbsd-tests/lib/libcurses/tests/copywin
new file mode 100644
index 0000000..2dbec40
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/copywin
@@ -0,0 +1,81 @@
+include start
+include window_create
+call win2 newwin 7 9 10 14
+check win2 NON_NULL
+call OK wrefresh $win2
+compare copywin1.chk
+call OK mvwprintw $win1 0 0 "%s" "testin"
+call OK mvwprintw $win1 1 0 "%s" "gtesti"
+call OK mvwprintw $win1 2 0 "%s" "ngtest"
+call OK mvwprintw $win1 3 0 "%s" "ingtes"
+call OK mvwprintw $win1 4 0 "%s" "tingte"
+call OK mvwprintw $win1 5 0 "%s" "stingt"
+call OK wrefresh $win1
+compare copywin2.chk
+call OK copywin $win1 $win2 0 0 1 1 7 7 0
+call OK wrefresh $win2
+compare copywin3.chk
+call OK wclear $win1
+call OK wclear $win2
+call OK wrefresh $win1
+call OK wrefresh $win2
+compare copywin4.chk
+call OK mvwprintw $win2 0 0 "%s" "testingte"
+call OK mvwprintw $win2 1 0 "%s" "stingtest"
+call OK mvwprintw $win2 2 0 "%s" "ingtestin"
+call OK mvwprintw $win2 3 0 "%s" "gtestingt"
+call OK mvwprintw $win2 4 0 "%s" "estingtes"
+call OK mvwprintw $win2 5 0 "%s" "tingtesti"
+call OK wrefresh $win2
+compare copywin5.chk
+call OK copywin $win2 $win1 0 0 0 0 7 9 0
+call OK wrefresh $win1
+compare copywin6.chk
+call OK wclear $win1
+call OK wclear $win2
+call OK wrefresh $win1
+call OK wrefresh $win2
+compare copywin7.chk
+call OK mvwprintw $win1 0 0 "%s" "t s i "
+call OK mvwprintw $win1 1 0 "%s" "g e t "
+call OK mvwprintw $win1 2 0 "%s" "n t s "
+call OK mvwprintw $win1 3 0 "%s" " n t s"
+call OK mvwprintw $win1 4 0 "%s" "t n t "
+call OK mvwprintw $win1 5 0 "%s" " t n t"
+call OK wrefresh $win1
+compare copywin8.chk
+call OK mvwprintw $win2 0 0 "%s" " e t n"
+call OK mvwprintw $win2 1 0 "%s" " t s i"
+call OK mvwprintw $win2 2 0 "%s" " g e t"
+call OK mvwprintw $win2 3 0 "%s" "i g e "
+call OK mvwprintw $win2 4 0 "%s" " i g e"
+call OK mvwprintw $win2 5 0 "%s" "s i g "
+call OK wrefresh $win2
+compare copywin9.chk
+call OK copywin $win1 $win2 0 0 0 0 6 6 0
+call OK wrefresh $win2
+compare copywin10.chk
+call OK wclear $win1
+call OK wclear $win2
+call OK wrefresh $win1
+call OK wrefresh $win2
+compare copywin11.chk
+call OK mvwprintw $win1 0 0 "%s" "t s i "
+call OK mvwprintw $win1 1 0 "%s" "g e t "
+call OK mvwprintw $win1 2 0 "%s" "n t s "
+call OK mvwprintw $win1 3 0 "%s" " n t s"
+call OK mvwprintw $win1 4 0 "%s" "t n t "
+call OK mvwprintw $win1 5 0 "%s" " t n t"
+call OK wrefresh $win1
+compare copywin12.chk
+call OK mvwprintw $win2 0 0 "%s" " e t n"
+call OK mvwprintw $win2 1 0 "%s" " t s i"
+call OK mvwprintw $win2 2 0 "%s" " g e t"
+call OK mvwprintw $win2 3 0 "%s" "i g e "
+call OK mvwprintw $win2 4 0 "%s" " i g e"
+call OK mvwprintw $win2 5 0 "%s" "s i g "
+call OK wrefresh $win2
+compare copywin13.chk
+call OK copywin $win1 $win2 0 0 0 0 6 6 1
+call OK wrefresh $win2
+compare copywin14.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/curs_set b/contrib/netbsd-tests/lib/libcurses/tests/curs_set
new file mode 100644
index 0000000..5d7cb54
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/curs_set
@@ -0,0 +1,7 @@
+include start
+call 2 curs_set 0
+compare curs_set1.chk
+call 0 curs_set 1
+compare curs_set2.chk
+call 1 curs_set 2
+compare curs_set3.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/fill_screen b/contrib/netbsd-tests/lib/libcurses/tests/fill_screen
new file mode 100644
index 0000000..b9e2942
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/fill_screen
@@ -0,0 +1,29 @@
+#
+# Fill the screen with characters. We don't do a compare in here because
+# this is meant to be included from other tests which could result in random
+# cursor motions before the fill is done.
+#
+call OK mvaddstr 0 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 1 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 2 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 3 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 4 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 5 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 6 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 7 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 8 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 9 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 10 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 11 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 12 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 13 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 14 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 15 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 16 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 17 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 18 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 19 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 20 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 21 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK mvaddstr 22 0 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
+call OK refresh
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/getch b/contrib/netbsd-tests/lib/libcurses/tests/getch
new file mode 100644
index 0000000..9f437f5
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/getch
@@ -0,0 +1,3 @@
+include start
+input "i"
+call 105 getch
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/getstr b/contrib/netbsd-tests/lib/libcurses/tests/getstr
new file mode 100644
index 0000000..320325f
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/getstr
@@ -0,0 +1,6 @@
+include window
+input "input\n"
+call2 OK "input" wgetstr $win1
+compare wgetstr.chk
+call OK wrefresh $win1
+compare wgetstr_refresh.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/mvwin b/contrib/netbsd-tests/lib/libcurses/tests/mvwin
new file mode 100644
index 0000000..86d9bd6
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/mvwin
@@ -0,0 +1,12 @@
+include window
+call OK wmove $win1 1 1
+call OK wprintw $win1 "%s" "xxxx"
+call OK wrefresh $win1
+compare /dev/zero
+call OK refresh
+compare /dev/zero
+call OK mvwin $win1 4 7
+call OK wrefresh $win1
+compare /dev/zero
+call OK refresh
+compare /dev/zero
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/start b/contrib/netbsd-tests/lib/libcurses/tests/start
new file mode 100644
index 0000000..963f2f4
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/start
@@ -0,0 +1,3 @@
+include std_defines
+call OK refresh
+compare curses_start.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/start_color b/contrib/netbsd-tests/lib/libcurses/tests/start_color
new file mode 100644
index 0000000..6d3f133
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/start_color
@@ -0,0 +1,5 @@
+include start
+call OK start_color
+call OK refresh
+comparend color_start.chk
+compare color_blank_draw.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/std_defines b/contrib/netbsd-tests/lib/libcurses/tests/std_defines
new file mode 100644
index 0000000..9c986df
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/std_defines
@@ -0,0 +1,138 @@
+#
+# Define some standard symbols for curses so tests can reference things
+# symbolically instead of using magic numbers.
+#
+#
+# boolean
+#
+assign TRUE 0x01
+assign FALSE 0x00
+#
+# colours
+#
+assign COLOR_BLACK 0x00
+assign COLOR_RED 0x01
+assign COLOR_GREEN 0x02
+assign COLOR_YELLOW 0x03
+assign COLOR_BLUE 0x04
+assign COLOR_MAGENTA 0x05
+assign COLOR_CYAN 0x06
+assign COLOR_WHITE 0x07
+#
+# Attributes
+#
+assign NORMAL 0x00000000
+assign STANDOUT 0x00000100
+assign UNDERSCORE 0x00000200
+assign REVERSE 0x00000400
+assign BLINK 0x00000800
+assign DIM 0x00001000
+assign BOLD 0x00002000
+assign BLANK 0x00004000
+assign PROTECT 0x00008000
+assign ALTCHARSET 0x00010000
+assign ACS_IS_WACS 0x00040000
+#
+# Keys
+#
+assign KEY_BREAK 0x101
+assign KEY_DOWN 0x102
+assign KEY_UP 0x103
+assign KEY_LEFT 0x104
+assign KEY_RIGHT 0x105
+assign KEY_HOME 0x106
+assign KEY_BACKSPACE 0x107
+assign KEY_F0 0x108
+assign KEY_F1 0x109
+assign KEY_F2 0x10a
+assign KEY_F3 0x10b
+assign KEY_F4 0x10c
+assign KEY_F5 0x10d
+assign KEY_F6 0x10e
+assign KEY_F7 0x10f
+assign KEY_F8 0x110
+assign KEY_F9 0x111
+assign KEY_DL 0x148
+assign KEY_IL 0x149
+assign KEY_DC 0x14A
+assign KEY_IC 0x14B
+assign KEY_EIC 0x14C
+assign KEY_CLEAR 0x14D
+assign KEY_EOS 0x14E
+assign KEY_EOL 0x14F
+assign KEY_SF 0x150
+assign KEY_SR 0x151
+assign KEY_NPAGE 0x152
+assign KEY_PPAGE 0x153
+assign KEY_STAB 0x154
+assign KEY_CTAB 0x155
+assign KEY_CATAB 0x156
+assign KEY_ENTER 0x157
+assign KEY_SRESET 0x158
+assign KEY_RESET 0x159
+assign KEY_PRINT 0x15A
+assign KEY_LL 0x15B
+assign KEY_A1 0x15C
+assign KEY_A3 0x15D
+assign KEY_B2 0x15E
+assign KEY_C1 0x15F
+assign KEY_C3 0x160
+assign KEY_BTAB 0x161
+assign KEY_BEG 0x162
+assign KEY_CANCEL 0x163
+assign KEY_CLOSE 0x164
+assign KEY_COMMAND 0x165
+assign KEY_COPY 0x166
+assign KEY_CREATE 0x167
+assign KEY_END 0x168
+assign KEY_EXIT 0x169
+assign KEY_FIND 0x16A
+assign KEY_HELP 0x16B
+assign KEY_MARK 0x16C
+assign KEY_MESSAGE 0x16D
+assign KEY_MOVE 0x16E
+assign KEY_NEXT 0x16F
+assign KEY_OPEN 0x170
+assign KEY_OPTIONS 0x171
+assign KEY_PREVIOUS 0x172
+assign KEY_REDO 0x173
+assign KEY_REFERENCE 0x174
+assign KEY_REFRESH 0x175
+assign KEY_REPLACE 0x176
+assign KEY_RESTART 0x177
+assign KEY_RESUME 0x178
+assign KEY_SAVE 0x179
+assign KEY_SBEG 0x17A
+assign KEY_SCANCEL 0x17B
+assign KEY_SCOMMAND 0x17C
+assign KEY_SCOPY 0x17D
+assign KEY_SCREATE 0x17E
+assign KEY_SDC 0x17F
+assign KEY_SDL 0x180
+assign KEY_SELECT 0x181
+assign KEY_SEND 0x182
+assign KEY_SEOL 0x183
+assign KEY_SEXIT 0x184
+assign KEY_SFIND 0x185
+assign KEY_SHELP 0x186
+assign KEY_SHOME 0x187
+assign KEY_SIC 0x188
+assign KEY_SLEFT 0x189
+assign KEY_SMESSAGE 0x18A
+assign KEY_SMOVE 0x18B
+assign KEY_SNEXT 0x18C
+assign KEY_SOPTIONS 0x18D
+assign KEY_SPREVIOUS 0x18E
+assign KEY_SPRINT 0x18F
+assign KEY_SREDO 0x190
+assign KEY_SREPLACE 0x191
+assign KEY_SRIGHT 0x192
+assign KEY_SRSUME 0x193
+assign KEY_SSAVE 0x194
+assign KEY_SSUSPEND 0x195
+assign KEY_SUNDO 0x196
+assign KEY_SUSPEND 0x197
+assign KEY_UNDO 0x198
+assign KEY_MOUSE 0x199
+assign KEY_RESIZE 0x200
+
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/termattrs b/contrib/netbsd-tests/lib/libcurses/tests/termattrs
new file mode 100644
index 0000000..1025301
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/termattrs
@@ -0,0 +1,3 @@
+include start
+# the atf terminal can do all attributes except PROTECT
+call 0x17f00 termattrs
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/timeout b/contrib/netbsd-tests/lib/libcurses/tests/timeout
new file mode 100644
index 0000000..1adf057
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/timeout
@@ -0,0 +1,21 @@
+#
+# Validate the timeout works.
+#
+include start
+delay 2000
+input "a"
+call 97 getch
+call OK timeout 100
+input "b"
+# since delay is in effect and we set timeout the following getch should
+# return ERR not the character b.
+call -1 getch
+# drain input....
+call OK drain
+call OK timeout -1
+call OK keypad STDSCR 1
+delay 0
+input "\eOA"
+call $KEY_UP getch
+call OK refresh
+compare timeout.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/wborder b/contrib/netbsd-tests/lib/libcurses/tests/wborder
new file mode 100644
index 0000000..7a8e78f
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/wborder
@@ -0,0 +1,6 @@
+include window
+call OK wborder $win1 0 0 0 0 0 0 0 0
+call OK wrefresh $win1
+compare wborder.chk
+call OK refresh
+compare wborder_refresh.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/window b/contrib/netbsd-tests/lib/libcurses/tests/window
new file mode 100644
index 0000000..52b2d0a
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/window
@@ -0,0 +1,2 @@
+include start
+include window_create
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/window_create b/contrib/netbsd-tests/lib/libcurses/tests/window_create
new file mode 100644
index 0000000..8c96134
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/window_create
@@ -0,0 +1,4 @@
+call win1 newwin 6 6 2 5
+check win1 NON_NULL
+call OK wrefresh $win1
+compare window.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/wprintw b/contrib/netbsd-tests/lib/libcurses/tests/wprintw
new file mode 100644
index 0000000..a30fcc0
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/wprintw
@@ -0,0 +1,6 @@
+include start
+call win1 newwin 2 5 2 5
+check win1 NON_NULL
+call OK wprintw $win1 "%s" "hello"
+call OK wrefresh $win1
+compare wprintw_refresh.chk
diff --git a/contrib/netbsd-tests/lib/libcurses/tests/wscrl b/contrib/netbsd-tests/lib/libcurses/tests/wscrl
new file mode 100644
index 0000000..51be531
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libcurses/tests/wscrl
@@ -0,0 +1,11 @@
+include window
+call OK wmove $win1 1 1
+call OK wprintw $win1 "%s" "xxxx"
+call OK wrefresh $win1
+call OK refresh
+compare wscrl1.chk
+call OK scrollok $win1 1
+call OK wscrl $win1 -2
+call OK wrefresh $win1
+call OK refresh
+compare wscrl2.chk
OpenPOWER on IntegriCloud