summaryrefslogtreecommitdiff
path: root/payloads/libpayload
diff options
context:
space:
mode:
Diffstat (limited to 'payloads/libpayload')
-rw-r--r--payloads/libpayload/Config.in26
-rw-r--r--payloads/libpayload/Makefile.inc17
-rw-r--r--payloads/libpayload/configs/defconfig5
-rw-r--r--payloads/libpayload/curses/Makefile.inc136
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/HISTORY1925
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/IMPLEMNT325
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/Makefile.in108
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/PDCurses.spec52
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/README48
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/aclocal.m4613
-rwxr-xr-xpayloads/libpayload/curses/PDCurses-3.4/config.guess1500
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/config.h.in133
-rwxr-xr-xpayloads/libpayload/curses/PDCurses-3.4/config.sub1616
-rwxr-xr-xpayloads/libpayload/curses/PDCurses-3.4/configure6738
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/configure.ac285
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/curses.h1377
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/curspriv.h142
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/demos/README25
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/demos/firework.c148
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/demos/newdemo.c425
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/demos/ptest.c285
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/demos/rain.c159
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/demos/testcurs.c1144
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/demos/tui.c821
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/demos/tui.h67
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/demos/tuidemo.c233
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/demos/worm.c434
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/demos/xmas.c957
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/doc/Makefile37
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/doc/intro.txt834
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/doc/manext.c119
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/doc/sdl.txt152
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/doc/x11.txt416
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/dos/README49
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/dos/bccdos.lrf9
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/dos/bccdos.mak82
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/dos/gccdos.mak87
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/dos/mscdos.lrf50
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/dos/mscdos.mak114
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/dos/pdcclip.c129
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/dos/pdcdisp.c158
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/dos/pdcdos.h186
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/dos/pdcgetsc.c100
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/dos/pdckbd.c511
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/dos/pdcscrn.c757
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/dos/pdcsetsc.c99
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/dos/pdcutil.c105
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/dos/wccdos16.mak48
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/dos/wccdos4g.mak45
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/exp-base.def374
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/exp-wide.def90
-rwxr-xr-xpayloads/libpayload/curses/PDCurses-3.4/install-sh253
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/libobjs.mif26
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/makedist.mif20
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/os2/README43
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/os2/bccos2.mak90
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/os2/gccos2.mak148
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/os2/iccos2.lrf50
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/os2/iccos2.mak256
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/os2/pdcclip.c185
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/os2/pdcdisp.c95
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/os2/pdcgetsc.c91
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/os2/pdckbd.c519
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/os2/pdcos2.h51
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/os2/pdcscrn.c422
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/os2/pdcsetsc.c110
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/os2/pdcutil.c36
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/os2/wccos2.mak43
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/panel.h58
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/README25
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/addch.c408
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/addchstr.c242
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/addstr.c237
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/attr.c349
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/beep.c65
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/bkgd.c220
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/border.c408
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/clear.c154
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/color.c295
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/debug.c81
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/delch.c93
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/deleteln.c208
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/deprec.c29
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/getch.c410
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/getstr.c471
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/getyx.c143
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/inch.c125
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/inchstr.c211
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/initscr.c339
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/inopts.c321
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/insch.c268
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/insstr.c261
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/instr.c243
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/kernel.c256
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/keyname.c125
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/mouse.c429
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/move.c54
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/outopts.c156
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/overlay.c256
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/pad.c259
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/panel.c630
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/printw.c123
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/refresh.c276
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/scanw.c575
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/scr_dump.c210
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/scroll.c98
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/slk.c643
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/termattr.c176
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/terminfo.c215
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/touch.c160
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/util.c309
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/window.c562
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/sdl1/Makefile101
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/sdl1/Makefile.mng105
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/sdl1/README33
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/sdl1/deffont.h385
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/sdl1/deficon.h23
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcclip.c128
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcdisp.c301
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcgetsc.c32
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/sdl1/pdckbd.c389
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcscrn.c295
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcsdl.h26
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcsetsc.c62
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcutil.c23
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/sdl1/sdltest.c81
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/term.h57
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/version.mif4
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/watcom.mif59
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/README76
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/bccwin32.mak85
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/dmcwin32.mak253
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/gccwin32.mak128
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/lccwin32.mak273
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/mingwin32.mak121
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcclip.c145
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcdisp.c117
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcgetsc.c57
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdckbd.c656
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcscrn.c620
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcsetsc.c89
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcurses.icobin0 -> 1078 bytes
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcurses.rc28
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcutil.c25
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/pdcwin.h17
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/vcwin32.mak136
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/win32/wccwin32.mak51
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/Makefile.aix.in234
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/Makefile.in572
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/README64
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBox.c321
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBox.h53
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBoxP.h72
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/big_icon.xbm46
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/compose.h203
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/little_icon.xbm14
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/ncurses_cfg.h47
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdcclip.c170
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdcdisp.c132
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdcgetsc.c30
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdckbd.c102
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdcscrn.c150
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdcsetsc.c74
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdcutil.c39
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdcx11.c317
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/pdcx11.h188
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/sb.c153
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/x11.c3229
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/x11/xcurses-config.in76
-rw-r--r--payloads/libpayload/curses/curses.h (renamed from payloads/libpayload/include/curses.h)0
-rw-r--r--payloads/libpayload/curses/curses.priv.h (renamed from payloads/libpayload/include/curses.priv.h)0
-rw-r--r--payloads/libpayload/curses/form/Makefile.in170
-rw-r--r--payloads/libpayload/curses/form/READ.ME42
-rw-r--r--payloads/libpayload/curses/form/f_trace.c70
-rw-r--r--payloads/libpayload/curses/form/fld_arg.c98
-rw-r--r--payloads/libpayload/curses/form/fld_attr.c119
-rw-r--r--payloads/libpayload/curses/form/fld_current.c137
-rw-r--r--payloads/libpayload/curses/form/fld_def.c399
-rw-r--r--payloads/libpayload/curses/form/fld_dup.c101
-rw-r--r--payloads/libpayload/curses/form/fld_ftchoice.c70
-rw-r--r--payloads/libpayload/curses/form/fld_ftlink.c87
-rw-r--r--payloads/libpayload/curses/form/fld_info.c113
-rw-r--r--payloads/libpayload/curses/form/fld_just.c86
-rw-r--r--payloads/libpayload/curses/form/fld_link.c96
-rw-r--r--payloads/libpayload/curses/form/fld_max.c77
-rw-r--r--payloads/libpayload/curses/form/fld_move.c64
-rw-r--r--payloads/libpayload/curses/form/fld_newftyp.c143
-rw-r--r--payloads/libpayload/curses/form/fld_opts.c138
-rw-r--r--payloads/libpayload/curses/form/fld_pad.c85
-rw-r--r--payloads/libpayload/curses/form/fld_page.c82
-rw-r--r--payloads/libpayload/curses/form/fld_stat.c79
-rw-r--r--payloads/libpayload/curses/form/fld_type.c97
-rw-r--r--payloads/libpayload/curses/form/fld_user.c72
-rw-r--r--payloads/libpayload/curses/form/form.h423
-rw-r--r--payloads/libpayload/curses/form/form.priv.h299
-rw-r--r--payloads/libpayload/curses/form/frm_cursor.c70
-rw-r--r--payloads/libpayload/curses/form/frm_data.c193
-rw-r--r--payloads/libpayload/curses/form/frm_def.c448
-rw-r--r--payloads/libpayload/curses/form/frm_driver.c4646
-rw-r--r--payloads/libpayload/curses/form/frm_hook.c142
-rw-r--r--payloads/libpayload/curses/form/frm_opts.c127
-rw-r--r--payloads/libpayload/curses/form/frm_page.c106
-rw-r--r--payloads/libpayload/curses/form/frm_post.c124
-rw-r--r--payloads/libpayload/curses/form/frm_req_name.c170
-rw-r--r--payloads/libpayload/curses/form/frm_scale.c69
-rw-r--r--payloads/libpayload/curses/form/frm_sub.c86
-rw-r--r--payloads/libpayload/curses/form/frm_user.c72
-rw-r--r--payloads/libpayload/curses/form/frm_win.c92
-rw-r--r--payloads/libpayload/curses/form/fty_alnum.c202
-rw-r--r--payloads/libpayload/curses/form/fty_alpha.c202
-rw-r--r--payloads/libpayload/curses/form/fty_enum.c442
-rw-r--r--payloads/libpayload/curses/form/fty_generic.c297
-rw-r--r--payloads/libpayload/curses/form/fty_int.c293
-rw-r--r--payloads/libpayload/curses/form/fty_ipv4.c120
-rw-r--r--payloads/libpayload/curses/form/fty_num.c339
-rw-r--r--payloads/libpayload/curses/form/fty_regex.c350
-rw-r--r--payloads/libpayload/curses/form/headers32
-rw-r--r--payloads/libpayload/curses/form/llib-lform777
-rw-r--r--payloads/libpayload/curses/form/llib-lformt777
-rw-r--r--payloads/libpayload/curses/form/llib-lformtw783
-rw-r--r--payloads/libpayload/curses/form/llib-lformw783
-rw-r--r--payloads/libpayload/curses/form/modules78
-rw-r--r--payloads/libpayload/curses/menu/Makefile.in172
-rw-r--r--payloads/libpayload/curses/menu/READ.ME42
-rw-r--r--payloads/libpayload/curses/menu/eti.h54
-rw-r--r--payloads/libpayload/curses/menu/headers33
-rw-r--r--payloads/libpayload/curses/menu/llib-lmenu551
-rw-r--r--payloads/libpayload/curses/menu/llib-lmenut551
-rw-r--r--payloads/libpayload/curses/menu/llib-lmenutw553
-rw-r--r--payloads/libpayload/curses/menu/llib-lmenuw553
-rw-r--r--payloads/libpayload/curses/menu/m_attribs.c144
-rw-r--r--payloads/libpayload/curses/menu/m_cursor.c112
-rw-r--r--payloads/libpayload/curses/menu/m_driver.c556
-rw-r--r--payloads/libpayload/curses/menu/m_format.c131
-rw-r--r--payloads/libpayload/curses/menu/m_global.c598
-rw-r--r--payloads/libpayload/curses/menu/m_hook.c151
-rw-r--r--payloads/libpayload/curses/menu/m_item_cur.c113
-rw-r--r--payloads/libpayload/curses/menu/m_item_nam.c72
-rw-r--r--payloads/libpayload/curses/menu/m_item_new.c275
-rw-r--r--payloads/libpayload/curses/menu/m_item_opt.c159
-rw-r--r--payloads/libpayload/curses/menu/m_item_top.c107
-rw-r--r--payloads/libpayload/curses/menu/m_item_use.c76
-rw-r--r--payloads/libpayload/curses/menu/m_item_val.c104
-rw-r--r--payloads/libpayload/curses/menu/m_item_vis.c68
-rw-r--r--payloads/libpayload/curses/menu/m_items.c110
-rw-r--r--payloads/libpayload/curses/menu/m_new.c142
-rw-r--r--payloads/libpayload/curses/menu/m_opts.c183
-rw-r--r--payloads/libpayload/curses/menu/m_pad.c95
-rw-r--r--payloads/libpayload/curses/menu/m_pattern.c124
-rw-r--r--payloads/libpayload/curses/menu/m_post.c377
-rw-r--r--payloads/libpayload/curses/menu/m_req_name.c125
-rw-r--r--payloads/libpayload/curses/menu/m_scale.c76
-rw-r--r--payloads/libpayload/curses/menu/m_spacing.c113
-rw-r--r--payloads/libpayload/curses/menu/m_sub.c100
-rw-r--r--payloads/libpayload/curses/menu/m_trace.c77
-rw-r--r--payloads/libpayload/curses/menu/m_userptr.c76
-rw-r--r--payloads/libpayload/curses/menu/m_win.c100
-rw-r--r--payloads/libpayload/curses/menu/menu.h261
-rw-r--r--payloads/libpayload/curses/menu/menu.priv.h156
-rw-r--r--payloads/libpayload/curses/menu/mf_common.h95
-rw-r--r--payloads/libpayload/curses/menu/modules63
-rw-r--r--payloads/libpayload/curses/pdcurses-backend/config.h134
-rw-r--r--payloads/libpayload/curses/pdcurses-backend/lppdc.h10
-rw-r--r--payloads/libpayload/curses/pdcurses-backend/nc_alloc.h4
-rw-r--r--payloads/libpayload/curses/pdcurses-backend/ncurses_cfg.h40
-rw-r--r--payloads/libpayload/curses/pdcurses-backend/pdcdisp.c247
-rw-r--r--payloads/libpayload/curses/pdcurses-backend/pdcgetsc.c48
-rw-r--r--payloads/libpayload/curses/pdcurses-backend/pdckbd.c194
-rw-r--r--payloads/libpayload/curses/pdcurses-backend/pdcscrn.c161
-rw-r--r--payloads/libpayload/curses/pdcurses-backend/pdcsetsc.c32
-rw-r--r--payloads/libpayload/curses/pdcurses-backend/pdcutil.c49
-rw-r--r--payloads/libpayload/include/panel.h58
-rw-r--r--payloads/libpayload/include/term.h57
273 files changed, 72619 insertions, 6 deletions
diff --git a/payloads/libpayload/Config.in b/payloads/libpayload/Config.in
index fe534001bb..028dd332f9 100644
--- a/payloads/libpayload/Config.in
+++ b/payloads/libpayload/Config.in
@@ -90,9 +90,33 @@ config LIBC
bool "Enable C library support"
default y
+config CURSES
+ bool "Build a curses library"
+ default y
+
+choice
+ prompt "Curses implementation"
+ default PDCURSES
+ depends on CURSES
+
config TINYCURSES
- bool "Enable tinycurses support"
+ bool "Tinycurses"
+ help
+ Tinycurses was the first curses implementation for libpayload.
+ It features low memory consumption, static allocation of larger
+ data structures (so few or no memory allocation calls) and a
+ reduced feature set.
+
+config PDCURSES
+ bool "PDCurses"
default y
+ help
+ libpayload's PDCurses port provides a full features curses
+ implementation, including libpanel, libmenu and libform (which
+ are taken from ncurses).
+ It requires more system resources, in particularily heap memory.
+
+endchoice
config LAR
bool "LAR support"
diff --git a/payloads/libpayload/Makefile.inc b/payloads/libpayload/Makefile.inc
index 03862ca878..5a7d142b1b 100644
--- a/payloads/libpayload/Makefile.inc
+++ b/payloads/libpayload/Makefile.inc
@@ -39,7 +39,8 @@ real-target: lib
classes-$(CONFIG_PCI) += libpci
classes-$(CONFIG_LIBC) += libc
-classes-$(CONFIG_TINYCURSES) += libcurses
+classes-$(CONFIG_CURSES) += libcurses
+classes-$(CONFIG_PDCURSES) += libmenu libform libpanel
libraries := $(classes-y)
classes-y += head.o
@@ -50,7 +51,7 @@ head.o-S-deps = $(obj)/libpayload-config.h
subdirs-y := arch/$(ARCHDIR-y)
subdirs-y += crypto libc drivers libpci
-subdirs-$(CONFIG_TINYCURSES) += curses
+subdirs-$(CONFIG_CURSES) += curses
INCLUDES := -Iinclude -Iinclude/$(ARCHDIR-y) -I$(obj)
CFLAGS = $(INCLUDES) -O2 -pipe -g
@@ -64,6 +65,15 @@ $(obj)/libpayload-config.h: $(KCONFIG_AUTOHEADER)
library-targets = $(addsuffix .a,$(addprefix $(obj)/,$(libraries))) $(obj)/libpayload.a
lib: $$(library-targets) $(obj)/head.o
+extract_nth=$(word $(1), $(subst |, ,$(2)))
+
+#######################################################################
+# Add handler for special include files
+$(call add-special-class,includes)
+includes-handler= \
+ $(if $(wildcard $(1)$(call extract_nth,1,$(2))), \
+ $(eval includes += $(1)$(2)))
+
$(obj)/libpayload.a: $(foreach class,$(libraries),$$($(class)-objs))
printf " AR $(subst $(shell pwd)/,,$(@))\n"
$(AR) rc $@ $^
@@ -92,6 +102,9 @@ install: real-target
install -m 644 $$file $(DESTDIR)/libpayload/$$file; \
done
install -m 644 $(obj)/libpayload-config.h $(DESTDIR)/libpayload/include
+ $(foreach item,$(includes), \
+ install -m 755 -d $(DESTDIR)/libpayload/include/$(call extract_nth,2,$(item)); \
+ install -m 644 $(call extract_nth,1,$(item)) $(DESTDIR)/libpayload/include/$(call extract_nth,2,$(item)); )
printf " INSTALL $(DESTDIR)/libpayload/bin\n"
install -m 755 -d $(DESTDIR)/libpayload/bin
install -m 755 bin/lpgcc $(DESTDIR)/libpayload/bin
diff --git a/payloads/libpayload/configs/defconfig b/payloads/libpayload/configs/defconfig
index 77b71b7205..6d514d6b0f 100644
--- a/payloads/libpayload/configs/defconfig
+++ b/payloads/libpayload/configs/defconfig
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# libpayload version: 0.2.0
-# Sat Sep 25 14:01:26 2010
+# Tue Jul 12 15:54:09 2011
#
#
@@ -16,13 +16,14 @@
#
CONFIG_TARGET_I386=y
# CONFIG_TARGET_POWERPC is not set
+# CONFIG_MEMMAP_RAM_ONLY is not set
# CONFIG_MULTIBOOT is not set
#
# Standard Libraries
#
CONFIG_LIBC=y
-CONFIG_TINYCURSES=y
+CONFIG_PDCURSES=y
# CONFIG_CBFS is not set
#
diff --git a/payloads/libpayload/curses/Makefile.inc b/payloads/libpayload/curses/Makefile.inc
index 44e3ab7eb7..5d14431cda 100644
--- a/payloads/libpayload/curses/Makefile.inc
+++ b/payloads/libpayload/curses/Makefile.inc
@@ -27,8 +27,142 @@
## SUCH DAMAGE.
##
-subdirs-y := libform libpanel libmenu
+ifeq ($(CONFIG_TINYCURSES),y)
+INCLUDES += -Icurses
+endif
libcurses-$(CONFIG_TINYCURSES) += keyboard.c
libcurses-$(CONFIG_TINYCURSES) += tinycurses.c
libcurses-$(CONFIG_TINYCURSES) += colors.c
+
+includes-$(CONFIG_TINYCURSES) += curses.h
+
+ifeq ($(CONFIG_PDCURSES),y)
+INCLUDES += -D_LP64=0 -Icurses/PDCurses-3.4 -Icurses/pdcurses-backend -Icurses/menu -Icurses/form
+endif
+
+libcurses-$(CONFIG_PDCURSES) += pdcurses-backend/pdcdisp.c
+libcurses-$(CONFIG_PDCURSES) += pdcurses-backend/pdcgetsc.c
+libcurses-$(CONFIG_PDCURSES) += pdcurses-backend/pdckbd.c
+libcurses-$(CONFIG_PDCURSES) += pdcurses-backend/pdcscrn.c
+libcurses-$(CONFIG_PDCURSES) += pdcurses-backend/pdcsetsc.c
+libcurses-$(CONFIG_PDCURSES) += pdcurses-backend/pdcutil.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/addch.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/move.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/overlay.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/refresh.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/terminfo.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/window.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/util.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/inopts.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/addstr.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/keyname.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/instr.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/clear.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/addchstr.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/kernel.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/pad.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/insstr.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/border.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/getyx.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/getstr.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/getch.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/termattr.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/outopts.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/color.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/deleteln.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/initscr.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/slk.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/delch.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/touch.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/mouse.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/scanw.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/scroll.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/printw.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/bkgd.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/inch.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/attr.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/insch.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/inchstr.c
+libcurses-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/beep.c
+
+includes-$(CONFIG_PDCURSES) += pdcurses-backend/nc_alloc.h
+includes-$(CONFIG_PDCURSES) += pdcurses-backend/ncurses_cfg.h
+includes-$(CONFIG_PDCURSES) += PDCurses-3.4/curses.h
+includes-$(CONFIG_PDCURSES) += PDCurses-3.4/term.h
+includes-$(CONFIG_PDCURSES) += PDCurses-3.4/panel.h
+includes-$(CONFIG_PDCURSES) += menu/eti.h
+includes-$(CONFIG_PDCURSES) += menu/menu.h
+includes-$(CONFIG_PDCURSES) += menu/mf_common.h
+includes-$(CONFIG_PDCURSES) += form/form.h
+
+libpanel-$(CONFIG_PDCURSES) += PDCurses-3.4/pdcurses/panel.c
+
+libmenu-$(CONFIG_PDCURSES) += menu/m_req_name.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_item_nam.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_pad.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_cursor.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_item_new.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_attribs.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_item_opt.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_format.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_post.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_userptr.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_item_cur.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_driver.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_sub.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_win.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_global.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_item_vis.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_new.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_scale.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_spacing.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_opts.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_pattern.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_item_val.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_hook.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_item_use.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_items.c
+libmenu-$(CONFIG_PDCURSES) += menu/m_item_top.c
+libform-$(CONFIG_PDCURSES) += form/frm_page.c
+libform-$(CONFIG_PDCURSES) += form/frm_opts.c
+libform-$(CONFIG_PDCURSES) += form/frm_def.c
+libform-$(CONFIG_PDCURSES) += form/frm_req_name.c
+libform-$(CONFIG_PDCURSES) += form/fty_alpha.c
+libform-$(CONFIG_PDCURSES) += form/frm_driver.c
+libform-$(CONFIG_PDCURSES) += form/fld_user.c
+libform-$(CONFIG_PDCURSES) += form/frm_win.c
+libform-$(CONFIG_PDCURSES) += form/fld_newftyp.c
+#libform-$(CONFIG_PDCURSES) += form/fty_regex.c
+libform-$(CONFIG_PDCURSES) += form/fld_stat.c
+libform-$(CONFIG_PDCURSES) += form/fld_pad.c
+libform-$(CONFIG_PDCURSES) += form/fld_current.c
+libform-$(CONFIG_PDCURSES) += form/frm_post.c
+#libform-$(CONFIG_PDCURSES) += form/f_trace.c
+libform-$(CONFIG_PDCURSES) += form/fty_generic.c
+libform-$(CONFIG_PDCURSES) += form/fld_page.c
+libform-$(CONFIG_PDCURSES) += form/frm_hook.c
+libform-$(CONFIG_PDCURSES) += form/frm_scale.c
+libform-$(CONFIG_PDCURSES) += form/fty_int.c
+libform-$(CONFIG_PDCURSES) += form/fty_alnum.c
+libform-$(CONFIG_PDCURSES) += form/frm_cursor.c
+#libform-$(CONFIG_PDCURSES) += form/fty_ipv4.c
+libform-$(CONFIG_PDCURSES) += form/fld_link.c
+libform-$(CONFIG_PDCURSES) += form/fld_arg.c
+libform-$(CONFIG_PDCURSES) += form/fld_move.c
+libform-$(CONFIG_PDCURSES) += form/fld_def.c
+libform-$(CONFIG_PDCURSES) += form/fld_type.c
+libform-$(CONFIG_PDCURSES) += form/fld_max.c
+libform-$(CONFIG_PDCURSES) += form/fld_ftlink.c
+libform-$(CONFIG_PDCURSES) += form/fld_ftchoice.c
+libform-$(CONFIG_PDCURSES) += form/fld_info.c
+libform-$(CONFIG_PDCURSES) += form/frm_user.c
+#libform-$(CONFIG_PDCURSES) += form/fty_num.c
+libform-$(CONFIG_PDCURSES) += form/frm_sub.c
+libform-$(CONFIG_PDCURSES) += form/fty_enum.c
+libform-$(CONFIG_PDCURSES) += form/frm_data.c
+libform-$(CONFIG_PDCURSES) += form/fld_opts.c
+libform-$(CONFIG_PDCURSES) += form/fld_attr.c
+libform-$(CONFIG_PDCURSES) += form/fld_dup.c
+libform-$(CONFIG_PDCURSES) += form/fld_just.c
+
diff --git a/payloads/libpayload/curses/PDCurses-3.4/HISTORY b/payloads/libpayload/curses/PDCurses-3.4/HISTORY
new file mode 100644
index 0000000000..7cf5b71acc
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/HISTORY
@@ -0,0 +1,1925 @@
+PDCurses 3.4 - 2008/09/08
+=========================
+
+Nothing much new this time, but I've been sitting on some bug fixes for
+almost a year, so it's overdue. Apart from bugs, the main changes are in
+the documentation.
+
+New features:
+
+- setsyx() is now a function rather than a macro.
+
+Bug fixes and such:
+
+- In x11, the xc_atrtab table size was under-calculated by half,
+ resulting in crashes at (oddly) certain line counts. (It should've
+ crashed a lot more.) Reported by Mark Hessling.
+
+- Test for moved cursor was omitting the window origin offset. Reported
+ by Carey Evans.
+
+- Is DOS and OS/2, the value for max items in key_table was still wrong.
+ Reported by C.E.
+
+- Changed isendwin() so it won't crash after delscreen().
+
+- Ensure zero-termination in PDC_mbstowcs() and PDC_wcstombs().
+
+- Disable QuickEdit Mode when enabling mouse input for the Win32
+ console; reported by "Zalapkrakna".
+
+- Fix for building under Innotek C (I hope). Report by Elbert Pol, fix
+ courtesy of Paul Smedley.
+
+- Unified exports list with no duplicates -- pdcurses.def is now built
+ from components at compile time.
+
+- Don't install curspriv.h, and don't include it with binary
+ distributions.
+
+- Building DLLs with LCC is no longer supported, due to the primitive
+ nature of its make.exe.
+
+- Export the terminfo stub functions from the DLLs, too.
+
+- Added support for Apple's ".dylib" in configure. Suggested by Marc
+ Vaillant (who says it's needed with OS 10.5.)
+
+- In sdl1/Makefile.mng, ensure that CC is set.
+
+- In the gcc makefiles, "$?" didn't really have the desired effect --
+ _all_ the dependencies showed up on the command line, including
+ curses.h, and pdcurses.a twice. And apparently, this can mess up some
+ old version (?) of MinGW. So, revert to spelling out "tuidemo.o
+ tui.o". Reported by "Howard L."
+
+- Extensive documentation revision and reorganizing. More to do here.
+ For example, I moved the build instructions from INSTALL (which never
+ really described installation) to the platform-specific READMEs.
+
+- New indentation standard: four spaces, no tabs.
+
+------------------------------------------------------------------------
+
+PDCurses 3.3 - 2007/07/11
+=========================
+
+This release adds an SDL backend, refines the demos, and is faster in
+some cases.
+
+New features:
+
+- SDL port. See INSTALL, doc/sdl.txt and sdl1/* for details.
+
+- Double-buffering -- minimize screen writes by checking, in doupdate()
+ and wnoutrefresh(), whether the changes to curscr are really changes.
+ In most cases, this makes no difference (writes were already limited
+ to areas marked as changed), but it can greatly reduce the overhead
+ from touchwin(). It also helps if you have small, separated updates on
+ the same line.
+
+- The PDC_RGB colors can now be used, or not, with any platform (as long
+ as the same options are used when compiling both the library and
+ apps). This may help if you have apps that are hardwired to assume
+ certain definitions.
+
+- Restored the use_default_colors() stuff from the ncurses versions of
+ the rain and worm demos, to make them "transparent" (this is useful
+ now, with the SDL port); added transparency to newdemo.
+
+- Added setlocale() to tuidemo, to make it easier to browse files with
+ non-ASCII characters.
+
+- Sped up firework demo by replacing unneeded clear() and init_pair()
+ calls.
+
+- Allow exit from ptest demo by typing 'q'.
+
+- New functions for implementors: PDC_pair_content() and PDC_init_pair()
+ (the old pdc_atrtab stuff was arguably the last remnant of code in the
+ pdcurses directory that was based on platform details).
+
+Bug fixes and such:
+
+- Implicit wrefresh() needs to be called from wgetch() when the window's
+ cursor position is changed, even if there are no other changes.
+
+- Set SP->audible on a per-platform basis, as was documented in
+ IMPLEMNT, but not actually being done.
+
+- Minor tweaks for efficiency and readability, notably with wscrl().
+
+- tuidemo didn't work correctly on monochrome screens when A_COLOR was
+ defined -- the color pair numbers appeared as the corresponding
+ character; also, the input box was (I now realize) broken with ncurses
+ since our 2.7, and broke more subtly with PDCurses' new implicit
+ refresh handling; also, the path to the default file for the Browse
+ function was a bit off.
+
+- Assume in the demos that curs_set() is always available -- there's no
+ good test for this, and the existing tests were bogus.
+
+- Made the command-line parameter for ptest work. (If given an argument,
+ it delays that number of milliseconds between changes, instead of
+ waiting for a key, and automatically loops five times.)
+
+- Building the Win32 DLL with MinGW or Cygwin wouldn't work from outside
+ the platform directory.
+
+- Building the X11 port with Cygwin required manually editing the
+ Makefile after configuring; no longer. Reported by Warren W. Gay.
+
+- Minor tightening of configure and makefiles.
+
+- Bogus references to "ACS_BLCORNER" in the border man page. Reported by
+ "Walrii".
+
+- slk_wlabel() was not documented.
+
+- Spelling cleanup.
+
+- Changed RCSIDs to not end with a semicolon -- avoids warnings when
+ compiling with the -pedantic option.
+
+- Merged latin-1.txt into x11.txt.
+
+- Updated config.guess and config.sub to more recent versions.
+
+------------------------------------------------------------------------
+
+PDCurses 3.2 - 2007/06/06
+=========================
+
+This release mainly covers changes to the build process, along with a
+few structural changes.
+
+New features:
+
+- The panel library has been folded into the main library. What this
+ means is that you no longer need to specify "-lpanel" or equivalent
+ when linking programs that use panel functionality with PDCurses;
+ however, panel.lib/.a is still provided (as a copy of pdcurses.lib/.a)
+ so that you can, optionally, build your projects with no changes. It
+ also means that panel functionality is available with the DLL or
+ shared library. Note that panel.h remains separate from curses.h.
+
+- Setting the PDCURSES_SRCDIR environment variable is no longer required
+ before building, unless you want to build in a location other than the
+ platform directory. (See INSTALL.)
+
+- MinGW and Cygwin makefiles support building DLLs, via the "DLL=Y"
+ option. Partly due to Timofei Shatrov.
+
+- Support for the Digital Mars compiler.
+
+- Watcom makefiles now use the "loaddll" feature.
+
+Bug fixes and such:
+
+- Eliminated the platform defines (DOS, WIN32, OS2, XCURSES) from
+ curses.h, except for X11-specific SCREEN elements and functions.
+ Dynamically-linked X11 apps built against an old version will have
+ their red and blue swapped until rebuilt. (You can define PDC_RGB to
+ build the library with the old color scheme, but it would also have to
+ be defined when building any new app.) Any app that depends on
+ PDCurses to determine the platform it's building on will have to make
+ other arrangements.
+
+- Documentation cleanup -- added more details; removed some content that
+ didn't apply to PDCurses; moved the doc-building tool to the doc
+ directory; changed *.man to *.txt.
+
+- The EMX makefile now accepts "DLL=Y", builds pdcurses.dll instead of
+ curses.dll, builds either the static library or the DLL (not both at
+ once), and links all the demos with the DLL when building it.
+
+- In Win32, read the registry only when needed: when init_color() or
+ color_content() is called, instead of at startup.
+
+- A few additional consts in declarations.
+
+- The Win32 compilers that build DLLs now use common .def files.
+
+- panel.h functions sorted by name, as with other .h files; curses.h is
+ no longer included by repeated inclusions of panel.h or term.h.
+
+- Simplified Borland makefiles.
+
+- Makefile.aix.in depended on a file, xcurses.exp, that was never there.
+ This problem was fixed as part of the change to common .def files;
+ however, I still haven't been able to test building on AIX.
+
+------------------------------------------------------------------------
+
+PDCurses 3.1 - 2007/05/03
+=========================
+
+Primarily clipboard-related fixes, and special UTF-8 support.
+
+New features:
+
+- "Force UTF-8" mode, a compile-time option to force the use of UTF-8
+ for multibyte strings, instead of the system locale. (Mainly for
+ Windows, where UTF-8 doesn't work well in the console.) See INSTALL.
+
+- Multibyte string support in PDC_*clipboard() functions, and in Win32's
+ PDC_set_title().
+
+- Added the global string "ttytype", per other curses implementations,
+ for compatibility with old BSD curses.
+
+- Real functions for the "quasi-standard aliases" -- crmode(),
+ nocrmode(), draino(), resetterm(), fixterm() and saveterm().
+ (Corresponding macros removed.)
+
+Bug fixes and such:
+
+- In Win32, under NT-family OSes, the scrollback buffer would be
+ restored by endwin(), but would not be turned off again when resuming
+ curses after an endwin(). The result was an odd, partly-scrolled-up
+ display. Now, the buffer is toggled by PDC_reset_prog_mode() and
+ PDC_reset_shell_mode(), so it's properly turned off when returning
+ from an endwin().
+
+- In 3.0, selection in X11 didn't work. (Well, the selecting worked, but
+ the pasting elsewhere didn't.) This was due to the attempted fix
+ "don't return selection start as a press event," so that's been
+ reverted for now.
+
+- PDC_setclipboard() was locking up in X11. Reported by Mark Hessling.
+
+- Missing underscore in the declaration of XC_say() prevented
+ compilation with PDCDEBUG defined. Reported by M.H.
+
+- Off-by-one error in copywin() -- the maximum coordinates for the
+ destination window should be inclusive. Reported by Tiago Dionizio.
+
+- Start in echo mode, per X/Open. Reported by T.D.
+
+- Strip leading and trailing spaces from slk labels, per a literal
+ reading of X/Open. Suggested by Alexey Miheev (about ncurses, but it
+ also applies here).
+
+- The #endif for __PDCURSES__ needs to come _after_ the closing of the
+ extern "C". This has been broken since June 2005. Fortunately (?), it
+ only shows up if the file is included multiple times, and then only in
+ C++. Reported on the DOSBox forums.
+
+- Use CF_OEMTEXT instead of CF_TEXT in the narrow versions of the
+ clipboard functions in Win32, to match the console.
+
+- Changed the format of the string returned from longname().
+
+- In the clipboard test in the testcurs demo, use a single mvprintw() to
+ display the return from PDC_getclipboard(), instead of a loop of
+ addch(), which was incompatible with multibyte strings.
+
+- Moved has_key() into the keyname module, and documented it.
+
+- Moved RIPPEDOFFLINE to curspriv.h.
+
+- Typos in IMPLEMNT.
+
+------------------------------------------------------------------------
+
+PDCurses 3.0 - 2007/04/01
+=========================
+
+The focuses for this release are X/Open conformance, i18n, better color
+support, cleaner code, and more consistency across platforms.
+
+This is only a brief summary of the changes. For more details, consult
+the CVS log.
+
+New features:
+
+- An almost complete implementation of X/Open curses, including the
+ wide-character and attr_t functions (but excluding terminfo). The
+ wide-character functions work only in Win32 and X11, for now, and
+ require building the library with the appropriate options (see
+ INSTALL). Note that this is a simplistic implementation, with exactly
+ one wchar_t per cchar_t; the only characters it handles properly are
+ those that are one column wide.
+
+- Support for X Input Methods in the X11 port (see INSTALL). When built
+ this way, the internal compose key support is disabled in favor of
+ XIM's, which is a lot more complete, although you lose the box cursor.
+
+- Multibyte character support in the non-wide string handling functions,
+ per X/Open. This only works when the library is built with wide-
+ character support enabled.
+
+- Mouse support for DOS and OS/2. The DOS version includes untested
+ support for scroll wheels, via the "CuteMouse" driver.
+
+- An ncurses-compatible mouse interface, which can work in parallel with
+ the traditional PDCurses mouse interface. See the man page (or
+ mouse.c) for details.
+
+- DOS and OS/2 can now return modifiers as keys, as in Win32 and X11.
+
+- COLORS, which had been fixed at 8, is now either 8 or 16, depending on
+ the terminal -- usually 16. When it's 8, blinking mode is enabled
+ (controlled as before by the A_BLINK attribute); when it's 16, bright
+ background colors are used instead. On platforms where it can be
+ changed, the mode is toggled by the new function PDC_set_blink().
+ PDCurses tries to set PDC_set_blink(FALSE) at startup. (In Win32, it's
+ always set to FALSE; in DOS, with other than an EGA or VGA card, it
+ can't be.) Also, COLORS is now set to 0 until start_color() is called.
+
+- Corresponding to the change in COLORS, COLOR_PAIRS is now 256.
+
+- Working init_color() and color_content(). The OS/2 version of
+ init_color() works only in a full-screen session; the Win32 version
+ works only in windowed mode, and only in NT-family OSes; the DOS
+ version works only with VGA adapters (real or simulated). The Win32
+ version is based mostly on James Brown's setconsoleinfo.c
+ (www.catch22.net).
+
+- use_default_colors(), assume_default_colors(), and curses_version(),
+ after ncurses.
+
+- Added global int TABSIZE, after ncurses and Solaris curses; removed
+ window-specific _tabsize.
+
+- Logical extension to the wide-character slk_ funcs: slk_wlabel(), for
+ retrieving the label as a wide-character string.
+
+- A non-macro implementation of ncurses' wresize().
+
+- Working putwin(), getwin(), scr_dump() and scr_restore().
+
+- A working acs_map[]. Characters from the ACS are now stored in window
+ structures as a regular character plus the A_ALTCHARSET attribute, and
+ rendered to the ACS only when displayed. (This allows, for example,
+ the correct display on one platform of windows saved from another.)
+
+- In X11, allow selection and paste of UTF8_STRING.
+
+- The testcurs demo now includes a color chart and init_color() test, a
+ wide character input test, a display of wide ACS characters with
+ sample Unicode text, a specific test of flash(), more info in the
+ resize test, and attempts to change the width as well as the height.
+
+- Command-line option for MSVC to build DLLs (see INSTALL). Also, the
+ naming distinction for DLLs ("curses" vs. "pdcurses") is abandoned,
+ and either the static lib or DLL is built, not both at once (except
+ for X11).
+
+- For backwards compatibility, a special module just for deprecated
+ functions -- currently PDC_check_bios_key(), PDC_get_bios_key(),
+ PDC_get_ctrl_break() and PDC_set_ctrl_break(). These shouldn't be used
+ in applications, but currently are... in fact, all the "private"
+ functions (in curspriv.h) are subject to change and should be avoided.
+
+- A new document, IMPLEMNT, describing PDCurses' internal functions for
+ those wishing to port it to new platforms.
+
+- Mark Hessling has released the X11 port to the public domain.
+ (However, x11/ScrollBox* retain their separate copyright and MIT-like
+ license.)
+
+Bug fixes and such:
+
+- Most of the macros have been removed (along with the NOMACROS ifdef).
+ The only remaining ones are those which have to be macros to work, and
+ those that are required by X/Open to be macros. There were numerous
+ problems with the macros, and no apparent reason to keep them, except
+ tradition -- although it was PCcurses 1.x that first omitted them.
+
+- Clean separation of platform-specific code from the rest. Outside of
+ the platform directories, there remain only a few ifdefs in curses.h
+ and curspriv.h.
+
+- General reorganization and simplification.
+
+- Documentation revisions.
+
+- When expanding control characters in addch() or insch(), retain the
+ attributes from the chtype.
+
+- Preserve the A_ALTCHARSET attribute in addch() and insch().
+
+- Per X/Open, beep() should always return OK.
+
+- On platforms with a controlling terminal (i.e., not X11), curs_set(1)
+ now sets the cursor to the shape it had at the time of initscr(),
+ rather than always making it small. (Exception for DOS: If the video
+ mode has been changed by PDC_resize_screen(), curs_set(1) reverts to
+ line 6/7.) The shape is taken from SP->orig_cursor (the meaning of
+ which is platform-specific).
+
+- Stop updating the cursor position when the cursor is invisible (this
+ gives a huge performance boost in Win 9x); update the cursor position
+ from curs_set() if changing from invisible to visible.
+
+- Some tweaking of the behavior of def_prog_mode(), def_shell_mode(),
+ savetty(), reset_prog_mode(), reset_shell_mode() and resetty()...
+ still not quite right.
+
+- flash() was not implemented for Win32 or X. A portable implementation
+ is now used for all platforms. Note that it's much slower than the
+ old (DOS and OS/2) version, but this is only apparent on an extremely
+ slow machine, such as an XT.
+
+- In getstr(), backspacing on high-bit characters caused a double
+ backspace.
+
+- hline() and vline() used an incorrect (off by one) interpretation of
+ _maxx and _maxy. If values of n greater than the max were specified,
+ these functions could access unallocated memory.
+
+- innstr() is supposed to return the number of characters read, not just
+ OK or ERR. Reported by Mike Aubury.
+
+- A proper implementation of insch() -- the PDC_chadd()-based version
+ wasn't handling the control characters correctly.
+
+- Return ASCII and control key names from keyname() (problem revealed by
+ ncurses' movewindow test); also, per X/Open, return "UNKNOWN KEY" when
+ appropriate, rather than "NO KEY NAME".
+
+- Turn off the cursor from leaveok(TRUE), even in X11; leaveok(FALSE)
+ now calls curs_set(1), regardless of the previous state of the cursor.
+
+- In the slk area, BUTTON_CLICKED events now translate to function keys,
+ along with the previously recognized BUTTON_PRESSED events. Of course,
+ it should really be checking the events specified by map_button(),
+ which still doesn't work.
+
+- napms(0) now returns immediately.
+
+- A unified napms() implementation for DOS -- no longer throttles the
+ CPU when built with any compiler.
+
+- Allow backspace editing of the nocbreak() buffer.
+
+- pair_content(0, ...) is valid.
+
+- There was no check to ensure that the pnoutrefresh() window fit within
+ the screen. It now returns an ERR if it doesn't.
+
+- In X11, resize_term() must be called with parameters (0, 0), and only
+ when SP->resized is set, else it returns ERR.
+
+- Copy _bkgd in resize_window(). Patch found on Frederic L. W. Meunier's
+ web site.
+
+- slk_clear() now removes the buttons completely, as in ncurses.
+
+- Use the current foreground color for the line attributes (underline,
+ left, right), unless PDC_set_line_color() is explicitly called. After
+ setting the line color, you can reset it to this mode via
+ "PDC_set_line_color(-1)".
+
+- Removed non-macro implementations of COLOR_PAIR() and PAIR_NUMBER().
+
+- Dispensed with PDC_chadd() and PDC_chins() -- waddch() and winsch()
+ are now (again) the core functions.
+
+- Dropped or made static many obsolete, unused, and/or broken functions,
+ including PDC_chg_attrs(), PDC_cursor_on() and _off(),
+ PDC_fix_cursor(), PDC_get_attribute(), PDC_get_cur_col() and _row(),
+ PDC_set_80x25(), PDC_set_cursor_mode(), PDC_set_rows(),
+ PDC_wunderline(), PDC_wleftline(), PDC_wrightline(),
+ XCursesModifierPress() and XCurses_refresh_scrollbar().
+
+- Obsolete/unused defines: _BCHAR, _GOCHAR, _STOPCHAR, _PRINTCHAR
+ _ENDLINE, _FULLWIN and _SCROLLWIN.
+
+- Obsolete/unused elements of the WINDOW struct: _pmax*, _lastp*,
+ _lasts*.
+
+- Obsolete/unused elements of the SCREEN struct: orgcbr, visible_cursor,
+ sizeable, shell, blank, cursor, orig_emulation, font, orig_font,
+ tahead, adapter, scrnmode, kbdinfo, direct_video, video_page,
+ video_seg, video_ofs, bogus_adapter. (Some of these persist outside
+ the SCREEN struct, in the platform directories.) Added mouse_wait and
+ key_code.
+
+- Removed all the EMALLOC stuff. Straight malloc calls were used
+ elsewhere; it was undocumented outside of comments in curspriv.h; and
+ there are better ways to use a substitute malloc().
+
+- Single mouse clicks are now reportable on all platforms (not just
+ double-clicks). And in general, mouse event reporting is more
+ consistent across platforms.
+
+- The mouse cursor no longer appears in full-screen mode in Win32 unless
+ a nonzero mouse event mask is used.
+
+- ALT-keypad input now works in Win32.
+
+- In Win32, SetConsoleMode(ENABLE_WINDOW_INPUT) is not useful, and
+ appears to be the source of a four-year-old bug report (hanging in
+ THE) by Phil Smith.
+
+- Removed the PDC_THREAD_BUILD stuff, which has never worked. For the
+ record: PDCurses is not thread-safe. Neither is ncurses; and the
+ X/Open curses spec explicitly makes it a non-requirement.
+
+- With the internal compose key system in the X11 port, modifier keys
+ were breaking out of the compose state, making it impossible to type
+ accented capitals, etc. Also, Multi_key is now the default compose
+ key, instead of leaving it undefined by default; and a few more combos
+ are supported.
+
+- In X11, the first reported mouse event after startup always read as a
+ double-click at position 0, 0. (This bug was introduced in 2.8.)
+
+- In X11, don't return selection start as a press event. (Shift-click on
+ button 1 is still returned.)
+
+- In X11, properly handle pasting of high-bit chars. (It was doing an
+ unwanted sign extension.)
+
+- In X11, BUTTON_MOVED was never returned, although PDC_MOUSE_MOVED was
+ set.
+
+- The fix in 2.8 for the scroll wheel in X11 wasn't very good -- it did
+ report the events as scroll wheel events, but it doubled them. Here's
+ a proper fix.
+
+- Changed mouse handling in X11: Simpler translation table, with
+ XCursesPasteSelection() called from XCursesButton() instead of the
+ translation table; require shift with button 1 or 2 for select or
+ paste when mouse events are being reported (as with ncurses), allowing
+ passthrough of simple button 2 events. This fixes the previously
+ unreliable button 2 behavior.
+
+- Modifier keys are now returned on key up in X11, as in Win32. And in
+ general, modifier key reporting is more consistent across platforms.
+
+- Modifiers are not returned as keys when a mouse click has occurred
+ since the key press.
+
+- In BIOS mode (in DOS), count successive identical output bytes, and
+ make only one BIOS call for all of them. This dramatically improves
+ performance.
+
+- The cursor position was not always updated correctly in BIOS mode.
+
+- In testcurs, the way the ACS test was written, it would really only
+ work with a) PDCurses (with any compiler), or b) gcc (with any
+ curses). Here's a more portable implementation.
+
+- Better reporting of mouse events in testcurs.
+
+- Blank out buffer and num before the scanw() test in testcurs, in case
+ the user just hits enter or etc.; clear the screen after resizing.
+
+- Allow tuidemo to use the last line.
+
+- Separate left/right modifier keys are now reported properly in Win32.
+ (Everything was being reported as _R.)
+
+- Attempts to redirect input in Win32 now cause program exit and an
+ error message, instead of hanging.
+
+- Dropped support for the Microway NDP compiler.
+
+- Some modules renamed, rearranged.
+
+- Fixes for errors and warnings when building with Visual C++ 2005.
+
+- In MSVC, the panel library didn't work with the DLL.
+
+- Complete export lists for DLLs.
+
+- Simplified makefiles; moved common elements to .mif files; better
+ optimization; strip demos when possible.
+
+- Changed makefile targets of "pdcurses.a/lib" and "panel.a/lib" to
+ $(LIBCURSES) and $(LIBPANEL). Suggestion of Doug Kaufman.
+
+- Changed "install" target in the makefile to a double-colon rule, to
+ get around a conflict with INSTALL on non-case-sensitive filesystems,
+ such as Mac OS X's HFS+. Reported by Douglas Godfrey et al.
+
+- Make PDCurses.man dependent on manext. Suggestion of Tiziano Mueller.
+
+- Set up configure.ac so autoheader works; removed some obsolescent
+ macros. Partly the suggestion of T.M.
+
+- The X11 port now builds in the x11 directory (including the demos), as
+ with other ports.
+
+- The X11 port should now build on more 64-bit systems. Partly due to
+ M.H.
+
+- The default window title and icons for the X11 port are now "PDCurses"
+ instead of "XCurses".
+
+- Internal functions and variables made static where possible.
+
+- Adopted a somewhat more consistent naming style: Internal functions
+ with external linkage, and only those, have the prefix "PDC_";
+ external variables that aren't part of the API use "pdc_"; static
+ functions use "_"; and "XC_" and "xc_" prefixes are used for functions
+ and variables, respectively, that are shared between both processes in
+ the X11 port. Also eliminated camel casing, where possible.
+
+- Changed the encoding for non-ASCII characters in comments and
+ documentation from Latin-1 to UTF-8.
+
+------------------------------------------------------------------------
+
+PDCurses 2.8 - 2006/04/01
+=========================
+
+As with the previous version, you should assume that apps linked against
+older dynamic versions of the library won't work with this one until
+recompiled.
+
+New features:
+
+- Simpler, faster.
+
+- Declarations for all supported, standard functions, per the X/Open
+ Curses 4.2 spec, with the notable exception of getch() and ungetch().
+ You can disable the use of the macro versions by defining NOMACROS
+ before including curses.h (see xmas.c for an example). NOMACROS yields
+ smaller but theoretically slower executables.
+
+- New functions: vwprintw(), vwscanw(), vw_printw() and vw_scanw(). This
+ completes the list of X/Open 4.2 functions, except for those concerned
+ with attr_t and wide characters. Some (especially the terminfo/termcap
+ functions) aren't yet fully fleshed out, though.
+
+- Non-macro implementations for COLOR_PAIR(), PAIR_NUMBER(), getbkgd(),
+ mvgetnstr(), mvwgetnstr(), mvhline(), mvvline(), mvwhline(), and
+ mvwvline(). (The macros are still available, too.)
+
+- newterm() works now, in a limited way -- the parameters are ignored,
+ and only the first invocation will work (i.e., only one SCREEN can be
+ used).
+
+- start_color() works now -- which is to say, if you _don't_ call it,
+ you'll only get monochrome output. Also, without calling it, the
+ terminal's default colors will be used, where supported (currently
+ only in Win32). This is equivalent to the PDC_ORIGINAL_COLORS behavior
+ introduced in 2.7, except that _only_ the default colors will be used.
+ (PDC_ORIGINAL_COLORS is still available, if you want to combine the
+ use of specific colors and the default colors.)
+
+- New logic for termname() and longname(): termname() always returns
+ "pdcurses"; longname() returns "PDCurses for [platform] [adapter]
+ [COLOR/MONO]-YxX" (adapter is only defined for DOS and OS/2). This is
+ the first time these functions return _anything_ in Win32.
+
+- New installation method for XCurses: the header files are placed in a
+ subdirectory "xcurses" within the include directory, rather than being
+ renamed. (But the renamed xcurses.h and xpanel.h are also installed,
+ for backwards compatibility.) curspriv.h and term.h are now available,
+ and existing curses-based code need no longer be edited to use
+ XCurses' curses.h. And with no more need for explicit XCursesExit()
+ calls (see below), your code need not be changed at all to move from
+ another curses implementation to XCurses. It can be as simple as "gcc
+ -I/usr/local/include/xcurses -lXCurses -oprogname progname.c".
+
+- Combined readme.* into this HISTORY file, and incorporated the old 1.x
+ (PCcurses) history.
+
+- New functionality for the testcurs demo: ACS character display; menu
+ support for PgUp, PgDn, Home and End; centered menu; and it can now
+ be resized in X.
+
+- Added modified versions of the rain and worm demos from ncurses.
+
+Bug fixes and such:
+
+- Big cleanup of dead and redundant code, including unneeded defines,
+ ifdefs, and structure elements.
+
+- flushinp() was not implemented for Win32.
+
+- resetty() was not restoring LINES and COLS.
+
+- nonl() made '\n' print a line feed without carriage return. This was
+ incorrect.
+
+- Removed bogus implementation of intrflush().
+
+- The line-breakout optimization system, disabled by default in 2.7, is
+ removed in 2.8. It simply didn't work, and never has. (The typeahead()
+ function remains, for compatibility, but does nothing.)
+
+- The declarations for the printw() and scanw() function families were
+ erroneously ifdef'd.
+
+- Safer printw() calls on platforms that support vsnprintf().
+
+- Use the native vsscanf() in DJGPP, MinGW and Cygwin.
+
+- ACS_BLOCK now works in X.
+
+- Explicit calls to XCursesExit() are no longer needed.
+
+- XCURSES is now defined automatically if not DOS, OS2 or WIN32.
+
+- The default icon for XCurses wasn't working (had to remove the focus
+ hint code to fix this). Also, the default title is now "XCurses"
+ instead of "main".
+
+- Incorrect dimensions (undercounting by two in each direction) were
+ shown while resizing in X.
+
+- Scroll wheel events were not always correctly reported in X.
+
+- 32 bits are enough for the "long" chtype, but 64 bits were used on a
+ 64-bit system, wasting memory. Now conditioned on _LP64. This could be
+ faster, too.
+
+- The short, 16-bit chtype now works with XCurses.
+
+- Corrected return value for is_linetouched(), is_wintouched(),
+ can_change_color() and isendwin() (bool instead of int).
+
+- timeout(), wtimeout(), idcok() and immedok() return void.
+
+- pair_content() takes a short.
+
+- Replaced incorrect usages of attr_t with chtype. attr_t is still
+ typedef'd, for backwards compatibility. (It's supposed to be used for
+ the WA_*-style functions, which PDCurses doesn't yet support.)
+
+- Added const where required by the spec, and in other appropriate
+ places.
+
+- Removed PDC_usleep(). napms() is now the core delay routine.
+
+- Fixed poll() support in napms().
+
+- Various changes to the internal PDC_* functions -- don't depend on
+ these, and don't use them unless you absolutely have to.
+
+- Some routines accessed window structures in their variable
+ declarations, _before_ checking for a NULL window pointer.
+
+- Dropped support for the undocumented PDC_FULL_DISPLAY, wtitle(), and
+ PDC_print().
+
+- Cleaned up remaining warnings.
+
+- Reduced unnecessary #include directives -- speeds up compilation.
+
+- Fix for demos build in Borland/DOS -- the makefile in 2.7 didn't
+ specify the memory model. Reported by Erwin Waterlander.
+
+- Simplified the makefiles; e.g., some now build each demo in a single
+ step, and Watcom no longer uses demos.lnk. Also, the demo exes are now
+ stripped when possible; maximum compression used for archives built
+ by the makefiles; xcurses-config removed as part of "make distclean";
+ and I tweaked optimization for some platforms.
+
+- Reverted to /usr/local/ as default installation directory for XCurses.
+
+- Upgraded to autoconf 2.59... instantly doubling the size of the
+ configure script. Ah well. Otherwise, simplified the build system.
+
+- Dropped support for pre-ANSI compilers. (It hasn't worked since at
+ least version 2.4, anyway.)
+
+- Revised and, I hope, clarified the boilerplate and other comments.
+
+- Simplified logging and RCS ids; added RCS ids where missing.
+
+- Consistent formatting for all code, approximately equivalent to
+ "indent -kr -i8 -bl -bli0", with adjustments for 80 columns.
+
+------------------------------------------------------------------------
+
+PDCurses 2.7 - 2005/12/30
+=========================
+
+INTRODUCTION:
+
+ Hello all. As of a few weeks ago, I'm the new maintainer for PDCurses.
+ Here's a brief summary of changes in this release. (More details are
+ available in the CVS log and trackers on SourceForge.)
+
+NEW FEATURES:
+
+- Functions: delscreen(), getattrs(), has_key(), slk_color(),
+ wcolor_set(), wtimeout().
+
+- Macros: color_set(), mvhline(), mvvline(), mvwgetnstr(), mvwhline(),
+ mvwvline(), timeout(), wresize().
+
+- Stub implementations of terminfo functions (including a term.h).
+
+- More stubs for compatibility: filter(), getwin(), putwin(),
+ noqiflush(), qiflush(), scr_dump(), scr_init(), scr_restore(),
+ scr_set(), use_env(), vidattr(), vidputs().
+
+- The terminal's default colors are used as curses' default colors when
+ the environment variable "PDC_ORIGINAL_COLORS" is set to any value
+ (Win32 only at the moment).
+
+- Simplified build system.
+
+- Replaced PDC_STATIC_BUILD with its opposite, PDC_DLL_BUILD (see .mak
+ files for more info).
+
+- Minimal implementation of color_content() -- no longer a stub.
+
+- Added the remaining ACS defines (ACS_S3, ACS_BBSS, etc.) for
+ DOS/OS2/Win; "enhanced" versions of existing ACS characters used.
+
+- Support for scroll wheels.
+
+- Support for Pacific C.
+
+BUGS FIXED:
+
+- Builds correctly (including demos) on all tested platforms (see
+ below); nearly all compiler warnings have been cleaned up; the ptest
+ demo is built on all platforms; "clean" targets are improved.
+
+- The ability to build ncurses_tests has been restored (see demos dir).
+
+- Line-breakout optimization now defaults to off (equivalent to
+ "typeahead(-1)"), so output is not interrupted by keystrokes (it's
+ supposed to resume on the next refresh(), which wasn't working).
+
+- Implicit wrefresh() in wgetch() was not being invoked in nodelay mode.
+
+- subpad() was erroneously offsetting from the origin coordinates of the
+ parent pad (which are always -1,-1).
+
+- In wborder(), whline(), and wvline(), the current (wattrset) attribute
+ was being used, but not the current background (wbkgd).
+
+- Allow Russian 'r' character ASCII 0xe0 to be returned.
+
+- termattrs() now also returns A_UNDERLINE, A_REVERSE.
+
+- In Win32, with large scrollback buffers set, there was an unwanted
+ "scrollup" effect on startup.
+
+- Revamped keyboard handling for Win32.
+
+- New screen resize method for Win32.
+
+- napms(), delay_output(), etc. now work with Cygwin.
+
+- curs_set(0) wasn't working in Win32 in full-screen (ALT-ENTER) mode --
+ the cursor stayed on.
+
+- The A_REVERSE attribute was broken in XCurses.
+
+- On 64-bit systems, XCurses was ignoring every other keystroke.
+
+- Added focus hints for XCurses.
+
+- Demos (except for tuidemo) once again have their proper titles in
+ XCurses (using Xinitscr() instead of the obsolete XCursesProgramName).
+
+- The 16-bit chtype is a working option again (by removing #define
+ CHTYPE_LONG from curses.h), except in XCurses. It's not recommended;
+ but if your needs are limited, it still works.
+
+- Reset screen size in resetty() under DOS, as in Win32 and OS/2.
+
+- Changes for cursor size under DOS.
+
+- Automatic setting of BIOS mode for CGA under DOS now works.
+
+- The cursor is now always updated in PDC_gotoxy(); this fixes the
+ problem of missing characters in BIOS mode.
+
+- Macros nocbreak(), cbreak(), nocrmode(), crmode(), nodelay(),
+ nl() and nonl() now return OK.
+
+- ERR and OK are now defined as -1 and 0, respectively, for
+ compatibility with other curses implementations -- note that this
+ change is not binary compatible; you'll have to rebuild programs that
+ use shared/dynamic libraries.
+
+- Added "const" to prototypes where appropriate.
+
+- Miscellaneous code cleanup.
+
+ACKNOWLEDGEMENTS:
+
+ Walter Briscoe
+ Jean-Pierre Demailly
+ Ruslan Fedyarov
+ Warren Gay
+ Florian Grosse-Coosmann
+ Vladimir Kokovic
+ Matt Maloy
+ K.H. Man
+ Michael Ryazanov
+ Ron Thibodeau
+ Alexandr Zamaraev
+
+ and of course, MARK HESSLING, for his over 13 years of service as the
+ maintainer of PDCurses. Plus, thanks to all who've reported bugs or
+ requested features. Apologies to anyone I've forgotten.
+
+ I've tested this version on Turbo C++ 3.0 and Borland C++ 3.1 for DOS;
+ DJGPP 2.X; Open Watcom 1.3 for DOS (16 and 32-bit), Windows and OS/2;
+ EMX 0.9d and the "newgcc" version of EMX; Borland C++ 5.5 for Windows;
+ recent versions of MinGW, Cygwin, LCC-Win32 and Microsoft Visual C++;
+ and gcc under several flavors of Linux, Mac OS X, *BSD and Solaris.
+
+-- William McBrine
+
+------------------------------------------------------------------------
+
+PDCurses 2.6 - 2003/01/08
+=========================
+
+INTRODUCTION:
+
+ This release of PDCurses includes the following changes:
+
+BUGS FIXED:
+
+- Allow accented characters on Win32 platform when run on non-English
+ keyboards.
+
+- Allow "special" characters like Ctrl-S, Ctrl-Q under OS/2 to be returned.
+
+- Some bugs with halfdelay() fixed by William McBrine.
+
+- pechochar() should now work correctly.
+
+- redrawwin() macro in curses.h was incorrect - fixed by Alberto Ornaghi
+
+- Don't include "special" characters like KEY_SHIFT_L to be returned in
+ getnstr() family. Bug 542913
+
+- Entering TAB in wgetnstr() no longer exceeds requested buffer size.
+ Bug 489233
+
+- Fixed bug 550066, scrollok() and pads.
+ Also beep() called when buffer exceeded. Bug 562041.
+
+- Reverse video of X11 selection reinstated. Pablo Garcia Abio??
+
+- Right Alt modifier now works like left Alt modifier under Win32
+
+- Add support for all libXaw replacement libraries with Scrollbar bug.
+ Note that for this to work, you still have to change the libXaw
+ replacement libraries to fix the bug :-(
+
+- Don't trap signals in XCurses if calling application has ignored them.
+ Change by Frank Heckenbach.
+
+- Bug reports from Warren W. Gay:
+ - Fix termattrs() to return A_REVERSE and A_BLINK on all platforms.
+ - Fix definition of getsyx() and setsyx() to be consistent with
+ ncurses. Bug 624424.
+ - Fix definition of echo() and noecho(). Bug 625001.
+ - Fix definition of keypad() and leaveok(). Bug 632653.
+ - Missing panel_hidden() prototype. Bug 649320.
+
+- Fixed bug with calling def_prog_mode(), resize_term(),
+ reset_prog_mode(); the resize details were being lost.
+
+NEW FEATURES:
+
+- Clipboard support now available on DOS platform, but handled
+ internally to the currently running process.
+
+- New X11 resource: textCursor, allows the text cursor to be specified
+ as a vertical bar, or the standard horizontal bar. Thanks to Frank
+ Heckenbach for the suggestion.
+
+NEW COMPILER SUPPORT:
+
+- lcc-win32 now works correctly
+
+------------------------------------------------------------------------
+
+PDCurses 2.5 - 2001/11/26
+=========================
+
+INTRODUCTION:
+
+ This release of PDCurses includes the following changes:
+
+- Set BASE address for Win32 DLL
+
+- Add KEY_SUP and KEY_SDOWN.
+
+- Add PDC_set_line_color()
+
+- Add blink support as bold background
+
+- Add bold colors
+
+- Add getbkgd() macro
+
+- Add new PDC functions for adding underline, overline, leftline and
+ rightline
+
+- Add support for shifted keypad keys.
+
+- Allow more keypad keys to work under Win32
+
+- Change Win32 and OS/2 DLL name to curses.dll
+
+- Change example resources to allow overriding from the command line
+
+- Changes for building cleanly on OS/2
+
+- Changes to handle building XCurses under AIX
+
+- Check if prefresh() and pnoutrefresh() parameters are valid.
+
+- Ensure build/install works from any directory
+
+- Handle platforms where X11 headers do not typedef XPointer.
+
+- Mention that Flexos is likely out-of-date.
+
+- Pass delaytenths to XCurses_rawgetch()
+
+- Remove boldFont
+
+- Updates for cursor blinking and italic.
+
+BUGS FIXED:
+
+- Fix bug with getting Win32 clipboard contents. Added new
+ PDC_freeclipboard() function.
+
+- Fix bug with halfdelay()
+
+- Fix bug with mouse interrupting programs that are not trapping mouse
+ events under Win32.
+
+- Fix return value from curs_set()
+
+- Reverse the left and right pointing bars in ALT_CHARSET
+
+NEW COMPILER SUPPORT:
+
+- Add QNX-RTP port
+
+------------------------------------------------------------------------
+
+PDCurses 2.4 - 2000/01/17
+=========================
+
+INTRODUCTION:
+
+ This release of PDCurses includes the following changes:
+
+- full support of X11 selection handling
+
+- removed the need for the cursos2.h file
+
+- enabled the "shifted" key on the numeric keypad
+
+- added native clipboard support for X11, Win32 and OS/2
+
+- added extra functions for obtaining internal PDCurses status
+
+- added clipboard and key modifier tests in testcurs.c
+
+- fixes for panel library
+
+- key modifiers pressed by themselves are now returned as keys:
+ KEY_SHIFT_L KEY_SHIFT_R KEY_CONTROL_L KEY_CONTROL_R KEY_ALT_L KEY_ALT_R
+ This works on Win32 and X11 ports only
+
+- Added X11 shared library support
+
+- Added extra slk formats supported by ncurses
+
+- Fixed bug with resizing the terminal when slk were on.
+
+- Changed behavior of slk_attrset(), slk_attron() slk_attroff()
+ functions to work more like ncurses.
+
+BUGS FIXED:
+
+- some minor bug and portability fixes were included in this release
+
+NEW FUNCTIONS:
+
+- PDC_getclipboard() and PDC_setclipboard() for accessing the native
+ clipboard (X11, Win32 and OS/2)
+
+- PDC_set_title() for setting the title of the window (X11 and Win32
+ only)
+
+- PDC_get_input_fd() for getting the file handle of the PDCurses input
+
+- PDC_get_key_modifiers() for getting the keyboard modifier settings at
+ the time of the last (w)getch()
+
+- Xinitscr() (only for X11 port) which allows standard X11 switches to
+ be passed to the application
+
+NEW COMPILER SUPPORT:
+
+- MingW32 GNU compiler under Win95/NT
+
+- Cygnus Win32 GNU compiler under Win95/NT
+
+- Borland C++ for OS/2 1.0+
+
+- lcc-win32 compiler under Win95/NT
+
+ACKNOWLEDGEMENTS: (for this release)
+
+ Georg Fuchs for various changes.
+ Juan David Palomar for pointing out getnstr() was not implemented.
+ William McBrine for fix to allow black/black as valid color pair.
+ Peter Preus for pointing out the missing bccos2.mak file.
+ Laura Michaels for a couple of bug fixes and changes required to
+ support Mingw32 compiler.
+ Frank Heckenbach for PDC_get_input_fd() and some portability fixes and
+ the fixes for panel library.
+ Matthias Burian for the lcc-win32 compiler support.
+
+------------------------------------------------------------------------
+
+PDCurses 2.3 - 1998/07/09
+=========================
+
+INTRODUCTION:
+
+ This release of PDCurses includes the following changes:
+
+- added more System V R4 functions
+
+- added Win32 port
+
+- the X11 port is now fully functional
+
+- the MS Visual C++ Win32 port now includes a DLL
+
+- both the X11 and Win32 ports support the mouse
+
+- the slk..() functions are now functional
+
+- support for scrollbars under X11 are experimental at this stage
+
+- long chtype extended to non-Unix ports
+
+ The name of the statically built library is pdcurses.lib (or
+ pdcurses.a). The name of the DLL import library (where applicable) is
+ curses.lib.
+
+BUGS FIXED:
+
+- some minor bugs were corrected in this release
+
+NEW FUNCTIONS:
+
+- slk..() functions
+
+NEW COMPILER SUPPORT:
+
+- MS Visual C++ under Win95/NT
+
+- Watcom C++ under OS/2, Win32 and DOS
+
+- two EMX ports have been provided:
+ - OS/2 only using OS/2 APIs
+ - OS/2 and DOS using EMX video support routines
+
+EXTRA OPTIONS:
+
+ PDCurses recognizes two environment variables which determines the
+ initialization and finalization behavior. These environment variables
+ do not apply to the X11 port.
+
+ PDC_PRESERVE_SCREEN
+ If this environment variable is set, PDCurses will not clear the screen
+ to the default white on black on startup. This allows you to overlay
+ a window over the top of the existing screen background.
+
+ PDC_RESTORE_SCREEN
+ If this environment variable is set, PDCurses will take a copy of the
+ contents of the screen at the time that PDCurses is started; initscr(),
+ and when endwin() is called, the screen will be restored.
+
+
+ACKNOWLEDGEMENTS: (for this release)
+
+ Chris Szurgot for original Win32 port.
+ Gurusamy Sarathy for some updates to the Win32 port.
+ Kim Huron for the slk..() functions.
+ Florian Grosse Coosmann for some bug fixes.
+ Esa Peuha for reducing compiler warnings.
+ Augustin Martin Domingo for patches to X11 port to enable accented
+ characters.
+
+------------------------------------------------------------------------
+
+PDCurses 2.2 - 1995/02/12
+=========================
+
+INTRODUCTION:
+
+ This release of PDCurses has includes a number of major changes:
+
+- The portable library functions are now grouped together into single
+ files with the same arrangement as System V R4 curses.
+
+- A panels library has been included. This panels library was written by
+ Warren Tucker.
+
+- Quite a few more functions have been supplied by Wade Schauer and
+ incorporated into release 2.2. Wade also supplied the support for the
+ Microway NDP C/C++ 32 bit DOS compiler.
+
+- The curses datatype has been changed from an unsigned int to a long.
+ This allows more attributes to be stored as well as increasing the
+ number of color-pairs from 32 to 64.
+
+- Xwindows port (experimental at the moment).
+
+BUGS FIXED:
+
+- mvwin() checked the wrong coordinates
+
+- removed DESQview shadow memory buffer checking bug in curses.h in
+ #define for wstandout()
+
+- lots of others I can't remember
+
+NEW FUNCTIONS:
+
+- Too many to mention. See intro.man for a complete list of the
+ functions PDCurses now supports.
+
+COMPILER SUPPORT:
+
+- DJGPP 1.12 is now supported. The run-time error that caused programs
+ to crash has been removed.
+
+- emx 0.9a is supported. A program compiled for OS/2 should also work
+ under DOS if you use the VID=EMX switch when compiling. See the
+ makefile for details.
+
+- The Microway NDP C/C++ DOS compiler is now supported. Thanks to Wade
+ Schauer for this port.
+
+- The Watcom C++ 10.0 DOS compiler is now supported. Thanks to Pieter
+ Kunst for this port.
+
+- The library now has many functions grouped together to reduce the size
+ of the library and to improve the speed of compilation.
+
+- The "names" of a couple of the compilers in the makefile has changed;
+ CSET2 is now ICC and GO32 is now GCC.
+
+EXTRA OPTIONS:
+
+ One difference between the behavior of PDCurses and Unix curses is the
+ attributes that are displayed when a character is cleared. Under Unix
+ curses, no attributes are displayed, so the result is always black.
+ Under PDCurses, these functions clear with the current attributes in
+ effect at the time. With the introduction of the bkgd functions, by
+ default, PDCurses clears using the value set by (w)bkgd(). To have
+ PDCurses behave the same way as it did before release 2.2, compile with
+ -DPDCURSES_WCLR
+
+ACKNOWLEDGEMENTS: (for this release)
+
+ Pieter Kunst, David Nugent, Warren Tucker, Darin Haugen, Stefan Strack,
+ Wade Schauer and others who either alerted me to bugs or supplied
+ fixes.
+
+------------------------------------------------------------------------
+
+PDCurses 2.1 - 1993/06/20
+=========================
+
+INTRODUCTION:
+
+ The current code contains bug fixes for the DOS and OS/2 releases and
+ also includes an alpha release for Unix. The Unix release uses another
+ public domain package (mytinfo) to handle the low-level screen writes.
+ mytinfo was posted to comp.sources.unix (or misc) in December 1992 or
+ January 1993. Unless you are a glutton for punishment I would recommend
+ you avoid the Unix port at this stage.
+
+ The other major addition to PDCurses is the support for DJGPP (the DOS
+ port of GNU C++). Thanks to David Nugent <davidn@csource.oz.au>.
+
+ Other additions are copywin() function, function debugging support and
+ getting the small and medium memory models to work. The testcurs.c demo
+ program has also been changed significantly and a new demo program,
+ tuidemo, has been added.
+
+ Some people have suggested including information on where to get dmake
+ from. oak.oakland.edu in /pub/msdos/c
+
+OTHER NOTES:
+
+ Under DOS, by default, screen writes to a CGA monitor are done via the
+ video BIOS rather than by direct video memory writes. This is due to
+ the CGA "snow" problem. If you have a CGA monitor and do not suffer
+ from snow, you can compile private\_queryad.c with CGA_DIRECT defined.
+ This will then use cause PDCurses to write directly to the CGA video
+ memory.
+
+ Function debugging: Firstly to get function debugging, you have to
+ compile the library with OPT=N in the makefile. This also turns on
+ compiler debugging. You can control when you want PDCurses to write to
+ the debug file (called trace in the current directory) by using the
+ functions traceon() and traceoff() in your program.
+
+ Microsoft C 6.00 Users note:
+ ----------------------------
+
+ With the addition of several new functions, using dmake to compile
+ PDCurses now causes the compiler to run "out of heap space in pass 2".
+ Using the 6.00AX version (DOS-Extended) to compile PDCurses fixes this
+ problem; hence the -EM switch.
+
+ Functional changes
+ ------------------
+
+ Added OS/2 DLL support.
+
+ A few curses functions have been fixed to exhibit their correct
+ behavior and make them more functionally portable with System V
+ curses. The functions that have changed are overlay(), overwrite() and
+ typeahead.
+
+ overlay() and overwrite()
+
+ Both of theses functions in PDCurses 2.0 allowed for one window to be
+ effectively placed on top of another, and the characters in the first
+ window were overlaid or overwritten starting at 0,0 in both windows.
+ This behavior of these functions was not correct. These functions only
+ operate on windows that physically overlap with respect to the
+ displayed screen. To achieve the same functionality as before, use the
+ new function copywin(). See the manual page for further details.
+
+ typeahead()
+
+ This function in PDCurses 2.0 effectively checked to see if there were
+ any characters remaining in the keyboard buffer. This is not the
+ behavior exhibited by System V curses. This function is intended
+ purely to set a flag so that curses can check while updating the
+ physical screen if any keyboard input is pending. To achieve the same
+ effect with typeahead() under PDCurses 2.1 the following code should be
+ used.
+
+ In place of...
+
+ while(!typeahead(stdin))
+ {
+ /* do something until any key is pressed... */
+ }
+
+ use...
+
+ /* getch() to return ERR if no key pending */
+ nodelay(stdscr,TRUE);
+ while(getch() == (ERR))
+ {
+ /* do something until any key is pressed... */
+ }
+
+
+ACKNOWLEDGEMENTS: (in no particular order)
+
+ Jason Shumate, Pieter Kunst, David Nugent, Andreas Otte, Pasi
+ Hamalainen, James McLennan, Duane Paulson, Ib Hojme
+
+ Apologies to anyone I may have left out.
+
+------------------------------------------------------------------------
+
+PDCurses 2.0 - 1992/11/23
+=========================
+
+INTRODUCTION:
+
+ Well, here it finally is; PDCurses v2.0.
+
+ PDCurses v2.0 is an almost total rewrite of PCcurses 1.4 done by John
+ 'Frotz' Fa'atuai, the previous maintainer. It adds support for OS/2 as
+ well as DOS.
+
+ This version has been tested with Microsoft C v6.0, QuickC v2.0 and
+ Borland C++ 2.0 under DOS and Microsoft C v6.0 and TopSpeed c v3.02
+ under OS/2 2.0. Also the library has been compiled successfully with
+ emx 0.8e, C Set/2 and Watcom 9. Most testing was done with the large
+ memory model, where applicable. The large memory model is probably the
+ best model to use.
+
+ The amount of testing has not been as extensive as I would have liked,
+ but demands on releasing a product have outweighed the product's
+ quality. Nothing new with that !! Hopefully with wider circulation,
+ more bugs will be fixed more quickly.
+
+ I have included just 1 makefile which is suitable for dmake 3.8 for
+ both DOS and OS/2. The makefile does not rely on customization of the
+ dmake.ini file.
+
+ If you discover bugs, and especially if you have fixes, please let me
+ know ASAP.
+
+ The source to the library is distributed as a zip file made with zip
+ 1.9. You will need Info-ZIP unzip 5.0 to unzip. Follow the directions
+ below to compile the library.
+
+DIRECTIONS:
+
+ 1. Create a new directory in which to unzip pdcurs20.zip. This will
+ create a curses directory and a number of subdirectories containing
+ source code for the library and utilities and the documentation.
+
+ 2. Make changes to the makefile where necessary:
+ Change the MODEL or model macro to the appropriate value (if it
+ applies to your compiler). Use model for Borland compilers.
+
+ Change any paths in the defined macros to be suitable for your
+ compiler.
+
+ 3. Invoke DMAKE [-e environment_options] [target]
+
+ where environment_options are:
+
+ OS (host operating system)
+ COMP (compiler)
+ OPT (optimized version or debug version) - optional. default Y
+ TOS (target operating system) - optional. default OS
+
+ see the makefile for valid combinations
+
+ targets: all, demos, lcursesd.lib, manual...
+
+ NB. dmake is case sensitive with targets, so those environments that
+ use an upper case model value (eg MSC) MUST specify the library
+ target as for eg. Lcursesd.lib
+
+ The makefile is by default set up for Borland C++. The use of -e
+ environment_options override these defaults. If you prefer, you can
+ just change the defaults in the makefile and invoke it without the
+ -e switch.
+
+OTHER NOTES:
+
+ The documentation for the library is built into each source file, a
+ couple of specific doc files and the header files. A program is
+ supplied (manext) to build the manual. This program gets compiled when
+ you build the documentation.
+
+ To generate the library response file correctly, I had to write a quick
+ and dirty program (buildlrf) to achieve this. Originally the makefiles
+ just had statements like: "echo -+$(OBJ)\$* & >> $(LRF)" which appended
+ a suitable line to the response file. Unfortunately under some
+ combinations of makefiles and command processors (eg. nmake and 4DOS)
+ the & would get treated as stderr and the echo command would fail.
+
+ The original source for PDCurses that I received from the previous
+ maintainer contained support for the FLEXOS operating system. Not
+ having access to it, I could not test the changes I made so its support
+ has fallen by the wayside. If you really need to have PDCurses running
+ under FLEXOS, contact me and I will see what can be arranged.
+
+ Under DOS, by default, screen writes to a CGA monitor are done via the
+ video BIOS rather than by direct video memory writes. This is due to
+ the CGA "snow" problem. If you have a CGA monitor and do not suffer
+ from snow, you can compile private\_queryad.c with CGA_DIRECT defined.
+ This will then use cause PDCurses to write directly to the CGA video
+ memory.
+
+ Added System V color support.
+
+COMPILER-SPECIFIC NOTES:
+
+ Microsoft C
+ -----------
+
+ It is possible with MSC 6.0 to build the OS/2 libraries and demo
+ programs from within DOS. This is the only case where it is possible to
+ specify the value of TOS on the command line to be OS2 and the value of
+ OS be DOS.
+
+ C Set/2
+ -------
+
+ I have only tested the library using the migration libraries. I doubt
+ that the demo programs will work without them.
+
+ emx
+ ---
+
+ Testing has been done with 0.8e of emx together with the 16_to_32
+ libraries. The emx\lib directory should include the vio32.lib and
+ kbd32.lib libraries from the 16_to_32 package.
+
+BUGS and UNFINISHED BUSINESS:
+
+- PDC_set_ctrl_break() function does not work under OS/2.
+
+- win_print() and PDC_print() do not work under OS/2.
+
+- The file todo.man in the doc directory also lists those functions of
+ System V 3.2 curses not yet implemented. Any volunteers?
+
+ACKNOWLEDGEMENTS:
+
+ John 'Frotz' Fa'atuai, the previous maintainer for providing an
+ excellent base for further development.
+ John Burnell <johnb@kea.am.dsir.govt.nz>, for the OS/2 port.
+ John Steele, Jason (finally NOT a John) Shumate....
+ for various fixes and suggestions.
+ Eberhardt Mattes (author of emx) for allowing code based on his
+ C library to be included with PDCurses.
+ Several others for their support, moral and actual.
+
+-- Mark Hessling
+
+------------------------------------------------------------------------
+
+PDCurses 2.0Beta - 1991/12/21
+=============================
+
+Changed back from short to int. (int is the correct size for the default
+platform. Short might be too short on some platforms. This is more
+portable. I, also, made this mistake.)
+
+Many functions are now macros. If you want the real thing, #undef the
+macro. (X/Open requirement.)
+
+Merged many sources into current release.
+
+Added many X/Open routines (not quite all yet).
+
+Added internal documentation to all routines.
+
+Added a HISTORY file to the environment.
+
+Added a CONTRIB file to the environment.
+
+------------------------------------------------------------------------
+
+PDCurses 1.5Beta - 1990/07/14
+=============================
+
+Added many levels of compiler support. Added mixed prototypes for all
+"internal" routines. Removed all assembly language. Added EGA/VGA
+support. Converted all #ifdef to #if in all modules except CURSES.H and
+CURSPRIV.H. Always include ASSERT.H. Added support for an external
+malloc(), calloc() and free(). Added support for FAST_VIDEO
+(direct-memory writes). Added various memory model support (for
+FAST_VIDEO). Added much of the December 1988 X/Open Curses
+specification.
+
+-- John 'Frotz' Fa'atuai
+
+------------------------------------------------------------------------
+
+PCcurses 1.4 - 1990/01/14
+=========================
+
+ In PCcurses v.1.4, both portability improvements and bugfixes have
+been made. The files have been changed to allow lint-free compilation
+with Microsoft C v.5.1, and with Turbo C v.2.0. The source should still
+compile without problems on older compilers, although this has not been
+verified.
+
+ The makefiles have been changed to suit both the public release and
+the author, who maintains a special kind of libraries for himself. In
+the case of Microsoft C, changes were done in the makefile to lower the
+warning level to 2 (was 3). This was to avoid ANSI warnings which are
+abundant because PCcurses does not attempt to follow strict ANSI C
+standard.
+
+ BUG FIXES FROM V.1.3 TO V.1.4:
+
+ !!!IMPORTANT CHANGE!!!
+
+ The definitions for OK and ERR in curses.h were exchanged. This was
+done to be more consistent with UNIX versions. Also, it permits
+functions like newwin() and subwin() to return 0 (=NULL) when they fail
+due to memory shortage. This incompatibility with UNIX curses was
+pointed out by Fred C. Smith. If you have tested success/failure by
+comparisons to anything other than ERR and OK, your applications will
+need to be be changed on that point. Sorry... but presumably most of you
+used the symbolic constants?
+
+ (END OF IMPORTANT CHANGE)
+
+ Fred also pointed out a bug in the file update.c. The bug caused the
+first character printed after 'unauthorized' screen changes (like during
+a shell escape, for example) to be placed at the wrong screen position.
+This happened even if the normal precautions (clear / touch / refresh)
+were taken. The problem has now been fixed.
+
+ PCcurses is currently also being used on a 68000 system with
+hard-coded ESCape sequences for ANSI terminals. However, ints used by
+the 68000 C compiler are 32 bits. Therefore ints have been turned into
+shorts wherever possible in the code (otherwise all window structures
+occupy twice as much space as required on the 68000). This does not
+affect PC versions since normally both ints and shorts are 16 bits for
+PC C compilers.
+
+ At some places in the source code there are references made to the
+68000 version. There are also a makefile, a curses68.c file, and a
+curses68.cmd file. These are for making, low-level I/O, and linking
+commands when building the 68000 version. These files are probably
+useful to no-one but the author, since it is very specific for its
+special hardware environment. Still in an effort to keep all
+curses-related sources in one place they are included. Note however that
+PCcurses will not officially support a non-PC environment.
+
+ The file cursesio.c, which was included in the package at revision
+level 1.2, and which was to be an alternative to the cursesio.asm file,
+has been verified to behave incorrectly in the function _curseskeytst().
+The problem was that the value of 'cflag' does not contain the proper
+data for the test that is attempted. Furthermore, neither Turbo C or
+Microsoft C allows any way to return the data that is needed, and
+consequently you should not use cursesio.c. The best solution is to
+simply use the ASM version. In v.1.2 and v.1.3, the user could edit the
+makefile to select which version he wanted to use. The makefiles in
+v.1.4 have removed this possibility forcing the use of the ASM file, and
+cursesio.c has been dropped from the distribution.
+
+ A bug in the wgetstr() function caused PCcurses to echo characters
+when reading a keyboard string, even if the echo had been turned off.
+Thanks to Per Foreby at Lund University, Sweden, for this. Per also
+reported bugs concerning the handling of characters with bit 8 set.
+Their ASCII code were considered as lower than 32, so they were erased
+etc. like control characters, i.e. erasing two character positions. The
+control character test was changed to cope with this.
+
+ The overlay() and overwrite() functions were changed so that the
+overlaying window is positioned at its 'own' coordinates inside the
+underlying window (it used to be at the underlying window's [0,0]
+position). There is some controversy about this - the documentation for
+different curses versions say different things. I think the choice made
+is the most reasonable.
+
+ The border() and wborder() functions were changed to actually draw a
+border, since this seems to be the correct behavior of these functions.
+They used to just set the border characters to be used by box(). These
+functions are not present in standard BSD UNIX curses.
+
+ The subwin() function previously did not allow the subwindow to be as
+big as the original window in which it was created. This has now been
+fixed. There was also the problem that the default size (set by
+specifying numlines or numcols (or both) as 0 made the resulting actual
+size 1 line/column too small.
+
+ There were a few spelling errors in function names, both in the
+function declarations and in curses.h. This was reported by Carlos
+Amaral at INESC in Portugal. Thanks! There was also an unnecessary (but
+harmless) parameter in a function call at one place.
+
+------------------------------------------------------------------------
+
+PCcurses 1.3 - 1988/10/05
+=========================
+
+ The file 'border.c' is now included. It allows you to explicitly
+specify what characters should be used as box borders when the box()
+functions are called. If the new border characters are non-0, they
+override the border characters specified in the box() call. In my
+understanding, this functionality is required for AT&T UNIX sV.3
+compatibility. Thanks for this goes to Tony L. Hansen
+(hansen@pegasus.UUCP) for posting an article about it on Usenet
+(newsgroup comp.unix.questions; his posting was not related at all to
+PCcurses).
+
+ The only other difference between v.1.2 and v.1.3 is that the latter
+has been changed to avoid warning diagnostics if the source files are
+compiled with warning switches on (for Microsoft this means '-W3', for
+Turbo C it means '-w -w-pro'). Of these, the Turbo C warning check is
+clearly to be used rather than Microsoft, even if neither of them comes
+even close to a real UNIX 'lint'. Some of the warnings in fact indicated
+real bugs, mostly functions that did not return correct return values or
+types.
+
+ The makefiles for both MSC and TRC have been modified to produce
+warning messages as part of normal compilation.
+
+------------------------------------------------------------------------
+
+PCcurses 1.2 - 1988/10/02
+=========================
+
+ The changes from v.1.1 to v.1.2 are minor. The biggest change is that
+there was a bug related to limiting the cursor movement if the
+application tried to move it outside the screen (something that should
+not be done anyway). Such erroneous application behavior is now handled
+appropriately.
+
+ All modules have been changed to have a revision string in them, which
+makes it easier to determine what version is linked into a program (or
+what library version you have).
+
+ There is now a 'cursesio.c' file. That file does the same as
+'cursesio.asm' (i.e. it provides the interface to the lower-level system
+I/O routines). It is written in C and thus it is (possibly) more
+portable than the assembler version (but still not so portable since it
+uses 8086 INT XX calls directly). When one creates new curses libraries,
+one chooses whether to use the assembler or the C version of cursesio.
+The choice is made by commenting out the appropriate dependencies for
+cursesio.obj, near the end of the makefiles.
+
+ There is now a 'setmode.c' file. That file contains functions that
+save and restore terminal modes. They do it into other variables than do
+savetty() and resetty(), so one should probably use either
+savetty()/resetty() or the new functions only - and not mix the both
+ways unless one really knows what one does.
+
+ Diff lists vs v.1.0 are no longer included in the distribution. The
+make utility still is. PCcurses v.1.2 still compiles with Microsoft C
+v.4.0, and with Borland Turbo C v.1.0. There is as far as I know no
+reason to believe that it does not compile under Microsoft C v.3.0 and
+5.x, or Turbo C v.1.5, but this has not been tested.
+
+ There are two makefiles included, one for Microsoft C, one for Turbo
+C. They are both copies of my personal makefiles, and as such they
+reflect the directory structure on my own computer. This will have to be
+changed before you run make. Check $(INCDIR) and $(LIBDIR) in
+particular, and make the choice of ASM or C cursesio version as
+mentioned above (the distribution version uses the C version of
+cursesio).
+
+ The manual file (curses.man) has been changed at appropriate places.
+
+ I would like to thank the following persons for their help:
+
+ Brandon S. Allbery (alberry@ncoast.UUCP)
+ for running comp.binaries.ibm.pc (at that time)
+ and comp.source.misc.
+
+ Steve Balogh (Steve@cit5.cit.oz.AU)
+ for writing a set of manual pages and posting
+ them to the net.
+
+ Torbjorn Lindh
+ for finding bugs and suggesting raw
+ character output routines.
+
+ Nathan Glasser (nathan@eddie.mit.edu)
+ for finding and reporting bugs.
+
+ Ingvar Olafsson (...enea!hafro!ingvar)
+ for finding and reporting bugs.
+
+ Eric Rosco (...enea!ipmoea!ericr)
+ for finding and reporting bugs.
+
+ Steve Creps (creps@silver.bacs.indiana.edu)
+ for doing a lot of work - among others
+ posting bug fixes to the net, and writing
+ the new cursesio.c module.
+
+ N. Dean Pentcheff (dean@violet.berkeley.edu)
+ for finding bugs and rewriting cursesio.asm
+ for Turbo 'C' 1.5.
+
+ Finally, Jeff Dean (parcvax,hplabs}!cdp!jeff)
+ (jeff@ads.arpa)
+ has had a shareware version of curses deliverable since
+ about half a year before I released PCcurses 1.0 on Use-
+ Net. He is very concerned about confusion between the two
+ packages, and therefore any references on the network
+ should make clear whether they reference Dean's PCcurses
+ or Larsson's PCcurses.
+
+------------------------------------------------------------------------
+
+PCcurses 1.1 - 1988/03/06
+=========================
+
+ The changes from v.1.0 to v.1.1 are minor. There are a few bug fixes,
+and new (non-portable) functions for verbatim IBM character font display
+have been added (in charadd.c and charins.c). The manual file
+(curses.man) has been changed at appropriate places.
+
+ In the file v10tov11.dif there are listings of the differences between
+version 1.0 and 1.1. The diff listings are in UNIX diff(1) format.
+
+ Version 1.1 compiles with Turbo C v.1.0, as well as Microsoft C v.3.0
+and v.4.0. On the release disk there is a make.exe utility which is very
+similar to UNIX make (If the package was mailed to you, the make utility
+will be in uuencoded format - in make.uu - and must be uudecoded first).
+It is much more powerful than Microsoft's different MAKEs; the latter
+ones will NOT generate libraries properly if used with the PCcurses
+makefiles.
+
+ There are three makefiles:
+
+ makefile generic MSC 3.0 makefile
+ makefile.ms MSC 4.0 makefile
+ makefile.tc Turbo C 1.0 makefile
+
+ To make a library with for example Turbo C, make directories to hold
+.H and .LIB files (these directories are the 'standard places'), edit
+makefile.tc for this, and type
+
+ make -f makefile.tc all
+
+and libraries for all memory models will be created in the .LIB
+directory, while the include files will end up in the .H directory. Also
+read what is said about installation below!
+
+------------------------------------------------------------------------
+
+PCcurses 1.0 - 1987/08/24
+=========================
+
+ This is the release notes for the PCcurses v.1.0 cursor/window control
+package. PCcurses offers the functionality of UNIX curses, plus some
+extras. Normally it should be possible to port curses-based programs
+from UNIX curses to PCcurses on the IBM PC without changes. PCcurses is
+a port/ rewrite of Pavel Curtis' public domain 'ncurses' package. All
+the code has been re-written - it is not just an edit of ncurses (or
+UNIX curses). I mention this to clarify any copyright violation claims.
+The data structures and ideas are very similar to ncurses. As for UNIX
+curses, I have not even seen any sources for it.
+
+ For an introduction to the use of 'curses' and its derivatives, you
+should read 'Screen Updating and Cursor Movement Optimization: A Library
+Package' by Kenneth C. R. C. Arnold, which describes the original
+Berkeley UNIX version of curses. It is available as part of the UNIX
+manuals. The other source of information is 'The Ncurses Reference
+Manual' by Pavel Curtis. The latter is part of Curtis' ncurses package.
+
+ The only other documentation provided is a 'man' page which describes
+all the included functions in a very terse way. In the sources, each
+function is preceded by a rather thorough description of what the
+function does. I didn't have time to write a nice manual/tutorial -
+sorry.
+
+ PCcurses is released as a number of source files, a man page, and a
+make file. A uuencoded copy of a 'make' utility, and a manpage for the
+'make' is also provided to make it easier to put together PCcurses
+libraries. Even if you are not interested in PCcurses, it may be
+worthwhile to grab the make.
+
+ The makefile assumes the presence of the Microsoft C compiler (3.0 or
+4.0), Microsoft MASM and LIB, plus some MS-DOS utilities. The reason for
+supplying MAKE.EXE is that the Microsoft 'MAKE:s' are much inferior to a
+real UNIX make. The supplied make is a port of a public domain make,
+published on Usenet. It is almost completely compatible with UNIX make.
+When generating the curses libraries, the makefile will direct make to
+do some directory creating and file copying, and then re-invoke itself
+with new targets. The workings of the makefile are not absolutely
+crystal clear at first sight... just start it and see what it does.
+
+ For portability, the curses libraries depend on one assembler file for
+access to the BIOS routines. There is no support for the EGA, but both
+CGA, MGA, and the HGA can be used. The libraries are originally for
+Microsoft C, but all C modules should be portable right away. In the
+assembler file, segment names probably need to be changed, and possibly
+the parameter passing scheme. I think Turbo C will work right away - as
+far as I understand, all its conventions are compatible with Microsoft
+C.
+
+ There are some parts left out between ncurses and PCcurses. One is the
+support for multiple terminals - not very interesting on a PC anyway.
+Because we KNOW what terminal we have, there is no need for a termcap or
+terminfo library. PCcurses also has some things that neither curses nor
+ncurses have. Compared to the original UNIX curses, PCcurses has lots of
+extras.
+
+ The BIOS routines are used directly, which gives fast screen updates.
+PCcurses does not do direct writes to screen RAM - in my opinion it is
+a bit ugly to rely that much on hardware compatibility. Anyone could fix
+that, of course...
+
+ One of the more serious problems with PCcurses is the way in which
+normal, cbreak, and raw input modes are done. All those details are in
+the 'charget' module - I do raw I/O via the BIOS, and perform any
+buffering myself. If an application program uses PCcurses, it should do
+ALL its I/O via PCcurses calls, otherwise the mix of normal and
+PCcurses I/O may mess up the display. I think my code is reasonable...
+comments are welcome, provided you express them nicely...
+
+ To install, copy all files to a work directory, edit 'makefile' to
+define the standard include and library file directory names of your
+choice (these directories must exist already, and their path names must
+be relative to the root directory, not to the current one). You must
+also run uudecode on make.uu, to generate MAKE.EXE. You can do that on
+your PC, if you have uudecode there, otherwise you can do it under UNIX
+and do a binary transfer to the PC. When you have MAKE.EXE in your work
+directory (or in your /bin directory), type make.
+
+ Make will now create 4 sub-directories (one for each memory model),
+copy some assembler include files into them, copy two include files to
+your include directory, CHDIR to each sub-directory and re-invoke itself
+with other make targets to compile and assemble all the source files
+into the appropriate directories. Then the library manager is run to
+create the library files in your desired library directory. Presto!
+
+ If you only want to generate a library for one memory model, type
+'make small', 'make large', etc. The name of the memory model must be in
+lower case, like in the makefile.
+
+ I think the package is fairly well debugged - but then again, that's
+what I always think. It was completed in May-87, and no problems found
+yet. Now it's your turn... Comments, suggestions and bug reports and
+fixes (no flames please) to
+
+-- Bjorn Larsson
diff --git a/payloads/libpayload/curses/PDCurses-3.4/IMPLEMNT b/payloads/libpayload/curses/PDCurses-3.4/IMPLEMNT
new file mode 100644
index 0000000000..0445f8bbe1
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/IMPLEMNT
@@ -0,0 +1,325 @@
+PDCurses Implementor's Guide
+============================
+
+Version 1.3 - 200?/??/?? - notes about official ports
+Version 1.2 - 2007/07/11 - added PDC_init_pair(), PDC_pair_content(),
+ version history; removed pdc_atrtab
+Version 1.1 - 2007/06/06 - minor cosmetic change
+Version 1.0 - 2007/04/01 - initial revision
+
+This document is for those wishing to port PDCurses to a new platform,
+or just wanting to better understand how it works. Nothing here should
+be needed for application programming; for that, refer to PDCurses.txt,
+as built in doc/, or distributed as a file separate from this source
+package. This document assumes that you've read the user-level
+documentation and are very familiar with application-level curses
+programming.
+
+If you want to submit your port for possible inclusion into the main
+PDCurses distribution, please follow these guidelines:
+
+ - Don't modify anything in the pdcurses directory or in other port
+ directories. Don't modify curses.h or curspriv.h unless absolutely
+ necessary. (And prefer modifying curspriv.h over curses.h.)
+
+ - Use the same indentation style, naming and scope conventions as the
+ existing code.
+
+ - Release all your code to the public domain -- no copyright. Code
+ under GPL, BSD, etc. will not be accepted.
+
+
+DATA STRUCTURES
+---------------
+
+A port of PDCurses must provide acs_map[], a 128-element array of
+chtypes, with values laid out based on the Alternate Character Set of
+the VT100 (see curses.h). PDC_transform_line() must use this table; when
+it encounters a chtype with the A_ALTCHARSET flag set, and an A_CHARTEXT
+value in the range 0-127, it must render it using the A_CHARTEXT portion
+of the corresponding value from this table, instead of the original
+value. Also, values may be read from this table by apps, and passed
+through functions such as waddch(), which does no special processing on
+control characters (0-31 and 127) when the A_ALTCHARSET flag is set.
+Thus, any control characters used in acs_map[] should also have the
+A_ALTCHARSET flag set. Implementations should provide suitable values
+for all the ACS_ macros defined in curses.h; other values in the table
+should be filled with their own indices (e.g., acs_map['E'] == 'E'). The
+table can be either hardwired, or filled by PDC_scr_open(). Existing
+ports define it in pdcdisp.c, but this is not required.
+
+
+FUNCTIONS
+---------
+
+A port of PDCurses must implement the following functions, with extern
+scope. These functions are traditionally divided into several modules,
+as indicated below; this division is not required (only the functions
+are), but may make it easier to follow for someone familiar with the
+existing ports.
+
+Any other functions you create as part of your implementation should
+have static scope, if possible. If they can't be static, they should be
+named with the "PDC_" prefix. This minimizes the risk of collision with
+an application's choices.
+
+Current PDCurses style also uses a single leading underscore with the
+name of any static function; and modified BSD/Allman-style indentation,
+approximately equivalent to "indent -kr -i8 -bl -bli0", with adjustments
+to keep every line under 80 columns. This isn't essential, but a
+consistent style helps readability.
+
+
+pdcdisp.c:
+----------
+
+void PDC_gotoyx(int y, int x);
+
+Move the physical cursor (as opposed to the logical cursor affected by
+wmove()) to the given location. This is called mainly from doupdate().
+In general, this function need not compare the old location with the new
+one, and should just move the cursor unconditionally.
+
+void PDC_transform_line(int lineno, int x, int len, const chtype *srcp);
+
+The core output routine. It takes len chtype entities from srcp (a
+pointer into curscr) and renders them to the physical screen at line
+lineno, column x. It must also translate characters 0-127 via acs_map[],
+if they're flagged with A_ALTCHARSET in the attribute portion of the
+chtype.
+
+
+pdcgetsc.c:
+-----------
+
+int PDC_get_columns(void);
+
+Returns the size of the screen in columns. It's used in resize_term() to
+set the new value of COLS. (Some existing implementations also call it
+internally from PDC_scr_open(), but this is not required.)
+
+int PDC_get_cursor_mode(void);
+
+Returns the size/shape of the cursor. The format of the result is
+unspecified, except that it must be returned as an int. This function is
+called from initscr(), and the result is stored in SP->orig_cursor,
+which is used by PDC_curs_set() to determine the size/shape of the
+cursor in normal visibility mode (curs_set(1)).
+
+int PDC_get_rows(void);
+
+Returns the size of the screen in rows. It's used in resize_term() to
+set the new value of LINES. (Some existing implementations also call it
+internally from PDC_scr_open(), but this is not required.)
+
+
+pdckbd.c:
+---------
+
+bool PDC_check_key(void);
+
+Keyboard/mouse event check, called from wgetch(). Returns TRUE if
+there's an event ready to process. This function must be non-blocking.
+
+void PDC_flushinp(void);
+
+This is the core of flushinp(). It discards any pending key or mouse
+events, removing them from any internal queue and from the OS queue, if
+applicable.
+
+int PDC_get_key(void);
+
+Get the next available key, or mouse event (indicated by a return of
+KEY_MOUSE), and remove it from the OS' input queue, if applicable. This
+function is called from wgetch(). This function may be blocking, and
+traditionally is; but it need not be. If a valid key or mouse event
+cannot be returned, for any reason, this function returns -1. Valid keys
+are those that fall within the appropriate character set, or are in the
+list of special keys found in curses.h (KEY_MIN through KEY_MAX). When
+returning a special key code, this routine must also set SP->key_code to
+TRUE; otherwise it must set it to FALSE. If SP->return_key_modifiers is
+TRUE, this function may return modifier keys (shift, control, alt),
+pressed alone, as special key codes; if SP->return_key_modifiers is
+FALSE, it must not. If modifier keys are returned, it should only happen
+if no other keys were pressed in the meantime; i.e., the return should
+happen on key up. But if this is not possible, it may return the
+modifier keys on key down (if and only if SP->return_key_modifiers is
+TRUE).
+
+int PDC_modifiers_set(void);
+
+Called from PDC_return_key_modifiers(). If your platform needs to do
+anything in response to a change in SP->return_key_modifiers, do it
+here. Returns OK or ERR, which is passed on by the caller.
+
+int PDC_mouse_set(void);
+
+Called by mouse_set(), mouse_on(), and mouse_off() -- all the functions
+that modify SP->_trap_mbe. If your platform needs to do anything in
+response to a change in SP->_trap_mbe (for example, turning the mouse
+cursor on or off), do it here. Returns OK or ERR, which is passed on by
+the caller.
+
+void PDC_set_keyboard_binary(bool on);
+
+Set keyboard input to "binary" mode. If you need to do something to keep
+the OS from processing ^C, etc. on your platform, do it here. TRUE turns
+the mode on; FALSE reverts it. This function is called from raw() and
+noraw().
+
+
+pdcscrn.c:
+----------
+
+bool PDC_can_change_color(void);
+
+Returns TRUE if init_color() and color_content() give meaningful
+results, FALSE otherwise. Called from can_change_color().
+
+int PDC_color_content(short color, short *red, short *green, short *blue);
+
+The core of color_content(). This does all the work of that function,
+except checking for values out of range and null pointers.
+
+int PDC_init_color(short color, short red, short green, short blue);
+
+The core of init_color(). This does all the work of that function,
+except checking for values out of range.
+
+void PDC_init_pair(short pair, short fg, short bg);
+
+The core of init_pair(). This does all the work of that function, except
+checking for values out of range. The values passed to this function
+should be returned by a call to PDC_pair_content() with the same pair
+number. PDC_transform_line() should use the specified colors when
+rendering a chtype with the given pair number.
+
+int PDC_pair_content(short pair, short *fg, short *bg);
+
+The core of pair_content(). This does all the work of that function,
+except checking for values out of range and null pointers.
+
+void PDC_reset_prog_mode(void);
+
+The non-portable functionality of reset_prog_mode() is handled here --
+whatever's not done in _restore_mode(). In current ports: In OS/2, this
+sets the keyboard to binary mode; in Win32, it enables or disables the
+mouse pointer to match the saved mode; in others it does nothing.
+
+void PDC_reset_shell_mode(void);
+
+The same thing, for reset_shell_mode(). In OS/2 and Win32, it restores
+the default console mode; in others it does nothing.
+
+int PDC_resize_screen(int nlines, int ncols);
+
+This does the main work of resize_term(). It may respond to non-zero
+parameters, by setting the screen to the specified size; to zero
+parameters, by setting the screen to a size chosen by the user at
+runtime, in an unspecified way (e.g., by dragging the edges of the
+window); or both. It may also do nothing, if there's no appropriate
+action for the platform.
+
+void PDC_restore_screen_mode(int i);
+
+Called from _restore_mode() in kernel.c, this function does the actual
+mode changing, if applicable. Currently used only in DOS and OS/2.
+
+void PDC_save_screen_mode(int i);
+
+Called from _save_mode() in kernel.c, this function saves the actual
+screen mode, if applicable. Currently used only in DOS and OS/2.
+
+void PDC_scr_close(void);
+
+The platform-specific part of endwin(). It may restore the image of the
+original screen saved by PDC_scr_open(), if the PDC_RESTORE_SCREEN
+environment variable is set; either way, if using an existing terminal,
+this function should restore it to the mode it had at startup, and move
+the cursor to the lower left corner. (The X11 port does nothing.)
+
+void PDC_scr_free(void);
+
+Frees the memory for SP allocated by PDC_scr_open(). Called by
+delscreen().
+
+int PDC_scr_open(int argc, char **argv);
+
+The platform-specific part of initscr(). It's actually called from
+Xinitscr(); the arguments, if present, correspond to those used with
+main(), and may be used to set the title of the terminal window, or for
+other, platform-specific purposes. (The arguments are currently used
+only in X11.) PDC_scr_open() must allocate memory for SP, and must
+initialize acs_map[] (unless it's preset) and several members of SP,
+including lines, cols, mouse_wait, orig_attr (and if orig_attr is TRUE,
+orig_fore and orig_back), mono, _restore and _preserve. (Although SP is
+used the same way in all ports, it's allocated here in order to allow
+the X11 port to map it to a block of shared memory.) If using an
+existing terminal, and the environment variable PDC_RESTORE_SCREEN is
+set, this function may also store the existing screen image for later
+restoration by PDC_scr_close().
+
+
+pdcsetsc.c:
+-----------
+
+int PDC_curs_set(int visibility);
+
+Called from curs_set(). Changes the appearance of the cursor -- 0 turns
+it off, 1 is normal (the terminal's default, if applicable, as
+determined by SP->orig_cursor), and 2 is high visibility. The exact
+appearance of these modes is not specified.
+
+
+pdcutil.c:
+----------
+
+void PDC_beep(void);
+
+Emits a short audible beep. If this is not possible on your platform,
+you must set SP->audible to FALSE during initialization (i.e., from
+PDC_scr_open() -- not here); otherwise, set it to TRUE. This function is
+called from beep().
+
+void PDC_napms(int ms);
+
+This is the core delay routine, called by napms(). It pauses for about
+(the X/Open spec says "at least") ms milliseconds, then returns. High
+degrees of accuracy and precision are not expected (though desirable, if
+you can achieve them). More important is that this function gives back
+the process' time slice to the OS, so that PDCurses idles at low CPU
+usage.
+
+const char *PDC_sysname(void);
+
+Returns a short string describing the platform, such as "DOS" or "X11".
+This is used by longname(). It must be no more than 100 characters; it
+should be much, much shorter (existing platforms use no more than 5).
+
+--------------------------------------------------------------------------
+
+The following functions are implemented in the platform directories, but
+are accessed directly by apps. Refer to the user documentation for their
+descriptions:
+
+
+pdcclip.c:
+----------
+
+int PDC_clearclipboard(void);
+int PDC_freeclipboard(char *contents);
+int PDC_getclipboard(char **contents, long *length);
+int PDC_setclipboard(const char *contents, long length);
+
+
+pdckbd.c:
+---------
+
+unsigned long PDC_get_input_fd(void);
+
+
+pdcsetsc.c:
+-----------
+
+int PDC_set_blink(bool blinkon);
+void PDC_set_title(const char *title);
diff --git a/payloads/libpayload/curses/PDCurses-3.4/Makefile.in b/payloads/libpayload/curses/PDCurses-3.4/Makefile.in
new file mode 100644
index 0000000000..dc40abfbf5
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/Makefile.in
@@ -0,0 +1,108 @@
+# Makefile for PDCurses library for X11
+
+SHELL = @SHELL@
+
+@SET_MAKE@
+
+srcdir =@srcdir@
+prefix =@prefix@
+exec_prefix =$(DESTDIR)@exec_prefix@
+libdir =$(exec_prefix)/lib
+bindir =$(exec_prefix)/bin
+includedir =$(exec_prefix)/include
+pdcursesdir =./x11
+
+INSTALL =$(srcdir)/install-sh
+RANLIB =@RANLIB@
+SHLPRE = @SHLPRE@
+SHLPST = @SHLPST@
+SHLFILE = XCurses
+
+include $(srcdir)/version.mif
+
+PDC_DIR=PDCurses-$(VERDOT)
+
+ZIPFILE = pdcurs$(VER).zip
+TARBALL = $(PDC_DIR).tar.gz
+
+all \
+clean \
+distclean \
+mostlyclean \
+realclean ::
+ cd x11; $(MAKE) $(MFLAGS) $@
+ cd doc; $(MAKE) $(MFLAGS) $@
+
+install ::
+ $(INSTALL) -d -m 755 $(libdir)
+ $(INSTALL) -d -m 755 $(bindir)
+ $(INSTALL) -d -m 755 $(includedir)
+ $(INSTALL) -d -m 755 $(includedir)/xcurses
+ $(INSTALL) -c -m 644 $(srcdir)/curses.h $(includedir)/xcurses.h
+ $(INSTALL) -c -m 644 $(srcdir)/curses.h $(includedir)/xcurses/curses.h
+ sed -e 's/#include <curses.h>/#include <xcurses.h>/' \
+ < $(srcdir)/panel.h > ./xpanel.h
+ $(INSTALL) -m 644 ./xpanel.h $(includedir)/xpanel.h
+ $(INSTALL) -c -m 644 $(srcdir)/panel.h $(includedir)/xcurses/panel.h
+ $(INSTALL) -c -m 644 $(srcdir)/term.h $(includedir)/xcurses/term.h
+ $(INSTALL) -c -m 644 $(pdcursesdir)/libXCurses.a $(libdir)/libXCurses.a
+ -$(RANLIB) $(libdir)/libXCurses.a
+ -$(INSTALL) -c -m 755 $(pdcursesdir)/$(SHLPRE)$(SHLFILE)$(SHLPST) \
+ $(libdir)/$(SHLPRE)$(SHLFILE)$(SHLPST)
+ ln -f -s $(libdir)/$(SHLPRE)$(SHLFILE)$(SHLPST) \
+ $(libdir)/$(SHLPRE)Xpanel$(SHLPST)
+ ln -f -s $(libdir)/libXCurses.a $(libdir)/libXpanel.a
+ -$(RANLIB) $(libdir)/libXpanel.a
+ $(INSTALL) -c -m 755 x11/xcurses-config $(bindir)/xcurses-config
+
+clean ::
+ rm -f config.log config.cache config.status
+
+distclean ::
+ rm -f config.log config.cache config.status
+ rm -f config.h Makefile x11/xcurses-config
+
+manual:
+ cd doc; $(MAKE) $(MFLAGS) $@
+
+$(ZIPFILE):
+ zip -9y $(ZIPFILE) README HISTORY IMPLEMNT *.spec *.mif *.def \
+ Makefile.in config.h.in configure configure.ac config.guess \
+ config.sub x11/xcurses-config.in install-sh aclocal.m4 curses.h \
+ curspriv.h panel.h term.h pdcurses/README \
+ pdcurses/*.c demos/README demos/*.c demos/*.h dos/README dos/*.c \
+ dos/*.h dos/*.mak dos/*.lrf os2/README os2/*.c os2/*.h os2/*.mak \
+ os2/*.lrf sdl1/README sdl1/*.c sdl1/*.h sdl1/Make* \
+ win32/README win32/*.c win32/*.h win32/*.mak \
+ win32/*.ico win32/*.rc x11/README x11/*.c x11/*.h x11/Makefile.* \
+ x11/*.xbm doc/*.txt doc/manext.c doc/Makefile
+
+zip: $(ZIPFILE)
+
+../$(TARBALL):
+ (cd ..; tar cvf - $(PDC_DIR)/README $(PDC_DIR)/HISTORY \
+ $(PDC_DIR)/IMPLEMNT $(PDC_DIR)/*.spec $(PDC_DIR)/*.mif \
+ $(PDC_DIR)/*.def $(PDC_DIR)/Makefile.in $(PDC_DIR)/aclocal.m4 \
+ $(PDC_DIR)/config.h.in $(PDC_DIR)/configure \
+ $(PDC_DIR)/config.guess $(PDC_DIR)/x11/xcurses-config.in \
+ $(PDC_DIR)/config.sub $(PDC_DIR)/configure.ac \
+ $(PDC_DIR)/install-sh $(PDC_DIR)/curses.h $(PDC_DIR)/curspriv.h \
+ $(PDC_DIR)/panel.h $(PDC_DIR)/term.h \
+ $(PDC_DIR)/pdcurses/README $(PDC_DIR)/pdcurses/*.c \
+ $(PDC_DIR)/demos/README $(PDC_DIR)/demos/*.c $(PDC_DIR)/demos/*.h \
+ $(PDC_DIR)/doc/*.txt $(PDC_DIR)/dos/README $(PDC_DIR)/dos/*.c \
+ $(PDC_DIR)/dos/*.h $(PDC_DIR)/dos/*.mak $(PDC_DIR)/dos/*.lrf \
+ $(PDC_DIR)/os2/README $(PDC_DIR)/os2/*.c $(PDC_DIR)/os2/*.h \
+ $(PDC_DIR)/os2/*.mak $(PDC_DIR)/os2/*.lrf \
+ $(PDC_DIR)/sdl1/README $(PDC_DIR)/sdl1/*.c $(PDC_DIR)/sdl1/*.h \
+ $(PDC_DIR)/sdl1/Make* $(PDC_DIR)/win32/README $(PDC_DIR)/win32/*.c \
+ $(PDC_DIR)/win32/*.h $(PDC_DIR)/win32/*.mak \
+ $(PDC_DIR)/win32/*.ico $(PDC_DIR)/win32/*.rc $(PDC_DIR)/x11/README \
+ $(PDC_DIR)/x11/*.c $(PDC_DIR)/x11/*.xbm $(PDC_DIR)/x11/*.h \
+ $(PDC_DIR)/x11/Makefile.* $(PDC_DIR)/doc/manext.c \
+ $(PDC_DIR)/doc/Makefile | gzip -9 > $(TARBALL))
+
+dist: ../$(TARBALL)
+
+rpm: ../$(TARBALL)
+ rpmbuild -ba $(srcdir)/PDCurses.spec
diff --git a/payloads/libpayload/curses/PDCurses-3.4/PDCurses.spec b/payloads/libpayload/curses/PDCurses-3.4/PDCurses.spec
new file mode 100644
index 0000000000..814e313fab
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/PDCurses.spec
@@ -0,0 +1,52 @@
+# $Id: PDCurses.spec,v 1.18 2008/07/21 12:25:20 wmcbrine Exp $
+
+%define ver 34
+%define verdot 3.4
+%define base /usr
+
+Summary: Public Domain Curses for X11
+Name: PDCurses
+Version: %verdot
+Release: 1
+Copyright: Public Domain
+Group: Development/Libraries
+Source: %{name}-%{version}.tar.gz
+URL: http://pdcurses.sourceforge.net
+BuildRoot: %{_tmppath}/%{name}-%{version}-root
+Prefix: %base
+
+%description
+PDCurses for X11 is an implementation of the curses library that lets
+you build text-mode curses programs as native X11 applications. For more
+information, visit http://pdcurses.sourceforge.net/
+
+%prep
+%setup -q
+
+%build
+./configure --prefix=%{base}
+make
+
+%install
+make DESTDIR=$RPM_BUILD_ROOT install
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+rm -rf $RPM_BUILD_DIR/%{name}-%{version}
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root)
+%doc README HISTORY
+%{base}/bin/xcurses-config
+%{base}/lib/libXCurses.a
+%{base}/lib/libXpanel.a
+%{base}/lib/libXCurses.so
+%{base}/include/xcurses.h
+%{base}/include/xpanel.h
+%{base}/include/xcurses/curses.h
+%{base}/include/xcurses/panel.h
+%{base}/include/xcurses/term.h
diff --git a/payloads/libpayload/curses/PDCurses-3.4/README b/payloads/libpayload/curses/PDCurses-3.4/README
new file mode 100644
index 0000000000..dc476a9f1a
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/README
@@ -0,0 +1,48 @@
+Welcome to PDCurses!
+====================
+
+Public Domain Curses, aka PDCurses, is an implementation of X/Open
+curses for multiple platforms. The latest version can be found at:
+
+ http://pdcurses.sourceforge.net/
+
+For changes, see the HISTORY file.
+
+
+Legal Stuff
+-----------
+
+The core package is in the public domain, but small portions of PDCurses
+are subject to copyright under various licenses. Each directory
+contains a README file, with a section titled "Distribution Status"
+which describes the status of the files in that directory.
+
+If you use PDCurses in an application, an acknowledgement would be
+appreciated, but is not mandatory. If you make corrections or
+enhancements to PDCurses, please forward them to the current maintainer
+for the benefit of other users.
+
+This software is provided AS IS with NO WARRANTY whatsoever.
+
+
+Ports
+-----
+
+PDCurses has been ported to DOS, OS/2, Win32, X11 and SDL. A directory
+containing the port-specific source files exists for each of these
+platforms. Build instructions are in the README file for each platform.
+
+
+Distribution Status
+-------------------
+
+All files in this directory except configure, config.guess and
+config.sub are released to the Public Domain. config.guess and
+config.sub are under the GPL; configure is under a free license
+described within it.
+
+
+Maintainer
+----------
+
+William McBrine <wmcbrine@users.sf.net>
diff --git a/payloads/libpayload/curses/PDCurses-3.4/aclocal.m4 b/payloads/libpayload/curses/PDCurses-3.4/aclocal.m4
new file mode 100644
index 0000000000..ad7c3f3a44
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/aclocal.m4
@@ -0,0 +1,613 @@
+dnl ---------------------------------------------------------------------------
+dnl This file offers the following macros...
+dnl ---------------------------------------------------------------------------
+dnl MH_IPC
+dnl MH_CHECK_X_INC
+dnl MH_CHECK_X_LIB
+dnl MH_CHECK_X_HEADERS
+dnl MH_CHECK_X_KEYDEFS
+dnl MH_CHECK_X_TYPEDEF
+dnl MH_CHECK_LIB
+dnl MH_SHARED_LIBRARY
+dnl MH_HOWTO_DYN_LINK
+dnl MH_CHECK_CC_O
+dnl MH_SHLPST
+dnl MH_CHECK_MAX_SIGNALS
+
+dnl ---------------------------------------------------------------------------
+dnl Determine if the system has System V IPC. ie sys/ipc.h and sys/shm.h
+dnl headers.
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([MH_IPC],
+[
+AC_CHECK_HEADER(sys/ipc.h)
+if test $ac_cv_header_sys_ipc_h = no; then
+ AC_MSG_ERROR(Cannot find required header file sys/ipc.h; PDCurses cannot be configured)
+fi
+])dnl
+
+dnl ---------------------------------------------------------------------------
+dnl Set up the correct X header file location
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([MH_CHECK_X_INC],
+[
+mh_x11_dir=""
+mh_x11_xaw_dir=""
+
+mh_inc_dirs="$ac_x_header_dirs"
+
+dnl Provide for user supplying directory
+
+if test "x$x_includes" != xNONE ; then
+ mh_inc_dirs="$x_includes $mh_inc_dirs"
+fi
+
+dnl Try to determine the directory containing X headers
+dnl We will append X11 to all the paths above as an extra check
+
+for ac_dir in $mh_inc_dirs ; do
+ if test -r $ac_dir/Intrinsic.h; then
+ mh_x11_dir=$ac_dir
+ break
+ fi
+ if test -r $ac_dir/X11/Intrinsic.h; then
+ mh_x11_dir="$ac_dir/X11"
+ break
+ fi
+done
+
+dnl Try to determine the directory containing Xaw headers
+dnl We will append X11 to all the paths above as an extra check
+
+if test "$with_xaw3d" = yes; then
+ mh_xaw_dir="Xaw3d"
+else
+ if test "$with_nextaw" = yes; then
+ mh_xaw_dir="neXtaw"
+ else
+ mh_xaw_dir="Xaw"
+ fi
+fi
+for ac_dir in $mh_inc_dirs ; do
+ if test -r $ac_dir/$mh_xaw_dir/Box.h; then
+ mh_x11_xaw_dir=$ac_dir
+ break
+ fi
+ if test -r $ac_dir/X11/$mh_xaw_dir/Box.h; then
+ mh_x11_xaw_dir="$ac_dir/X11"
+ break
+ fi
+done
+
+if test "x$mh_x11_dir" != "x" ; then
+ mh_x11_dir_no_x11=`echo $mh_x11_dir | sed 's/\/X11$//'`
+
+ if test "$mh_x11_dir_no_x11" != "$mh_x11_dir" ; then
+ MH_XINC_DIR="-I$mh_x11_dir -I$mh_x11_dir_no_x11"
+ else
+ MH_XINC_DIR="-I$mh_x11_dir"
+ fi
+else
+ AC_MSG_ERROR(Cannot find required header file Intrinsic.h; PDCurses cannot be configured)
+fi
+
+if test "x$mh_x11_xaw_dir" != "x"; then
+ if test "$mh_x11_xaw_dir" != "$mh_x11_dir" ; then
+ MH_XINC_DIR="-I$mh_x11_xaw_dir $MH_XINC_DIR"
+ fi
+else
+ AC_MSG_ERROR(Cannot find required Xaw header file Box.h; PDCurses cannot be configured)
+fi
+
+AC_SUBST(MH_XINC_DIR)
+
+])dnl
+
+dnl ---------------------------------------------------------------------------
+dnl Set up the correct X library file location
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([MH_CHECK_X_LIB],
+[
+dnl Some systems require extra libraries...
+
+mh_solaris_flag=no
+mh_hpux9_flag=no
+AC_REQUIRE([AC_CANONICAL_SYSTEM])
+case "$target" in
+ *solaris*)
+ mh_solaris_flag=yes
+ ;;
+ *pc-sco*)
+ extra_x_libs="Xext"
+ ;;
+ sparc*sunos*)
+ extra_x_libs="Xext"
+ if test "$ac_cv_prog_CC" = "gcc" ; then
+ extra_ld_flags="-Wl,-Bstatic"
+ extra_ld_flags2="-Wl,-Bdynamic"
+ else
+ extra_ld_flags="-Bstatic"
+ extra_ld_flags2="-Bdynamic"
+ fi
+ ;;
+ *hpux9*)
+ mh_hpux9_flag=yes
+ ;;
+esac
+
+if test "$with_xaw3d" = yes; then
+ MH_X11_LIBS="Xaw3d Xmu Xt X11"
+else
+ if test "$with_nextaw" = yes; then
+ MH_X11_LIBS="neXtaw Xmu Xt X11"
+ else
+ MH_X11_LIBS="Xaw Xmu Xt X11"
+ fi
+fi
+MH_X11R6_LIBS="SM ICE Xext"
+mh_x11r6=no
+
+mh_lib_dirs="$x_libraries `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`"
+
+dnl try to find libSM.[a,sl,so,dylib]. If we find it we are using X11R6
+for ac_dir in $mh_lib_dirs ; do
+ for mh_xsm in libSM.a libSM.so libSM.sl libSM.dylib; do
+ if test -r $ac_dir/$mh_xsm; then
+ mh_x11r6=yes
+ break 2
+ fi
+ done
+done
+
+if test "$mh_x11r6" = yes ; then
+ mh_libs="$MH_X11_LIBS $MH_X11R6_LIBS"
+else
+ mh_libs="$MH_X11_LIBS $extra_x_libs"
+fi
+
+
+dnl Ensure that all required X libraries are found
+
+mh_prev_dir=""
+mh_where_found=""
+mh_where_found_dirs=""
+mh_solaris_path=""
+for mh_lib in $mh_libs; do
+ mh_lib_found=no
+ for ac_dir in $mh_lib_dirs ; do
+ for mh_ext in a so sl dll.a dylib; do
+ if test -r $ac_dir/lib$mh_lib.$mh_ext; then
+ if test "x$mh_prev_dir" != "x$ac_dir" ; then
+ if test "x$mh_prev_dir" = "x" ; then
+ mh_where_found="$mh_where_found found in $ac_dir"
+ else
+ mh_where_found="$mh_where_found and in $ac_dir"
+ fi
+ mh_prev_dir=$ac_dir
+ mh_where_found_dirs="$mh_where_found_dirs $ac_dir"
+ MH_XLIBS="$MH_XLIBS -L$ac_dir"
+ mh_solaris_path="${mh_solaris_path}:$ac_dir"
+ fi
+ MH_XLIBS="$MH_XLIBS -l$mh_lib"
+ mh_lib_found=yes
+ break 2
+ fi
+ done
+ done
+ if test "$mh_lib_found" = no; then
+ AC_MSG_ERROR(Cannot find required X library; lib$mh_lib. PDCurses cannot be configured)
+ fi
+done
+
+mh_solaris_path=`echo $mh_solaris_path | sed 's/^://'`
+if test "$mh_solaris_flag" = yes ; then
+ MH_XLIBS="-R$mh_solaris_path $extra_ld_flags $MH_XLIBS $extra_libs $extra_ld_flags2"
+else
+ MH_XLIBS="$extra_ld_flags $MH_XLIBS $extra_libs $extra_ld_flags2"
+fi
+if test "$mh_hpux9_flag" = yes ; then
+ grep -q XtSetLanguageProc $mh_x11_dir/Intrinsic.h
+ if test $? -eq 0 ; then
+ mh_found_xtshellstrings=no
+ for mh_acdir in $mh_where_found_dirs ; do
+ for mh_xaw in `ls $mh_acdir/libXaw.*` ; do
+ nm $mh_xaw | grep XtShellStrings | grep -qv extern
+ if test $? -eq 0 ; then
+ mh_found_xtshellstrings=yes
+ fi
+ done
+ done
+ if test "$mh_found_xtshellstrings" = no ; then
+ AC_MSG_WARN(The X11 development environment has not been installed correctly.)
+ AC_MSG_WARN(The header file; Intrinsic.h, is for X11R5 while the Athena Widget)
+ AC_MSG_WARN(Set library; libXaw is for X11R4. This is a common problem with)
+ AC_MSG_WARN(HP-UX 9.x.)
+ AC_MSG_ERROR(X11 installation incomplete; cannot continue)
+ fi
+ fi
+fi
+
+AC_SUBST(MH_XLIBS)
+
+])dnl
+
+dnl ---------------------------------------------------------------------------
+dnl Determine if the supplied X headers exist.
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([MH_CHECK_X_HEADERS],
+[
+save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $MH_XINC_DIR"
+for mh_header in $1; do
+ AC_CHECK_HEADERS($mh_header)
+done
+CPPFLAGS="$save_CPPFLAGS"
+])dnl
+
+dnl ---------------------------------------------------------------------------
+dnl Determine if various key definitions exist in keysym.h
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([MH_CHECK_X_KEYDEFS],
+[
+save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $MH_XINC_DIR"
+for mh_keydef in $1; do
+ AC_MSG_CHECKING(for $mh_keydef in keysym.h)
+ mh_upper_name="HAVE_`echo $mh_keydef | tr '[a-z]' '[A-Z]'`"
+ AC_TRY_COMPILE([#include <keysym.h>],
+[int i = $mh_keydef;],
+ mh_have_key=yes; AC_DEFINE_UNQUOTED($mh_upper_name,1), mh_have_key=no )
+ AC_MSG_RESULT($mh_have_key)
+done
+CPPFLAGS="$save_CPPFLAGS"
+])dnl
+
+dnl ---------------------------------------------------------------------------
+dnl Determine if supplied types have been typedefed
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([MH_CHECK_X_TYPEDEF],
+[
+save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $SYS_DEFS $MH_XINC_DIR"
+for td in $1 ; do
+AC_MSG_CHECKING(if $td is typedefed:)
+AC_TRY_COMPILE(
+[#include "X11/Xlib.h"],
+[$td fred],
+ [mh_td=yes],
+ [mh_td=no]
+)
+if test "$mh_td" = yes ; then
+ TD_upper=`echo $td | tr a-z A-Z`
+ AC_DEFINE_UNQUOTED(${TD_upper}_TYPEDEFED, 1)
+fi
+AC_MSG_RESULT($mh_td)
+done
+CPPFLAGS="$save_CPPFLAGS"
+])dnl
+
+dnl ---------------------------------------------------------------------------
+dnl Check for presence of various libraries
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([MH_CHECK_LIB],
+[
+MH_EXTRA_LIBS=''
+for mh_lib in $1; do
+ if test "$on_qnx" = yes; then
+ AC_MSG_CHECKING(for library -l${mh_lib})
+ if test -r /usr/lib/${mh_lib}3r.lib; then
+ AC_MSG_RESULT(found)
+ MH_EXTRA_LIBS="${MH_EXTRA_LIBS} -l${mh_lib}"
+ else
+ AC_MSG_RESULT(not found)
+ fi
+ else
+ AC_CHECK_LIB($mh_lib,main,mh_lib_found=yes,mh_lib_found=no)
+ if test "$mh_lib_found" = yes; then
+ MH_EXTRA_LIBS="${MH_EXTRA_LIBS} -l${mh_lib}"
+ fi
+ fi
+done
+])dnl
+
+dnl ---------------------------------------------------------------------------
+dnl Work out how to create a dynamically loaded module
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([MH_HOWTO_DYN_LINK],
+[
+mh_compile='${CC-cc} -c $DYN_COMP conftest.$ac_ext 1>&AC_FD_CC'
+cat > conftest.$ac_ext <<EOF
+dnl [#]line __oline__ "[$]0"
+[#]line __oline__ "configure"
+int foo()
+{
+return(0);
+}
+EOF
+if AC_TRY_EVAL(mh_compile) && test -s conftest.o; then
+ mh_dyn_link='ld -shared -o conftest.rxlib conftest.o -lc 1>&AC_FD_CC'
+# mh_dyn_link='${CC} -Wl,-shared -o conftest.rxlib conftest.o -lc 1>&AC_FD_CC'
+ if AC_TRY_EVAL(mh_dyn_link) && test -s conftest.rxlib; then
+ LD_RXLIB1="ld -shared"
+# LD_RXLIB1="${CC} -Wl,-shared"
+ SHLPRE="lib"
+ SHLPST=".so"
+ else
+ mh_dyn_link='ld -G -o conftest.rxlib conftest.o 1>&AC_FD_CC'
+# mh_dyn_link='${CC} -Wl,-G -o conftest.rxlib conftest.o 1>&AC_FD_CC'
+ if AC_TRY_EVAL(mh_dyn_link) && test -s conftest.rxlib; then
+ LD_RXLIB1="ld -G"
+# LD_RXLIB1="${CC} -Wl,-G"
+ SHLPRE="lib"
+ SHLPST=".so"
+ else
+ LD_RXLIB1=""
+ SHLPRE=""
+ SHLPST=""
+ fi
+ fi
+fi
+rm -f conftest*
+])dnl
+
+dnl ---------------------------------------------------------------------------
+dnl Determine how to build shared libraries etc..
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([MH_SHARED_LIBRARY],
+[
+AC_REQUIRE([MH_SHLPST])
+dnl
+dnl If compiler is gcc, then flags should be the same for all platforms
+dnl (just guessing on this)
+dnl
+AIX_DYN="no"
+BEOS_DYN="no"
+SHLFILE="$1"
+SHLFILES="$*"
+RXPACKEXPORTS=""
+SHLPRE="lib"
+LD_RXLIB1=""
+
+AC_REQUIRE([AC_CANONICAL_SYSTEM])
+case "$target" in
+ *hp-hpux*)
+ SYS_DEFS="-D_HPUX_SOURCE"
+ LD_RXLIB1="ld -b -q -n"
+ ;;
+ *ibm-aix*)
+ SYS_DEFS="-D_ALL_SOURCE -DAIX"
+ AIX_DYN="yes"
+ DYN_COMP="-DDYNAMIC"
+ LD_RXLIB1="ld -bnoentry -bM:SRE"
+ RXPACKEXPORTS="-bE:$SHLFILE.exp"
+ RXPACKEXP="$SHLFILE.exp"
+ ;;
+ *dec-osf*)
+ if test "$ac_cv_prog_CC" = "gcc"; then
+ SYS_DEFS="-D_POSIX_SOURCE -D_XOPEN_SOURCE"
+ else
+ SYS_DEFS="-D_POSIX_SOURCE -D_XOPEN_SOURCE -Olimit 800"
+ fi
+ LD_RXLIB1="ld -shared"
+ ;;
+ *sequent-dynix*|*esix*|*dgux*)
+ LD_RXLIB1="ld -G"
+ ;;
+ *solaris*)
+ if test "$ac_cv_prog_CC" = "gcc"; then
+ LD_RXLIB1="gcc -shared"
+ else
+ LD_RXLIB1="ld -G"
+ fi
+ ;;
+ sparc*sunos*)
+ SYS_DEFS="-DSUNOS -DSUNOS_STRTOD_BUG"
+ LD_RXLIB1="ld"
+ ;;
+ *linux*|*atheos*|*nto-qnx*)
+ LD_RXLIB1="${CC} -shared"
+ ;;
+ *freebsd*)
+ LD_RXLIB1="ld -Bdynamic -Bshareable"
+ ;;
+ *pc-sco*)
+ LD_RXLIB1="ld -dy -G"
+ ;;
+ *beos*)
+ LD_RXLIB1="${CC} -Wl,-shared -nostart -Xlinker -soname=\$(@)"
+ BEOS_DYN="yes"
+ ;;
+ *qnx*)
+ SHLPRE=""
+ DYN_COMP="-Q" # force no check for dynamic loading
+ SHLFILE=""
+ ;;
+ *cygwin)
+ SHLPRE=""
+ DYN_COMP="-DDYNAMIC"
+ LD_RXLIB1="dllwrap --def \$(srcdir)/../win32/pdcurses.def --target i386-cygwin32 --dllname \$(@)"
+# cygwininstall target MUST install the shared library itself because
+# it puts it into $(bindir) not $(libdir) as all other platforms
+ ;;
+ *darwin*)
+ DYN_COMP="-fno-common"
+ LD_RXLIB1="${CC} -flat_namespace -undefined suppress -dynamiclib -install_name=\$(@)"
+ ;;
+ *)
+ ;;
+esac
+
+dnl determine what switches our compiler uses for building objects
+dnl suitable for inclusion in shared libraries
+dnl Only call this if DYN_COMP is not set. If we have set DYN_COMP
+dnl above, then we know how to compile AND link for dynamic libraries
+
+if test "$DYN_COMP" = ""; then
+AC_MSG_CHECKING(compiler flags for a dynamic object)
+
+cat > conftest.$ac_ext <<EOF
+dnl [#]line __oline__ "[$]0"
+[#]line __oline__ "configure"
+int a=0
+EOF
+
+ DYN_COMP=""
+ mh_cv_stop=no
+ save_cflags="$CFLAGS"
+ mh_cv_flags="-fPIC -KPIC +Z"
+ for a in $mh_cv_flags; do
+ CFLAGS="-c $a"
+
+ mh_compile='${CC-cc} -c $CFLAGS conftest.$ac_ext > conftest.tmp 2>&1'
+ if AC_TRY_EVAL(mh_compile); then
+ DYN_COMP=""
+ else
+ slash="\\"
+ mh_dyncomp="`egrep -c $slash$a conftest.tmp`"
+ if test "$mh_dyncomp" = "0"; then
+ DYN_COMP="$a -DDYNAMIC"
+ AC_MSG_RESULT($a)
+ break
+ else
+ DYN_COMP=""
+ fi
+ fi
+ done
+ if test "$DYN_COMP" = ""; then
+ AC_MSG_RESULT(none of $mh_cv_flags supported)
+ fi
+ if test "$LD_RXLIB1" = ""; then
+ MH_HOWTO_DYN_LINK()
+ fi
+ CFLAGS=$save_cflags
+ rm -f conftest.*
+fi
+
+
+SHL_TARGETS=""
+
+if test "$AIX_DYN" = "yes"; then
+ aix_exports="config.exports.aix"
+ echo "" > $aix_exports
+fi
+
+if test "$ac_cv_header_dl_h" = "yes" -o "$ac_cv_header_dlfcn_h" = "yes" -o "$AIX_DYN" = "yes" -o "$BEOS_DYN" = "yes" -o "$DLFCNINCDIR" != "" -o "$DLFCNLIBDIR" != ""; then
+ EXPS="1,2,3,4,5,6,7,8,9"
+ for a in $SHLFILES
+ do
+ SHL_TARGETS="${SHL_TARGETS} ${SHLPRE}${a}${SHLPST}"
+ this=`echo $EXPS | cut -d, -f1`
+ EXPS=`echo $EXPS | cut -d, -f2-`
+ if test "$AIX_DYN" = "yes"; then
+ echo "RXPACKEXP$this=$a.exp" >> $aix_exports
+ echo "RXPACKEXPORTS$this=-bE:$a.exp" >> $aix_exports
+ fi
+ done
+fi
+
+AC_SUBST(DYN_COMP)
+AC_SUBST(LIBS)
+AC_SUBST(LD_RXLIB1)
+AC_SUBST(SHLPRE)
+AC_SUBST(SHLPST)
+AC_SUBST(SHL_TARGETS)
+AC_SUBST(O2SAVE)
+AC_SUBST(CC2O)
+AC_SUBST(SAVE2O)
+AC_SUBST(RXPACKEXPORTS)
+])dnl
+
+dnl ---------------------------------------------------------------------------
+dnl Check if C compiler supports -c -o file.ooo
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([MH_CHECK_CC_O],
+[
+AC_MSG_CHECKING(whether $CC understand -c and -o together)
+set dummy $CC; ac_cc="`echo [$]2 |
+changequote(, )dnl
+ sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`"
+changequote([, ])dnl
+AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
+[echo 'foo(){}' > conftest.c
+# We do the test twice because some compilers refuse to overwrite an
+# existing .o file with -o, though they will create one.
+eval ac_cv_prog_cc_${ac_cc}_c_o=no
+ac_try='${CC-cc} -c conftest.c -o conftest.ooo 1>&AC_FD_CC'
+if AC_TRY_EVAL(ac_try) && test -f conftest.ooo && AC_TRY_EVAL(ac_try);
+then
+ ac_try='${CC-cc} -c conftest.c -o conftest.ooo 1>&AC_FD_CC'
+ if AC_TRY_EVAL(ac_try) && test -f conftest.ooo && AC_TRY_EVAL(ac_try);
+ then
+ eval ac_cv_prog_cc_${ac_cc}_c_o=yes
+ fi
+fi
+rm -f conftest*
+])dnl
+if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then
+ O2SAVE=""
+ SAVE2O=""
+ CC2O="-o $"'@'
+ AC_MSG_RESULT(yes)
+else
+ O2SAVE="-mv \`basename "$'@'" .sho\`.o \`basename "$'@'" .sho\`.o.save;"
+ SAVE2O="-mv \`basename "$'@'" .sho\`.o "$'@'"; mv \`basename "$'@'" .sho\`.o.save \`basename "$'@'" .sho\`.o"
+ CC2O=""
+ AC_MSG_RESULT(no)
+fi
+])
+
+dnl ---------------------------------------------------------------------------
+dnl Determines the file extension for shared libraries
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([MH_SHLPST],
+[
+AC_MSG_CHECKING(shared library extension)
+SHLPST=".so"
+AC_REQUIRE([AC_CANONICAL_SYSTEM])
+case "$target" in
+ *hp-hpux*)
+ SHLPST=".sl"
+ ;;
+ *ibm-aix*)
+ SHLPST=".a"
+ ;;
+ *qnx*)
+ SHLPST=""
+ ;;
+ *cygwin*)
+ SHLPST=".dll"
+ ;;
+ *darwin*)
+ SHLPST=".dylib"
+ ;;
+esac
+AC_SUBST(SHLPST)
+AC_MSG_RESULT($SHLPST)
+])
+
+dnl ---------------------------------------------------------------------------
+dnl Determine the system limit for number of signals
+dnl ---------------------------------------------------------------------------
+AC_DEFUN([MH_CHECK_MAX_SIGNALS],
+[
+save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $SYS_DEFS"
+AC_MSG_CHECKING(for maximum signal specifier:)
+AC_CACHE_VAL(mh_cv_max_signals,
+mh_found="no"
+for mh_sigs in $1; do
+ AC_TRY_COMPILE([#include <signal.h>],
+[return $mh_sigs;],
+ mh_found="yes"; mh_cv_max_signals="$mh_sigs" )
+ if test "$mh_found" = "yes"; then
+ break;
+ fi
+done)
+CPPFLAGS="$save_CPPFLAGS"
+if test "$mh_found" = "no"; then
+ AC_MSG_ERROR(Cannot find a system limit for number of signals. PDCurses cannot be configured on this machine.)
+else
+ AC_DEFINE_UNQUOTED(PDC_MAX_SIGNALS,$mh_cv_max_signals)
+ AC_MSG_RESULT($mh_cv_max_signals)
+fi
+])dnl
diff --git a/payloads/libpayload/curses/PDCurses-3.4/config.guess b/payloads/libpayload/curses/PDCurses-3.4/config.guess
new file mode 100755
index 0000000000..396482d6cb
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/config.guess
@@ -0,0 +1,1500 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+# Inc.
+
+timestamp='2006-07-02'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub. If it succeeds, it prints the system name on stdout, and
+# exits with 0. Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) echo "int x;" > $dummy.c ;
+ for c in cc gcc c89 c99 ; do
+ if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+ CC_FOR_BUILD="$c"; break ;
+ fi ;
+ done ;
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found ;
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+ # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ sysctl="sysctl -n hw.machine_arch"
+ UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ case "${UNAME_MACHINE_ARCH}" in
+ armeb) machine=armeb-unknown ;;
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently, or will in the future.
+ case "${UNAME_MACHINE_ARCH}" in
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ eval $set_cc_for_build
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep __ELF__ >/dev/null
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # The OS release
+ # Debian GNU/NetBSD machines have a different userland, and
+ # thus, need a distinct triplet. However, they do not need
+ # kernel version information, so it can be replaced with a
+ # suitable tag, in the style of linux-gnu.
+ case "${UNAME_VERSION}" in
+ Debian*)
+ release='-gnu'
+ ;;
+ *)
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ ;;
+ esac
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit ;;
+ *:OpenBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+ exit ;;
+ *:ekkoBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+ exit ;;
+ *:SolidBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+ exit ;;
+ macppc:MirBSD:*:*)
+ echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ *:MirBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ alpha:OSF1:*:*)
+ case $UNAME_RELEASE in
+ *4.0)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ ;;
+ *5.*)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+ ;;
+ esac
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+ # types through head -n 1, so we only detect the type of CPU 0.
+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+ case "$ALPHA_CPU_TYPE" in
+ "EV4 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "EV4.5 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "LCA4 (21066/21068)")
+ UNAME_MACHINE="alpha" ;;
+ "EV5 (21164)")
+ UNAME_MACHINE="alphaev5" ;;
+ "EV5.6 (21164A)")
+ UNAME_MACHINE="alphaev56" ;;
+ "EV5.6 (21164PC)")
+ UNAME_MACHINE="alphapca56" ;;
+ "EV5.7 (21164PC)")
+ UNAME_MACHINE="alphapca57" ;;
+ "EV6 (21264)")
+ UNAME_MACHINE="alphaev6" ;;
+ "EV6.7 (21264A)")
+ UNAME_MACHINE="alphaev67" ;;
+ "EV6.8CB (21264C)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8AL (21264B)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8CX (21264D)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.9A (21264/EV69A)")
+ UNAME_MACHINE="alphaev69" ;;
+ "EV7 (21364)")
+ UNAME_MACHINE="alphaev7" ;;
+ "EV7.9 (21364A)")
+ UNAME_MACHINE="alphaev79" ;;
+ esac
+ # A Pn.n version is a patched version.
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+ exit ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
+ exit ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit ;;
+ *:z/VM:*:*)
+ echo s390-ibm-zvmoe
+ exit ;;
+ *:OS400:*:*)
+ echo powerpc-ibm-os400
+ exit ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit ;;
+ arm:riscos:*:*|arm:RISCOS:*:*)
+ echo arm-unknown-riscos
+ exit ;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit ;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit ;;
+ DRS?6000:unix:4.0:6*)
+ echo sparc-icl-nx6
+ exit ;;
+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) echo sparc-icl-nx7; exit ;;
+ esac ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ i86pc:SunOS:5.*:*)
+ echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit ;;
+ m68k:machten:*:*)
+ echo m68k-apple-machten${UNAME_RELEASE}
+ exit ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c &&
+ dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+ SYSTEM_NAME=`$dummy $dummyarg` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+ exit ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+ then
+ echo "$SYSTEM_NAME"
+ else
+ echo rs6000-ibm-aix3.2.5
+ fi
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit ;;
+ *:AIX:*:[45])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
+ '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
+ esac ;;
+ esac
+ fi
+ if [ "${HP_ARCH}" = "" ]; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+ test -z "$HP_ARCH" && HP_ARCH=hppa
+ fi ;;
+ esac
+ if [ ${HP_ARCH} = "hppa2.0w" ]
+ then
+ eval $set_cc_for_build
+
+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
+ # generating 64-bit code. GNU and HP use different nomenclature:
+ #
+ # $ CC_FOR_BUILD=cc ./config.guess
+ # => hppa2.0w-hp-hpux11.23
+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+ # => hppa64-hp-hpux11.23
+
+ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+ grep __LP64__ >/dev/null
+ then
+ HP_ARCH="hppa2.0w"
+ else
+ HP_ARCH="hppa64"
+ fi
+ fi
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit ;;
+ 3050*:HI-UX:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo unknown-hitachi-hiuxwe2
+ exit ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ *:UNICOS/mp:*:*)
+ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ 5000:UNIX_System_V:4.*:*)
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:FreeBSD:*:*)
+ case ${UNAME_MACHINE} in
+ pc98)
+ echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ amd64)
+ echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ *)
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ esac
+ exit ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit ;;
+ i*:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit ;;
+ i*:windows32*:*)
+ # uname -m includes "-pc" on this system.
+ echo ${UNAME_MACHINE}-mingw32
+ exit ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit ;;
+ x86:Interix*:[3456]*)
+ echo i586-pc-interix${UNAME_RELEASE}
+ exit ;;
+ EM64T:Interix*:[3456]*)
+ echo x86_64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+ echo i${UNAME_MACHINE}-pc-mks
+ exit ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i586-pc-interix
+ exit ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit ;;
+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+ echo x86_64-unknown-cygwin
+ exit ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ *:GNU:*:*)
+ # the GNU system
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit ;;
+ *:GNU/*:*:*)
+ # other systems with GNU libc and userland
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+ exit ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit ;;
+ arm*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ avr32*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ cris:Linux:*:*)
+ echo cris-axis-linux-gnu
+ exit ;;
+ crisv32:Linux:*:*)
+ echo crisv32-axis-linux-gnu
+ exit ;;
+ frv:Linux:*:*)
+ echo frv-unknown-linux-gnu
+ exit ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m32r*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ mips:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips
+ #undef mipsel
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mipsel
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ mips64:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips64
+ #undef mips64el
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mips64el
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips64
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ or32:Linux:*:*)
+ echo or32-unknown-linux-gnu
+ exit ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
+ exit ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-gnu
+ exit ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+ if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ exit ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) echo hppa1.1-unknown-linux-gnu ;;
+ PA8*) echo hppa2.0-unknown-linux-gnu ;;
+ *) echo hppa-unknown-linux-gnu ;;
+ esac
+ exit ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+ exit ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit ;;
+ sh64*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ vax:Linux:*:*)
+ echo ${UNAME_MACHINE}-dec-linux-gnu
+ exit ;;
+ x86_64:Linux:*:*)
+ echo x86_64-unknown-linux-gnu
+ exit ;;
+ i*86:Linux:*:*)
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us. cd to the root directory to prevent
+ # problems with other programs or directories called `ld' in the path.
+ # Set LC_ALL=C to ensure ld outputs messages in English.
+ ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+ | sed -ne '/supported targets:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported targets: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_targets" in
+ elf32-i386)
+ TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+ ;;
+ a.out-i386-linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+ exit ;;
+ coff-i386)
+ echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+ exit ;;
+ "")
+ # Either a pre-BFD a.out linker (linux-gnuoldld) or
+ # one that does not give us useful --help.
+ echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+ exit ;;
+ esac
+ # Determine whether the default compiler is a.out or elf
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <features.h>
+ #ifdef __ELF__
+ # ifdef __GLIBC__
+ # if __GLIBC__ >= 2
+ LIBC=gnu
+ # else
+ LIBC=gnulibc1
+ # endif
+ # else
+ LIBC=gnulibc1
+ # endif
+ #else
+ #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+ LIBC=gnu
+ #else
+ LIBC=gnuaout
+ #endif
+ #endif
+ #ifdef __dietlibc__
+ LIBC=dietlibc
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^LIBC/{
+ s: ::g
+ p
+ }'`"
+ test x"${LIBC}" != x && {
+ echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+ exit
+ }
+ test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+ ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
+ echo i386-sequent-sysv4
+ exit ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+ exit ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+ exit ;;
+ i*86:syllable:*:*)
+ echo ${UNAME_MACHINE}-pc-syllable
+ exit ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit ;;
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit ;;
+ i*86:*:5:[678]*)
+ # UnixWare 7.x, OpenUNIX and OpenServer 6.
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ exit ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+ exit ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+ exit ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+ exit ;;
+ M68*:*:R3V[5678]*:*)
+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4; exit; } ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit ;;
+ i*86:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo ${UNAME_MACHINE}-stratus-vos
+ exit ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo hppa1.1-stratus-vos
+ exit ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux${UNAME_RELEASE}
+ exit ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Darwin:*:*)
+ UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+ case $UNAME_PROCESSOR in
+ unknown) UNAME_PROCESSOR=powerpc ;;
+ esac
+ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ exit ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = "x86"; then
+ UNAME_PROCESSOR=i386
+ UNAME_MACHINE=pc
+ fi
+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+ exit ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit ;;
+ NSE-?:NONSTOP_KERNEL:*:*)
+ echo nse-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ NSR-?:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "$cputype" = "386"; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+ exit ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit ;;
+ SEI:*:*:SEIUX)
+ echo mips-sei-seiux${UNAME_RELEASE}
+ exit ;;
+ *:DragonFly:*:*)
+ echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit ;;
+ *:*VMS:*:*)
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ case "${UNAME_MACHINE}" in
+ A*) echo alpha-dec-vms ; exit ;;
+ I*) echo ia64-dec-vms ; exit ;;
+ V*) echo vax-dec-vms ; exit ;;
+ esac ;;
+ *:XENIX:*:SysV)
+ echo i386-pc-xenix
+ exit ;;
+ i*86:skyos:*:*)
+ echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+ exit ;;
+ i*86:rdos:*:*)
+ echo ${UNAME_MACHINE}-pc-rdos
+ exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+# include <sys/param.h>
+# if defined (BSD)
+# if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+# else
+# if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# endif
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# else
+ printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ c34*)
+ echo c34-convex-bsd
+ exit ;;
+ c38*)
+ echo c38-convex-bsd
+ exit ;;
+ c4*)
+ echo c4-convex-bsd
+ exit ;;
+ esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+ http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
+and
+ http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/payloads/libpayload/curses/PDCurses-3.4/config.h.in b/payloads/libpayload/curses/PDCurses-3.4/config.h.in
new file mode 100644
index 0000000000..28e9e48ea4
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/config.h.in
@@ -0,0 +1,133 @@
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define if you have the <DECkeySym.h> header file */
+#undef HAVE_DECKEYSYM_H
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <dl.h> header file. */
+#undef HAVE_DL_H
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `poll' function. */
+#undef HAVE_POLL
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define if you have the <Sunkeysym.h> header file */
+#undef HAVE_SUNKEYSYM_H
+
+/* Define to 1 if you have the <sys/select.h> header file. */
+#undef HAVE_SYS_SELECT_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the `usleep' function. */
+#undef HAVE_USLEEP
+
+/* Define to 1 if you have the `vsnprintf' function. */
+#undef HAVE_VSNPRINTF
+
+/* Define to 1 if you have the `vsscanf' function. */
+#undef HAVE_VSSCANF
+
+/* Define if you have this defined in <keysym.h> */
+#undef HAVE_XK_KP_BEGIN
+
+/* Define if you have this defined in <keysym.h> */
+#undef HAVE_XK_KP_DELETE
+
+/* Define if you have this defined in <keysym.h> */
+#undef HAVE_XK_KP_DOWN
+
+/* Define if you have this defined in <keysym.h> */
+#undef HAVE_XK_KP_END
+
+/* Define if you have this defined in <keysym.h> */
+#undef HAVE_XK_KP_HOME
+
+/* Define if you have this defined in <keysym.h> */
+#undef HAVE_XK_KP_INSERT
+
+/* Define if you have this defined in <keysym.h> */
+#undef HAVE_XK_KP_LEFT
+
+/* Define if you have this defined in <keysym.h> */
+#undef HAVE_XK_KP_NEXT
+
+/* Define if you have this defined in <keysym.h> */
+#undef HAVE_XK_KP_PRIOR
+
+/* Define if you have this defined in <keysym.h> */
+#undef HAVE_XK_KP_RIGHT
+
+/* Define if you have this defined in <keysym.h> */
+#undef HAVE_XK_KP_UP
+
+/* Define if you have the <xpm.h> header file */
+#undef HAVE_XPM_H
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define as the system defined limit for number of signals */
+#undef PDC_MAX_SIGNALS
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#undef RETSIGTYPE
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Define if you want to use neXtaw library */
+#undef USE_NEXTAW
+
+/* Define if you want to use Xaw3d library */
+#undef USE_XAW3D
+
+/* Define XPointer is typedefed in X11/Xlib.h */
+#undef XPOINTER_TYPEDEFED
diff --git a/payloads/libpayload/curses/PDCurses-3.4/config.sub b/payloads/libpayload/curses/PDCurses-3.4/config.sub
new file mode 100755
index 0000000000..fab0aa3556
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/config.sub
@@ -0,0 +1,1616 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+# Inc.
+
+timestamp='2006-09-20'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit ;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple | -axis | -knuth | -cray)
+ os=
+ basic_machine=$1
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -chorusos*)
+ os=-chorusos
+ basic_machine=$1
+ ;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco6)
+ os=-sco5v6
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ 1750a | 580 \
+ | a29k \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | am33_2.0 \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+ | bfin \
+ | c4x | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+ | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k | iq2000 \
+ | m32c | m32r | m32rle | m68000 | m68k | m88k \
+ | maxq | mb | microblaze | mcore \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64vr | mips64vrel \
+ | mips64orion | mips64orionel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mips64vr5900 | mips64vr5900el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | mt \
+ | msp430 \
+ | nios | nios2 \
+ | ns16k | ns32k \
+ | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+ | pyramid \
+ | score \
+ | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+ | spu | strongarm \
+ | tahoe | thumb | tic4x | tic80 | tron \
+ | v850 | v850e \
+ | we32k \
+ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+ | z8k)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12)
+ # Motorola 68HC11/12.
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ ;;
+ ms1)
+ basic_machine=mt-unknown
+ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* | avr32-* \
+ | bfin-* | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+ | clipper-* | craynv-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | elxsi-* \
+ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* | iq2000-* \
+ | m32c-* | m32r-* | m32rle-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mips64vr5900-* | mips64vr5900el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64r2-* | mipsisa64r2el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipstx39-* | mipstx39el-* \
+ | mmix-* \
+ | mt-* \
+ | msp430-* \
+ | nios-* | nios2-* \
+ | none-* | np1-* | ns16k-* | ns32k-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+ | pyramid-* \
+ | romp-* | rs6000-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+ | sparclite-* \
+ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+ | tahoe-* | thumb-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+ | tron-* \
+ | v850-* | v850e-* | vax-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+ | xstormy16-* | xtensa-* \
+ | ymp-* \
+ | z8k-*)
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ abacus)
+ basic_machine=abacus-unknown
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amd64)
+ basic_machine=x86_64-pc
+ ;;
+ amd64-*)
+ basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-unknown
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | j90)
+ basic_machine=j90-cray
+ os=-unicos
+ ;;
+ craynv)
+ basic_machine=craynv-cray
+ os=-unicosmp
+ ;;
+ cr16c)
+ basic_machine=cr16c-unknown
+ os=-elf
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ crisv32 | crisv32-* | etraxfs*)
+ basic_machine=crisv32-axis
+ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
+ crx)
+ basic_machine=crx-unknown
+ os=-elf
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ decsystem10* | dec10*)
+ basic_machine=pdp10-dec
+ os=-tops10
+ ;;
+ decsystem20* | dec20*)
+ basic_machine=pdp10-dec
+ os=-tops20
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ os=-msdosdjgpp
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i*86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i*86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i*86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i*86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ mingw32)
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
+ ms1-*)
+ basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ openrisc | openrisc-*)
+ basic_machine=or32-unknown
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ os=-os400
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pc98)
+ basic_machine=i386-pc
+ ;;
+ pc98-*)
+ basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium | p5 | k5 | k6 | nexgen | viac3)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon | athlon_*)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2 | pentiumiii | pentium3)
+ basic_machine=i686-pc
+ ;;
+ pentium4)
+ basic_machine=i786-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium4-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=power-ibm
+ ;;
+ ppc) basic_machine=powerpc-unknown
+ ;;
+ ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64) basic_machine=powerpc64-unknown
+ ;;
+ ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
+ rdos)
+ basic_machine=i386-pc
+ os=-rdos
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ s390 | s390-*)
+ basic_machine=s390-ibm
+ ;;
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sb1)
+ basic_machine=mipsisa64sb1-unknown
+ ;;
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
+ ;;
+ sde)
+ basic_machine=mipsisa32-sde
+ os=-elf
+ ;;
+ sei)
+ basic_machine=mips-sei
+ os=-seiux
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparclite-wrs | simso-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ os=-unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
+ tic54x | c54x*)
+ basic_machine=tic54x-unknown
+ os=-coff
+ ;;
+ tic55x | c55x*)
+ basic_machine=tic55x-unknown
+ os=-coff
+ ;;
+ tic6x | c6x*)
+ basic_machine=tic6x-unknown
+ os=-coff
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ tpf)
+ basic_machine=s390x-ibm
+ os=-tpf
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ xbox)
+ basic_machine=i686-pc
+ os=-mingw32
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ mmix)
+ basic_machine=mmix-knuth
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-unknown
+ ;;
+ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+ | -openbsd* | -solidbsd* \
+ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+ | -skyos* | -haiku* | -rdos* | -toppers*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto-qnx*)
+ ;;
+ -nto*)
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux-dietlibc)
+ os=-linux-dietlibc
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -os400*)
+ os=-os400
+ ;;
+ -wince*)
+ os=-wince
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -atheos*)
+ os=-atheos
+ ;;
+ -syllable*)
+ os=-syllable
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -nova*)
+ os=-rtmk-nova
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -tpf*)
+ os=-tpf
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
+ ;;
+ -aros*)
+ os=-aros
+ ;;
+ -kaos*)
+ os=-kaos
+ ;;
+ -zvmoe)
+ os=-zvmoe
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ score-*)
+ os=-elf
+ ;;
+ spu-*)
+ os=-elf
+ ;;
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=-tops20
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ or32-*)
+ os=-coff
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-haiku)
+ os=-haiku
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-knuth)
+ os=-mmixware
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -os400*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -tpf*)
+ vendor=ibm
+ ;;
+ -vxsim* | -vxworks* | -windiss*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ vendor=atari
+ ;;
+ -vos*)
+ vendor=stratus
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/payloads/libpayload/curses/PDCurses-3.4/configure b/payloads/libpayload/curses/PDCurses-3.4/configure
new file mode 100755
index 0000000000..2d094bc4be
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/configure
@@ -0,0 +1,6738 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.61 for PDCurses 3.4.
+#
+# Report bugs to <wmcbrine@users.sf.net>.
+#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in
+ *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+as_nl='
+'
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ { (exit 1); exit 1; }
+fi
+
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# CDPATH.
+$as_unset CDPATH
+
+
+if test "x$CONFIG_SHELL" = x; then
+ if (eval ":") 2>/dev/null; then
+ as_have_required=yes
+else
+ as_have_required=no
+fi
+
+ if test $as_have_required = yes && (eval ":
+(as_func_return () {
+ (exit \$1)
+}
+as_func_success () {
+ as_func_return 0
+}
+as_func_failure () {
+ as_func_return 1
+}
+as_func_ret_success () {
+ return 0
+}
+as_func_ret_failure () {
+ return 1
+}
+
+exitcode=0
+if as_func_success; then
+ :
+else
+ exitcode=1
+ echo as_func_success failed.
+fi
+
+if as_func_failure; then
+ exitcode=1
+ echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+ :
+else
+ exitcode=1
+ echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+ exitcode=1
+ echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+ :
+else
+ exitcode=1
+ echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0) || { (exit 1); exit 1; }
+
+(
+ as_lineno_1=\$LINENO
+ as_lineno_2=\$LINENO
+ test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
+ test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
+") 2> /dev/null; then
+ :
+else
+ as_candidate_shells=
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ case $as_dir in
+ /*)
+ for as_base in sh bash ksh sh5; do
+ as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
+ done;;
+ esac
+done
+IFS=$as_save_IFS
+
+
+ for as_shell in $as_candidate_shells $SHELL; do
+ # Try only shells that exist, to save several forks.
+ if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+ { ("$as_shell") 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in
+ *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+_ASEOF
+}; then
+ CONFIG_SHELL=$as_shell
+ as_have_required=yes
+ if { "$as_shell" 2> /dev/null <<\_ASEOF
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in
+ *posix*) set -o posix ;;
+esac
+
+fi
+
+
+:
+(as_func_return () {
+ (exit $1)
+}
+as_func_success () {
+ as_func_return 0
+}
+as_func_failure () {
+ as_func_return 1
+}
+as_func_ret_success () {
+ return 0
+}
+as_func_ret_failure () {
+ return 1
+}
+
+exitcode=0
+if as_func_success; then
+ :
+else
+ exitcode=1
+ echo as_func_success failed.
+fi
+
+if as_func_failure; then
+ exitcode=1
+ echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+ :
+else
+ exitcode=1
+ echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+ exitcode=1
+ echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = "$1" ); then
+ :
+else
+ exitcode=1
+ echo positional parameters were not saved.
+fi
+
+test $exitcode = 0) || { (exit 1); exit 1; }
+
+(
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
+
+_ASEOF
+}; then
+ break
+fi
+
+fi
+
+ done
+
+ if test "x$CONFIG_SHELL" != x; then
+ for as_var in BASH_ENV ENV
+ do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+ done
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+fi
+
+
+ if test $as_have_required = no; then
+ echo This script requires a shell more modern than all the
+ echo shells that I found on your system. Please install a
+ echo modern shell, or manually run the script under such a
+ echo shell if you do have one.
+ { (exit 1); exit 1; }
+fi
+
+
+fi
+
+fi
+
+
+
+(eval "as_func_return () {
+ (exit \$1)
+}
+as_func_success () {
+ as_func_return 0
+}
+as_func_failure () {
+ as_func_return 1
+}
+as_func_ret_success () {
+ return 0
+}
+as_func_ret_failure () {
+ return 1
+}
+
+exitcode=0
+if as_func_success; then
+ :
+else
+ exitcode=1
+ echo as_func_success failed.
+fi
+
+if as_func_failure; then
+ exitcode=1
+ echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+ :
+else
+ exitcode=1
+ echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+ exitcode=1
+ echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+ :
+else
+ exitcode=1
+ echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0") || {
+ echo No shell found that supports shell functions.
+ echo Please tell autoconf@gnu.org about your system,
+ echo including any error possibly output before this
+ echo message
+}
+
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line after each line using $LINENO; the second 'sed'
+ # does the real work. The second script uses 'N' to pair each
+ # line-number line with the line containing $LINENO, and appends
+ # trailing '-' during substitution so that $LINENO is not a special
+ # case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # scripts with optimization help from Paolo Bonzini. Blame Lee
+ # E. McMahon (1931-1989) for sed's syntax. :-)
+ sed -n '
+ p
+ /[$]LINENO/=
+ ' <$as_myself |
+ sed '
+ s/[$]LINENO.*/&-/
+ t lineno
+ b
+ :lineno
+ N
+ :loop
+ s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+ t loop
+ s/-\n.*//
+ ' >$as_me.lineno &&
+ chmod +x "$as_me.lineno" ||
+ { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensitive to this).
+ . "./$as_me.lineno"
+ # Exit status is that of the last command.
+ exit
+}
+
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+ case `echo 'x\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ *) ECHO_C='\c';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir
+fi
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -p'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -p'
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+ as_test_x='test -x'
+else
+ if ls -dL / >/dev/null 2>&1; then
+ as_ls_L_option=L
+ else
+ as_ls_L_option=
+ fi
+ as_test_x='
+ eval sh -c '\''
+ if test -d "$1"; then
+ test -d "$1/.";
+ else
+ case $1 in
+ -*)set "./$1";;
+ esac;
+ case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+ ???[sx]*):;;*)false;;esac;fi
+ '\'' sh
+ '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+
+exec 7<&0 </dev/null 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Identity of this package.
+PACKAGE_NAME='PDCurses'
+PACKAGE_TARNAME='PDCurses'
+PACKAGE_VERSION='3.4'
+PACKAGE_STRING='PDCurses 3.4'
+PACKAGE_BUGREPORT='wmcbrine@users.sf.net'
+
+ac_unique_file="curspriv.h"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='SHELL
+PATH_SEPARATOR
+PACKAGE_NAME
+PACKAGE_TARNAME
+PACKAGE_VERSION
+PACKAGE_STRING
+PACKAGE_BUGREPORT
+exec_prefix
+prefix
+program_transform_name
+bindir
+sbindir
+libexecdir
+datarootdir
+datadir
+sysconfdir
+sharedstatedir
+localstatedir
+includedir
+oldincludedir
+docdir
+infodir
+htmldir
+dvidir
+pdfdir
+psdir
+libdir
+localedir
+mandir
+DEFS
+ECHO_C
+ECHO_N
+ECHO_T
+LIBS
+build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+CPPFLAGS
+ac_ct_CC
+EXEEXT
+OBJEXT
+build
+build_cpu
+build_vendor
+build_os
+host
+host_cpu
+host_vendor
+host_os
+target
+target_cpu
+target_vendor
+target_os
+SYS_DEFS
+RANLIB
+INSTALL_PROGRAM
+INSTALL_SCRIPT
+INSTALL_DATA
+SET_MAKE
+CPP
+GREP
+EGREP
+MH_EXTRA_LIBS
+XMKMF
+MH_XINC_DIR
+MH_XLIBS
+PURIFY
+SHLPST
+DYN_COMP
+LD_RXLIB1
+SHLPRE
+SHL_TARGETS
+O2SAVE
+CC2O
+SAVE2O
+RXPACKEXPORTS
+LIBOBJS
+LTLIBOBJS'
+ac_subst_files=''
+ ac_precious_vars='build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CPP
+XMKMF'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval $ac_prev=\$ac_option
+ ac_prev=
+ continue
+ fi
+
+ case $ac_option in
+ *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+ *) ac_optarg=yes ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case $ac_dashdash$ac_option in
+ --)
+ ac_dashdash=yes ;;
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file=$ac_optarg ;;
+
+ --config-cache | -C)
+ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=*)
+ datadir=$ac_optarg ;;
+
+ -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+ | --dataroo | --dataro | --datar)
+ ac_prev=datarootdir ;;
+ -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+ datarootdir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'`
+ eval enable_$ac_feature=no ;;
+
+ -docdir | --docdir | --docdi | --doc | --do)
+ ac_prev=docdir ;;
+ -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+ docdir=$ac_optarg ;;
+
+ -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+ ac_prev=dvidir ;;
+ -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+ dvidir=$ac_optarg ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'`
+ eval enable_$ac_feature=\$ac_optarg ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he | -h)
+ ac_init_help=long ;;
+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+ ac_init_help=recursive ;;
+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host_alias=$ac_optarg ;;
+
+ -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+ ac_prev=htmldir ;;
+ -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+ | --ht=*)
+ htmldir=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir=$ac_optarg ;;
+
+ -localedir | --localedir | --localedi | --localed | --locale)
+ ac_prev=localedir ;;
+ -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+ localedir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst | --locals)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c | -n)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name=$ac_optarg ;;
+
+ -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+ ac_prev=pdfdir ;;
+ -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+ pdfdir=$ac_optarg ;;
+
+ -psdir | --psdir | --psdi | --psd | --ps)
+ ac_prev=psdir ;;
+ -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+ psdir=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers | -V)
+ ac_init_version=: ;;
+
+ -with-* | --with-*)
+ ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package | sed 's/[-.]/_/g'`
+ eval with_$ac_package=\$ac_optarg ;;
+
+ -without-* | --without-*)
+ ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package | sed 's/[-.]/_/g'`
+ eval with_$ac_package=no ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+ -*) { echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; }
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+ { (exit 1); exit 1; }; }
+ eval $ac_envvar=\$ac_optarg
+ export $ac_envvar ;;
+
+ *)
+ # FIXME: should be removed in autoconf 3.0.
+ echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+ : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+ { echo "$as_me: error: missing argument to $ac_option" >&2
+ { (exit 1); exit 1; }; }
+fi
+
+# Be sure to have absolute directory names.
+for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
+ datadir sysconfdir sharedstatedir localstatedir includedir \
+ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+ libdir localedir mandir
+do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* ) continue;;
+ NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+ esac
+ { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; }
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+ echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+ If a cross compiler is detected then cross compile mode will be used." >&2
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+ { echo "$as_me: error: Working directory cannot be determined" >&2
+ { (exit 1); exit 1; }; }
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+ { echo "$as_me: error: pwd does not report name of working directory" >&2
+ { (exit 1); exit 1; }; }
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then the parent directory.
+ ac_confdir=`$as_dirname -- "$0" ||
+$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$0" : 'X\(//\)[^/]' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$0" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ srcdir=$ac_confdir
+ if test ! -r "$srcdir/$ac_unique_file"; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+ test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+ { (exit 1); exit 1; }; }
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+ cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2
+ { (exit 1); exit 1; }; }
+ pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+ srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+ eval ac_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_env_${ac_var}_value=\$${ac_var}
+ eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat <<_ACEOF
+\`configure' configures PDCurses 3.4 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print \`checking...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
+ --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
+ --infodir=DIR info documentation [DATAROOTDIR/info]
+ --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
+ --mandir=DIR man documentation [DATAROOTDIR/man]
+ --docdir=DIR documentation root [DATAROOTDIR/doc/PDCurses]
+ --htmldir=DIR html documentation [DOCDIR]
+ --dvidir=DIR dvi documentation [DOCDIR]
+ --pdfdir=DIR pdf documentation [DOCDIR]
+ --psdir=DIR ps documentation [DOCDIR]
+_ACEOF
+
+ cat <<\_ACEOF
+
+X features:
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+
+System types:
+ --build=BUILD configure for building on BUILD [guessed]
+ --host=HOST cross-compile to build programs to run on HOST [BUILD]
+ --target=TARGET configure for building compilers for TARGET [HOST]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+ case $ac_init_help in
+ short | recursive ) echo "Configuration of PDCurses 3.4:";;
+ esac
+ cat <<\_ACEOF
+
+Optional Features:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --enable-debug turn on debugging
+ --enable-widec include support for wide characters
+ --enable-xim include support for XIM
+ --enable-force-utf8 override locale settings; use UTF-8
+ --enable-purify link with Purify (TM)
+
+Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-x use the X Window System
+ --with-xaw3d link with Xaw3d
+ --with-nextaw link with neXtaw
+
+Some influential environment variables:
+ CC C compiler command
+ CFLAGS C compiler flags
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+ LIBS libraries to pass to the linker, e.g. -l<library>
+ CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
+ you have headers in a nonstandard directory <include dir>
+ CPP C preprocessor
+ XMKMF Path to xmkmf, Makefile generator for X Window System
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to <wmcbrine@users.sf.net>.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+ # If there are subdirs, report their specific --help.
+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+ test -d "$ac_dir" || continue
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+ cd "$ac_dir" || { ac_status=$?; continue; }
+ # Check for guested configure.
+ if test -f "$ac_srcdir/configure.gnu"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+ elif test -f "$ac_srcdir/configure"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure" --help=recursive
+ else
+ echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+ fi || ac_status=$?
+ cd "$ac_pwd" || { ac_status=$?; break; }
+ done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+ cat <<\_ACEOF
+PDCurses configure 3.4
+generated by GNU Autoconf 2.61
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+ exit
+fi
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by PDCurses $as_me 3.4, which was
+generated by GNU Autoconf 2.61. Invocation command line was
+
+ $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
+
+/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ echo "PATH: $as_dir"
+done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+ for ac_arg
+ do
+ case $ac_arg in
+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ continue ;;
+ *\'*)
+ ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ case $ac_pass in
+ 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+ 2)
+ ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+ if test $ac_must_keep_next = true; then
+ ac_must_keep_next=false # Got value, back to normal.
+ else
+ case $ac_arg in
+ *=* | --config-cache | -C | -disable-* | --disable-* \
+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+ | -with-* | --with-* | -without-* | --without-* | --x)
+ case "$ac_configure_args0 " in
+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+ esac
+ ;;
+ -* ) ac_must_keep_next=true ;;
+ esac
+ fi
+ ac_configure_args="$ac_configure_args '$ac_arg'"
+ ;;
+ esac
+ done
+done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log. We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+ # Save into config.log some information that might help in debugging.
+ {
+ echo
+
+ cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+ echo
+ # The following way of writing the cache mishandles newlines in values,
+(
+ for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+ eval ac_val=\$$ac_var
+ case $ac_val in #(
+ *${as_nl}*)
+ case $ac_var in #(
+ *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
+echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ *) $as_unset $ac_var ;;
+ esac ;;
+ esac
+ done
+ (set) 2>&1 |
+ case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ sed -n \
+ "s/'\''/'\''\\\\'\'''\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+ ;; #(
+ *)
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+)
+ echo
+
+ cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_vars
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+
+ if test -n "$ac_subst_files"; then
+ cat <<\_ASBOX
+## ------------------- ##
+## File substitutions. ##
+## ------------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_files
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+ fi
+
+ if test -s confdefs.h; then
+ cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+ echo
+ cat confdefs.h
+ echo
+ fi
+ test "$ac_signal" != 0 &&
+ echo "$as_me: caught signal $ac_signal"
+ echo "$as_me: exit $exit_status"
+ } >&5
+ rm -f core *.core core.conftest.* &&
+ rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+ exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+ trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer explicitly selected file to automatically selected ones.
+if test -n "$CONFIG_SITE"; then
+ set x "$CONFIG_SITE"
+elif test "x$prefix" != xNONE; then
+ set x "$prefix/share/config.site" "$prefix/etc/config.site"
+else
+ set x "$ac_default_prefix/share/config.site" \
+ "$ac_default_prefix/etc/config.site"
+fi
+shift
+for ac_site_file
+do
+ if test -r "$ac_site_file"; then
+ { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+echo "$as_me: loading site script $ac_site_file" >&6;}
+ sed 's/^/| /' "$ac_site_file" >&5
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ # Some versions of bash will fail to source /dev/null (special
+ # files actually), so we avoid doing that.
+ if test -f "$cache_file"; then
+ { echo "$as_me:$LINENO: loading cache $cache_file" >&5
+echo "$as_me: loading cache $cache_file" >&6;}
+ case $cache_file in
+ [\\/]* | ?:[\\/]* ) . "$cache_file";;
+ *) . "./$cache_file";;
+ esac
+ fi
+else
+ { echo "$as_me:$LINENO: creating cache $cache_file" >&5
+echo "$as_me: creating cache $cache_file" >&6;}
+ >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+ eval ac_old_set=\$ac_cv_env_${ac_var}_set
+ eval ac_new_set=\$ac_env_${ac_var}_set
+ eval ac_old_val=\$ac_cv_env_${ac_var}_value
+ eval ac_new_val=\$ac_env_${ac_var}_value
+ case $ac_old_set,$ac_new_set in
+ set,)
+ { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,set)
+ { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+ if test "x$ac_old_val" != "x$ac_new_val"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+echo "$as_me: former value: $ac_old_val" >&2;}
+ { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
+echo "$as_me: current value: $ac_new_val" >&2;}
+ ac_cache_corrupted=:
+ fi;;
+ esac
+ # Pass precious variables to config.status.
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+ *) ac_arg=$ac_var=$ac_new_val ;;
+ esac
+ case " $ac_configure_args " in
+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
+ *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ esac
+ fi
+done
+if $ac_cache_corrupted; then
+ { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+ { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_ac_ct_CC="gcc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet. If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet. If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+ fi
+fi
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# != 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+ fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in cl.exe
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+ test -n "$CC" && break
+ done
+fi
+if test -z "$CC"; then
+ ac_ct_CC=$CC
+ for ac_prog in cl.exe
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+ test -n "$ac_ct_CC" && break
+done
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet. If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet. If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+fi
+
+fi
+
+
+test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+
+# Provide some information about the compiler.
+echo "$as_me:$LINENO: checking for C compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (ac_try="$ac_compiler --version >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compiler --version >&5") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compiler -v >&5") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compiler -V >&5") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
+echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; }
+ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+#
+# List of possible output files, starting from the most likely.
+# The algorithm is not robust to junk in `.', hence go to wildcards (a.*)
+# only as a last resort. b.out is created by i960 compilers.
+ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out'
+#
+# The IRIX 6 linker writes into existing files which may not be
+# executable, retaining their permissions. Remove them first so a
+# subsequent execution test works.
+ac_rmfiles=
+for ac_file in $ac_files
+do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
+ * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+ esac
+done
+rm -f $ac_rmfiles
+
+if { (ac_try="$ac_link_default"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link_default") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile. We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj )
+ ;;
+ [ab].out )
+ # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* )
+ if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+ then :; else
+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ fi
+ # We set ac_cv_exeext here because the later test for it is not
+ # safe: cross compilers may not add the suffix if given an `-o'
+ # argument, so we may need to know it at that point already.
+ # Even if this section looks crufty: it has the advantage of
+ # actually working.
+ break;;
+ * )
+ break;;
+ esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+ ac_file=''
+fi
+
+{ echo "$as_me:$LINENO: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6; }
+if test -z "$ac_file"; then
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
+See \`config.log' for more details." >&5
+echo "$as_me: error: C compiler cannot create executables
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+
+# Check that the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5
+echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; }
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+ if { ac_try='./$ac_file'
+ { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cross_compiling=no
+ else
+ if test "$cross_compiling" = maybe; then
+ cross_compiling=yes
+ else
+ { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ fi
+fi
+{ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+
+rm -f a.out a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+# Check that the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: result: $cross_compiling" >&5
+echo "${ECHO_T}$cross_compiling" >&6; }
+
+{ echo "$as_me:$LINENO: checking for suffix of executables" >&5
+echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; }
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ break;;
+ * ) break;;
+ esac
+done
+else
+ { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+echo "${ECHO_T}$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+{ echo "$as_me:$LINENO: checking for suffix of object files" >&5
+echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; }
+if test "${ac_cv_objext+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ for ac_file in conftest.o conftest.obj conftest.*; do
+ test -f "$ac_file" || continue;
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;;
+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+ break;;
+ esac
+done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+echo "${ECHO_T}$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; }
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_compiler_gnu=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_compiler_gnu=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; }
+GCC=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; }
+if test "${ac_cv_prog_cc_g+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_save_c_werror_flag=$ac_c_werror_flag
+ ac_c_werror_flag=yes
+ ac_cv_prog_cc_g=no
+ CFLAGS="-g"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_prog_cc_g=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ CFLAGS=""
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_c_werror_flag=$ac_save_c_werror_flag
+ CFLAGS="-g"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_prog_cc_g=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
+echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
+ function prototypes and stuff, but not '\xHH' hex character constants.
+ These don't provoke an error unfortunately, instead are silently treated
+ as 'x'. The following induces an error, until -std is added to get
+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
+ array size at least. It's necessary to write '\x00'==0 to get something
+ that's true only with -std. */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+ inside strings and character constants. */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_prog_cc_c89=$ac_arg
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext
+ test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+ x)
+ { echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6; } ;;
+ xno)
+ { echo "$as_me:$LINENO: result: unsupported" >&5
+echo "${ECHO_T}unsupported" >&6; } ;;
+ *)
+ CC="$CC $ac_cv_prog_cc_c89"
+ { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ac_config_headers="$ac_config_headers config.h"
+
+ac_aux_dir=
+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+ if test -f "$ac_dir/install-sh"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f "$ac_dir/install.sh"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ elif test -f "$ac_dir/shtool"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/shtool install -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5
+echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
+
+
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+ { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5
+echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;}
+ { (exit 1); exit 1; }; }
+
+{ echo "$as_me:$LINENO: checking build system type" >&5
+echo $ECHO_N "checking build system type... $ECHO_C" >&6; }
+if test "${ac_cv_build+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+ ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+ { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
+echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+ { (exit 1); exit 1; }; }
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+ { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5
+echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_build" >&5
+echo "${ECHO_T}$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5
+echo "$as_me: error: invalid value of canonical build" >&2;}
+ { (exit 1); exit 1; }; };;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ echo "$as_me:$LINENO: checking host system type" >&5
+echo $ECHO_N "checking host system type... $ECHO_C" >&6; }
+if test "${ac_cv_host+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "x$host_alias" = x; then
+ ac_cv_host=$ac_cv_build
+else
+ ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+ { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5
+echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5
+echo "${ECHO_T}$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5
+echo "$as_me: error: invalid value of canonical host" >&2;}
+ { (exit 1); exit 1; }; };;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+{ echo "$as_me:$LINENO: checking target system type" >&5
+echo $ECHO_N "checking target system type... $ECHO_C" >&6; }
+if test "${ac_cv_target+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "x$target_alias" = x; then
+ ac_cv_target=$ac_cv_host
+else
+ ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
+ { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&5
+echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_target" >&5
+echo "${ECHO_T}$ac_cv_target" >&6; }
+case $ac_cv_target in
+*-*-*) ;;
+*) { { echo "$as_me:$LINENO: error: invalid value of canonical target" >&5
+echo "$as_me: error: invalid value of canonical target" >&2;}
+ { (exit 1); exit 1; }; };;
+esac
+target=$ac_cv_target
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_target
+shift
+target_cpu=$1
+target_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+target_os=$*
+IFS=$ac_save_IFS
+case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac
+
+
+# The aliases save the names the user supplied, while $host etc.
+# will get canonicalized.
+test -n "$target_alias" &&
+ test "$program_prefix$program_suffix$program_transform_name" = \
+ NONENONEs,x,x, &&
+ program_prefix=${target_alias}-
+
+mymakefile="Makefile"
+on_qnx=no
+case "$target" in
+ *hp-hpux*)
+ SYS_DEFS="-D_HPUX_SOURCE"
+ ;;
+ *ibm-aix*)
+ SYS_DEFS="-D_ALL_SOURCE"
+ mymakefile="Makefile.aix"
+ ;;
+ *dec-osf*)
+ SYS_DEFS="-D_XOPEN_SOURCE_EXTENDED"
+ ;;
+ *pc-sco*)
+ SYS_DEFS="-UM_XENIX -b elf"
+ ;;
+ *qnx*)
+ on_qnx=yes
+ SYS_DEFS="-Q"
+ ;;
+ *)
+ ;;
+esac
+
+
+
+save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $SYS_DEFS"
+{ echo "$as_me:$LINENO: checking for maximum signal specifier:" >&5
+echo $ECHO_N "checking for maximum signal specifier:... $ECHO_C" >&6; }
+if test "${mh_cv_max_signals+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ mh_found="no"
+for mh_sigs in NSIG __sys_nsig; do
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <signal.h>
+int
+main ()
+{
+return $mh_sigs;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ mh_found="yes"; mh_cv_max_signals="$mh_sigs"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ if test "$mh_found" = "yes"; then
+ break;
+ fi
+done
+fi
+
+CPPFLAGS="$save_CPPFLAGS"
+if test "$mh_found" = "no"; then
+ { { echo "$as_me:$LINENO: error: Cannot find a system limit for number of signals. PDCurses cannot be configured on this machine." >&5
+echo "$as_me: error: Cannot find a system limit for number of signals. PDCurses cannot be configured on this machine." >&2;}
+ { (exit 1); exit 1; }; }
+else
+ cat >>confdefs.h <<_ACEOF
+#define PDC_MAX_SIGNALS $mh_cv_max_signals
+_ACEOF
+
+ { echo "$as_me:$LINENO: result: $mh_cv_max_signals" >&5
+echo "${ECHO_T}$mh_cv_max_signals" >&6; }
+fi
+
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_RANLIB+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+ { echo "$as_me:$LINENO: result: $RANLIB" >&5
+echo "${ECHO_T}$RANLIB" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+ ac_ct_RANLIB=$RANLIB
+ # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_RANLIB"; then
+ ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_ac_ct_RANLIB="ranlib"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+ { echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
+echo "${ECHO_T}$ac_ct_RANLIB" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+ if test "x$ac_ct_RANLIB" = x; then
+ RANLIB=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet. If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet. If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+ RANLIB=$ac_ct_RANLIB
+ fi
+else
+ RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; }
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+ ./ | .// | /cC/* | \
+ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
+ /usr/ucb/* ) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+ if test $ac_prog = install &&
+ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ elif test $ac_prog = install &&
+ grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # program-specific install script used by HP pwplus--don't use.
+ :
+ else
+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+ break 3
+ fi
+ fi
+ done
+ done
+ ;;
+esac
+done
+IFS=$as_save_IFS
+
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL=$ac_cv_path_install
+ else
+ # As a last resort, use the slow shell script. Don't cache a
+ # value for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the value is a relative name.
+ INSTALL=$ac_install_sh
+ fi
+fi
+{ echo "$as_me:$LINENO: result: $INSTALL" >&5
+echo "${ECHO_T}$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+{ echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; }
+set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+ @echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+ *@@@%%%=?*=@@@%%%*)
+ eval ac_cv_prog_make_${ac_make}_set=yes;;
+ *)
+ eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+ SET_MAKE=
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if test "${ac_cv_prog_CPP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+{ echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ :
+else
+ { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
+echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; }
+if test "${ac_cv_path_GREP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # Extract the first word of "grep ggrep" to use in msg output
+if test -z "$GREP"; then
+set dummy grep ggrep; ac_prog_name=$2
+if test "${ac_cv_path_GREP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_path_GREP_found=false
+# Loop through the user's path and test for each of PROGNAME-LIST
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in grep ggrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+ { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+ # Check for GNU ac_path_GREP and select it if it is found.
+ # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+ ac_count=0
+ echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ echo 'GREP' >> "conftest.nl"
+ "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ ac_count=`expr $ac_count + 1`
+ if test $ac_count -gt ${ac_path_GREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_GREP="$ac_path_GREP"
+ ac_path_GREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+
+ $ac_path_GREP_found && break 3
+ done
+done
+
+done
+IFS=$as_save_IFS
+
+
+fi
+
+GREP="$ac_cv_path_GREP"
+if test -z "$GREP"; then
+ { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+else
+ ac_cv_path_GREP=$GREP
+fi
+
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
+echo "${ECHO_T}$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6; }
+if test "${ac_cv_path_EGREP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+ then ac_cv_path_EGREP="$GREP -E"
+ else
+ # Extract the first word of "egrep" to use in msg output
+if test -z "$EGREP"; then
+set dummy egrep; ac_prog_name=$2
+if test "${ac_cv_path_EGREP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_path_EGREP_found=false
+# Loop through the user's path and test for each of PROGNAME-LIST
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in egrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+ { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+ # Check for GNU ac_path_EGREP and select it if it is found.
+ # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+ ac_count=0
+ echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ echo 'EGREP' >> "conftest.nl"
+ "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ ac_count=`expr $ac_count + 1`
+ if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_EGREP="$ac_path_EGREP"
+ ac_path_EGREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+
+ $ac_path_EGREP_found && break 3
+ done
+done
+
+done
+IFS=$as_save_IFS
+
+
+fi
+
+EGREP="$ac_cv_path_EGREP"
+if test -z "$EGREP"; then
+ { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+else
+ ac_cv_path_EGREP=$EGREP
+fi
+
+
+ fi
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
+echo "${ECHO_T}$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_header_stdc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_header_stdc=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then
+ :
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ return 2;
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ eval "$as_ac_Header=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_Header=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+ { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+if test "${ac_cv_header_sys_ipc_h+set}" = set; then
+ { echo "$as_me:$LINENO: checking for sys/ipc.h" >&5
+echo $ECHO_N "checking for sys/ipc.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_sys_ipc_h+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_sys_ipc_h" >&5
+echo "${ECHO_T}$ac_cv_header_sys_ipc_h" >&6; }
+else
+ # Is the header compilable?
+{ echo "$as_me:$LINENO: checking sys/ipc.h usability" >&5
+echo $ECHO_N "checking sys/ipc.h usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <sys/ipc.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking sys/ipc.h presence" >&5
+echo $ECHO_N "checking sys/ipc.h presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/ipc.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: sys/ipc.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: sys/ipc.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: sys/ipc.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: sys/ipc.h: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: sys/ipc.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: sys/ipc.h: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: sys/ipc.h: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: sys/ipc.h: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: sys/ipc.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: sys/ipc.h: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: sys/ipc.h: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: sys/ipc.h: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: sys/ipc.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: sys/ipc.h: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: sys/ipc.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: sys/ipc.h: in the future, the compiler will take precedence" >&2;}
+ ( cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to wmcbrine@users.sf.net ##
+## ------------------------------------ ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+{ echo "$as_me:$LINENO: checking for sys/ipc.h" >&5
+echo $ECHO_N "checking for sys/ipc.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_sys_ipc_h+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_header_sys_ipc_h=$ac_header_preproc
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_sys_ipc_h" >&5
+echo "${ECHO_T}$ac_cv_header_sys_ipc_h" >&6; }
+
+fi
+
+
+if test $ac_cv_header_sys_ipc_h = no; then
+ { { echo "$as_me:$LINENO: error: Cannot find required header file sys/ipc.h; PDCurses cannot be configured" >&5
+echo "$as_me: error: Cannot find required header file sys/ipc.h; PDCurses cannot be configured" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+
+if test $ac_cv_header_stdc != yes; then
+ { { echo "$as_me:$LINENO: error: Need ANSI C headers" >&5
+echo "$as_me: error: Need ANSI C headers" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+
+
+
+
+
+
+for ac_header in fcntl.h \
+ sys/time.h \
+ sys/select.h \
+ dlfcn.h \
+ dl.h
+
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+ { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+ # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ ( cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to wmcbrine@users.sf.net ##
+## ------------------------------------ ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+ { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+{ echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5
+echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6; }
+if test "${ac_cv_header_time+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+
+int
+main ()
+{
+if ((struct tm *) 0)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_header_time=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_header_time=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5
+echo "${ECHO_T}$ac_cv_header_time" >&6; }
+if test $ac_cv_header_time = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define TIME_WITH_SYS_TIME 1
+_ACEOF
+
+fi
+
+
+MH_EXTRA_LIBS=''
+for mh_lib in socket nls; do
+ if test "$on_qnx" = yes; then
+ { echo "$as_me:$LINENO: checking for library -l${mh_lib}" >&5
+echo $ECHO_N "checking for library -l${mh_lib}... $ECHO_C" >&6; }
+ if test -r /usr/lib/${mh_lib}3r.lib; then
+ { echo "$as_me:$LINENO: result: found" >&5
+echo "${ECHO_T}found" >&6; }
+ MH_EXTRA_LIBS="${MH_EXTRA_LIBS} -l${mh_lib}"
+ else
+ { echo "$as_me:$LINENO: result: not found" >&5
+echo "${ECHO_T}not found" >&6; }
+ fi
+ else
+ as_ac_Lib=`echo "ac_cv_lib_$mh_lib''_main" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for main in -l$mh_lib" >&5
+echo $ECHO_N "checking for main in -l$mh_lib... $ECHO_C" >&6; }
+if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-l$mh_lib $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+
+int
+main ()
+{
+return main ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ eval "$as_ac_Lib=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_Lib=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+ac_res=`eval echo '${'$as_ac_Lib'}'`
+ { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_Lib'}'` = yes; then
+ mh_lib_found=yes
+else
+ mh_lib_found=no
+fi
+
+ if test "$mh_lib_found" = yes; then
+ MH_EXTRA_LIBS="${MH_EXTRA_LIBS} -l${mh_lib}"
+ fi
+ fi
+done
+
+
+
+{ echo "$as_me:$LINENO: checking whether $CC understand -c and -o together" >&5
+echo $ECHO_N "checking whether $CC understand -c and -o together... $ECHO_C" >&6; }
+set dummy $CC; ac_cc="`echo $2 |
+ sed -e 's/[^a-zA-Z0-9_]/_/g' -e 's/^[0-9]/_/'`"
+if { as_var=ac_cv_prog_cc_${ac_cc}_c_o; eval "test \"\${$as_var+set}\" = set"; }; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ echo 'foo(){}' > conftest.c
+# We do the test twice because some compilers refuse to overwrite an
+# existing .o file with -o, though they will create one.
+eval ac_cv_prog_cc_${ac_cc}_c_o=no
+ac_try='${CC-cc} -c conftest.c -o conftest.ooo 1>&5'
+if { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && test -f conftest.ooo && { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); };
+then
+ ac_try='${CC-cc} -c conftest.c -o conftest.ooo 1>&5'
+ if { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && test -f conftest.ooo && { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); };
+ then
+ eval ac_cv_prog_cc_${ac_cc}_c_o=yes
+ fi
+fi
+rm -f conftest*
+
+fi
+if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then
+ O2SAVE=""
+ SAVE2O=""
+ CC2O="-o $"'@'
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+else
+ O2SAVE="-mv \`basename "$'@'" .sho\`.o \`basename "$'@'" .sho\`.o.save;"
+ SAVE2O="-mv \`basename "$'@'" .sho\`.o "$'@'"; mv \`basename "$'@'" .sho\`.o.save \`basename "$'@'" .sho\`.o"
+ CC2O=""
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+{ echo "$as_me:$LINENO: checking return type of signal handlers" >&5
+echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6; }
+if test "${ac_cv_type_signal+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <signal.h>
+
+int
+main ()
+{
+return *(signal (0, 0)) (0) == 1;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_type_signal=int
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_type_signal=void
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5
+echo "${ECHO_T}$ac_cv_type_signal" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define RETSIGTYPE $ac_cv_type_signal
+_ACEOF
+
+
+
+
+
+
+for ac_func in vsscanf usleep poll vsnprintf
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+ { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+{ echo "$as_me:$LINENO: checking for X" >&5
+echo $ECHO_N "checking for X... $ECHO_C" >&6; }
+
+
+# Check whether --with-x was given.
+if test "${with_x+set}" = set; then
+ withval=$with_x;
+fi
+
+# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
+if test "x$with_x" = xno; then
+ # The user explicitly disabled X.
+ have_x=disabled
+else
+ case $x_includes,$x_libraries in #(
+ *\'*) { { echo "$as_me:$LINENO: error: Cannot use X directory names containing '" >&5
+echo "$as_me: error: Cannot use X directory names containing '" >&2;}
+ { (exit 1); exit 1; }; };; #(
+ *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # One or both of the vars are not set, and there is no cached value.
+ac_x_includes=no ac_x_libraries=no
+rm -f -r conftest.dir
+if mkdir conftest.dir; then
+ cd conftest.dir
+ cat >Imakefile <<'_ACEOF'
+incroot:
+ @echo incroot='${INCROOT}'
+usrlibdir:
+ @echo usrlibdir='${USRLIBDIR}'
+libdir:
+ @echo libdir='${LIBDIR}'
+_ACEOF
+ if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then
+ # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+ for ac_var in incroot usrlibdir libdir; do
+ eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`"
+ done
+ # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
+ for ac_extension in a so sl; do
+ if test ! -f "$ac_im_usrlibdir/libX11.$ac_extension" &&
+ test -f "$ac_im_libdir/libX11.$ac_extension"; then
+ ac_im_usrlibdir=$ac_im_libdir; break
+ fi
+ done
+ # Screen out bogus values from the imake configuration. They are
+ # bogus both because they are the default anyway, and because
+ # using them would break gcc on systems where it needs fixed includes.
+ case $ac_im_incroot in
+ /usr/include) ac_x_includes= ;;
+ *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
+ esac
+ case $ac_im_usrlibdir in
+ /usr/lib | /lib) ;;
+ *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
+ esac
+ fi
+ cd ..
+ rm -f -r conftest.dir
+fi
+
+# Standard set of common directories for X headers.
+# Check X11 before X11Rn because it is often a symlink to the current release.
+ac_x_header_dirs='
+/usr/X11/include
+/usr/X11R6/include
+/usr/X11R5/include
+/usr/X11R4/include
+
+/usr/include/X11
+/usr/include/X11R6
+/usr/include/X11R5
+/usr/include/X11R4
+
+/usr/local/X11/include
+/usr/local/X11R6/include
+/usr/local/X11R5/include
+/usr/local/X11R4/include
+
+/usr/local/include/X11
+/usr/local/include/X11R6
+/usr/local/include/X11R5
+/usr/local/include/X11R4
+
+/usr/X386/include
+/usr/x386/include
+/usr/XFree86/include/X11
+
+/usr/include
+/usr/local/include
+/usr/unsupported/include
+/usr/athena/include
+/usr/local/x11r5/include
+/usr/lpp/Xamples/include
+
+/usr/openwin/include
+/usr/openwin/share/include'
+
+if test "$ac_x_includes" = no; then
+ # Guess where to find include files, by looking for Xlib.h.
+ # First, try using that file with no special directory specified.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <X11/Xlib.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ # We can compile using X headers with no special include directory.
+ac_x_includes=
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ for ac_dir in $ac_x_header_dirs; do
+ if test -r "$ac_dir/X11/Xlib.h"; then
+ ac_x_includes=$ac_dir
+ break
+ fi
+done
+fi
+
+rm -f conftest.err conftest.$ac_ext
+fi # $ac_x_includes = no
+
+if test "$ac_x_libraries" = no; then
+ # Check for the libraries.
+ # See if we find them without any special options.
+ # Don't add to $LIBS permanently.
+ ac_save_LIBS=$LIBS
+ LIBS="-lX11 $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <X11/Xlib.h>
+int
+main ()
+{
+XrmInitialize ()
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ LIBS=$ac_save_LIBS
+# We can link X programs with no special library path.
+ac_x_libraries=
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ LIBS=$ac_save_LIBS
+for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
+do
+ # Don't even attempt the hair of trying to link an X program!
+ for ac_extension in a so sl; do
+ if test -r "$ac_dir/libX11.$ac_extension"; then
+ ac_x_libraries=$ac_dir
+ break 2
+ fi
+ done
+done
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+fi # $ac_x_libraries = no
+
+case $ac_x_includes,$ac_x_libraries in #(
+ no,* | *,no | *\'*)
+ # Didn't find X, or a directory has "'" in its name.
+ ac_cv_have_x="have_x=no";; #(
+ *)
+ # Record where we found X for the cache.
+ ac_cv_have_x="have_x=yes\
+ ac_x_includes='$ac_x_includes'\
+ ac_x_libraries='$ac_x_libraries'"
+esac
+fi
+;; #(
+ *) have_x=yes;;
+ esac
+ eval "$ac_cv_have_x"
+fi # $with_x != no
+
+if test "$have_x" != yes; then
+ { echo "$as_me:$LINENO: result: $have_x" >&5
+echo "${ECHO_T}$have_x" >&6; }
+ no_x=yes
+else
+ # If each of the values was on the command line, it overrides each guess.
+ test "x$x_includes" = xNONE && x_includes=$ac_x_includes
+ test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
+ # Update the cache value to reflect the command line values.
+ ac_cv_have_x="have_x=yes\
+ ac_x_includes='$x_includes'\
+ ac_x_libraries='$x_libraries'"
+ { echo "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" >&5
+echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6; }
+fi
+
+
+mh_x11_dir=""
+mh_x11_xaw_dir=""
+
+mh_inc_dirs="$ac_x_header_dirs"
+
+
+if test "x$x_includes" != xNONE ; then
+ mh_inc_dirs="$x_includes $mh_inc_dirs"
+fi
+
+
+for ac_dir in $mh_inc_dirs ; do
+ if test -r $ac_dir/Intrinsic.h; then
+ mh_x11_dir=$ac_dir
+ break
+ fi
+ if test -r $ac_dir/X11/Intrinsic.h; then
+ mh_x11_dir="$ac_dir/X11"
+ break
+ fi
+done
+
+
+if test "$with_xaw3d" = yes; then
+ mh_xaw_dir="Xaw3d"
+else
+ if test "$with_nextaw" = yes; then
+ mh_xaw_dir="neXtaw"
+ else
+ mh_xaw_dir="Xaw"
+ fi
+fi
+for ac_dir in $mh_inc_dirs ; do
+ if test -r $ac_dir/$mh_xaw_dir/Box.h; then
+ mh_x11_xaw_dir=$ac_dir
+ break
+ fi
+ if test -r $ac_dir/X11/$mh_xaw_dir/Box.h; then
+ mh_x11_xaw_dir="$ac_dir/X11"
+ break
+ fi
+done
+
+if test "x$mh_x11_dir" != "x" ; then
+ mh_x11_dir_no_x11=`echo $mh_x11_dir | sed 's/\/X11$//'`
+
+ if test "$mh_x11_dir_no_x11" != "$mh_x11_dir" ; then
+ MH_XINC_DIR="-I$mh_x11_dir -I$mh_x11_dir_no_x11"
+ else
+ MH_XINC_DIR="-I$mh_x11_dir"
+ fi
+else
+ { { echo "$as_me:$LINENO: error: Cannot find required header file Intrinsic.h; PDCurses cannot be configured" >&5
+echo "$as_me: error: Cannot find required header file Intrinsic.h; PDCurses cannot be configured" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+if test "x$mh_x11_xaw_dir" != "x"; then
+ if test "$mh_x11_xaw_dir" != "$mh_x11_dir" ; then
+ MH_XINC_DIR="-I$mh_x11_xaw_dir $MH_XINC_DIR"
+ fi
+else
+ { { echo "$as_me:$LINENO: error: Cannot find required Xaw header file Box.h; PDCurses cannot be configured" >&5
+echo "$as_me: error: Cannot find required Xaw header file Box.h; PDCurses cannot be configured" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+
+
+
+
+
+mh_solaris_flag=no
+mh_hpux9_flag=no
+
+case "$target" in
+ *solaris*)
+ mh_solaris_flag=yes
+ ;;
+ *pc-sco*)
+ extra_x_libs="Xext"
+ ;;
+ sparc*sunos*)
+ extra_x_libs="Xext"
+ if test "$ac_cv_prog_CC" = "gcc" ; then
+ extra_ld_flags="-Wl,-Bstatic"
+ extra_ld_flags2="-Wl,-Bdynamic"
+ else
+ extra_ld_flags="-Bstatic"
+ extra_ld_flags2="-Bdynamic"
+ fi
+ ;;
+ *hpux9*)
+ mh_hpux9_flag=yes
+ ;;
+esac
+
+if test "$with_xaw3d" = yes; then
+ MH_X11_LIBS="Xaw3d Xmu Xt X11"
+else
+ if test "$with_nextaw" = yes; then
+ MH_X11_LIBS="neXtaw Xmu Xt X11"
+ else
+ MH_X11_LIBS="Xaw Xmu Xt X11"
+ fi
+fi
+MH_X11R6_LIBS="SM ICE Xext"
+mh_x11r6=no
+
+mh_lib_dirs="$x_libraries `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`"
+
+for ac_dir in $mh_lib_dirs ; do
+ for mh_xsm in libSM.a libSM.so libSM.sl libSM.dylib; do
+ if test -r $ac_dir/$mh_xsm; then
+ mh_x11r6=yes
+ break 2
+ fi
+ done
+done
+
+if test "$mh_x11r6" = yes ; then
+ mh_libs="$MH_X11_LIBS $MH_X11R6_LIBS"
+else
+ mh_libs="$MH_X11_LIBS $extra_x_libs"
+fi
+
+
+
+mh_prev_dir=""
+mh_where_found=""
+mh_where_found_dirs=""
+mh_solaris_path=""
+for mh_lib in $mh_libs; do
+ mh_lib_found=no
+ for ac_dir in $mh_lib_dirs ; do
+ for mh_ext in a so sl dll.a dylib; do
+ if test -r $ac_dir/lib$mh_lib.$mh_ext; then
+ if test "x$mh_prev_dir" != "x$ac_dir" ; then
+ if test "x$mh_prev_dir" = "x" ; then
+ mh_where_found="$mh_where_found found in $ac_dir"
+ else
+ mh_where_found="$mh_where_found and in $ac_dir"
+ fi
+ mh_prev_dir=$ac_dir
+ mh_where_found_dirs="$mh_where_found_dirs $ac_dir"
+ MH_XLIBS="$MH_XLIBS -L$ac_dir"
+ mh_solaris_path="${mh_solaris_path}:$ac_dir"
+ fi
+ MH_XLIBS="$MH_XLIBS -l$mh_lib"
+ mh_lib_found=yes
+ break 2
+ fi
+ done
+ done
+ if test "$mh_lib_found" = no; then
+ { { echo "$as_me:$LINENO: error: Cannot find required X library; lib$mh_lib. PDCurses cannot be configured" >&5
+echo "$as_me: error: Cannot find required X library; lib$mh_lib. PDCurses cannot be configured" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+done
+
+mh_solaris_path=`echo $mh_solaris_path | sed 's/^://'`
+if test "$mh_solaris_flag" = yes ; then
+ MH_XLIBS="-R$mh_solaris_path $extra_ld_flags $MH_XLIBS $extra_libs $extra_ld_flags2"
+else
+ MH_XLIBS="$extra_ld_flags $MH_XLIBS $extra_libs $extra_ld_flags2"
+fi
+if test "$mh_hpux9_flag" = yes ; then
+ grep -q XtSetLanguageProc $mh_x11_dir/Intrinsic.h
+ if test $? -eq 0 ; then
+ mh_found_xtshellstrings=no
+ for mh_acdir in $mh_where_found_dirs ; do
+ for mh_xaw in `ls $mh_acdir/libXaw.*` ; do
+ nm $mh_xaw | grep XtShellStrings | grep -qv extern
+ if test $? -eq 0 ; then
+ mh_found_xtshellstrings=yes
+ fi
+ done
+ done
+ if test "$mh_found_xtshellstrings" = no ; then
+ { echo "$as_me:$LINENO: WARNING: The X11 development environment has not been installed correctly." >&5
+echo "$as_me: WARNING: The X11 development environment has not been installed correctly." >&2;}
+ { echo "$as_me:$LINENO: WARNING: The header file; Intrinsic.h" >&5
+echo "$as_me: WARNING: The header file; Intrinsic.h" >&2;}
+ { echo "$as_me:$LINENO: WARNING: Set library; libXaw is for X11R4. This is a common problem with" >&5
+echo "$as_me: WARNING: Set library; libXaw is for X11R4. This is a common problem with" >&2;}
+ { echo "$as_me:$LINENO: WARNING: HP-UX 9.x." >&5
+echo "$as_me: WARNING: HP-UX 9.x." >&2;}
+ { { echo "$as_me:$LINENO: error: X11 installation incomplete; cannot continue" >&5
+echo "$as_me: error: X11 installation incomplete; cannot continue" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ fi
+fi
+
+
+
+
+
+save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $MH_XINC_DIR"
+for mh_header in DECkeysym.h Sunkeysym.h xpm.h; do
+
+for ac_header in $mh_header
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+ { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+ # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ ( cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to wmcbrine@users.sf.net ##
+## ------------------------------------ ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+ { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+done
+CPPFLAGS="$save_CPPFLAGS"
+
+
+save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $MH_XINC_DIR"
+for mh_keydef in XK_KP_Delete XK_KP_Insert XK_KP_End XK_KP_Down XK_KP_Next \
+ XK_KP_Left XK_KP_Right XK_KP_Home XK_KP_Up XK_KP_Prior XK_KP_Begin; do
+ { echo "$as_me:$LINENO: checking for $mh_keydef in keysym.h" >&5
+echo $ECHO_N "checking for $mh_keydef in keysym.h... $ECHO_C" >&6; }
+ mh_upper_name="HAVE_`echo $mh_keydef | tr 'a-z' 'A-Z'`"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <keysym.h>
+int
+main ()
+{
+int i = $mh_keydef;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ mh_have_key=yes; cat >>confdefs.h <<_ACEOF
+#define $mh_upper_name 1
+_ACEOF
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ mh_have_key=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ { echo "$as_me:$LINENO: result: $mh_have_key" >&5
+echo "${ECHO_T}$mh_have_key" >&6; }
+done
+CPPFLAGS="$save_CPPFLAGS"
+
+
+save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $SYS_DEFS $MH_XINC_DIR"
+for td in XPointer ; do
+{ echo "$as_me:$LINENO: checking if $td is typedefed:" >&5
+echo $ECHO_N "checking if $td is typedefed:... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include "X11/Xlib.h"
+int
+main ()
+{
+$td fred
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ mh_td=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ mh_td=no
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+if test "$mh_td" = yes ; then
+ TD_upper=`echo $td | tr a-z A-Z`
+ cat >>confdefs.h <<_ACEOF
+#define ${TD_upper}_TYPEDEFED 1
+_ACEOF
+
+fi
+{ echo "$as_me:$LINENO: result: $mh_td" >&5
+echo "${ECHO_T}$mh_td" >&6; }
+done
+CPPFLAGS="$save_CPPFLAGS"
+
+if test $ac_cv_header_xpm_h = yes; then
+ MH_XLIBS="$MH_XLIBS -lXpm"
+fi
+# Check whether --enable-debug was given.
+if test "${enable_debug+set}" = set; then
+ enableval=$enable_debug; with_debug=$enableval
+else
+ with_debug=no
+fi
+
+cflags_g="`echo $CFLAGS | grep -c '\-g'`"
+cflags_O="`echo $CFLAGS | grep -c '\-O'`"
+
+if test "$with_debug" = yes; then
+ if test "$cflags_g" = "0"; then
+ CFLAGS="${CFLAGS} -g"
+ fi
+ if test "$cflags_O" != "0"; then
+ CFLAGS="`echo ${CFLAGS} | sed -e s/-O.//`"
+ fi
+ CFLAGS="${CFLAGS} -DPDCDEBUG"
+else
+ if test "$cflags_O" = "0"; then
+ CFLAGS="${CFLAGS} -O"
+ fi
+ if test "$cflags_g" != "0"; then
+ CFLAGS="`echo ${CFLAGS} | sed -e s/-g//`"
+ fi
+fi
+if test "$ac_cv_prog_CC" = "gcc"; then
+ if test "$with_debug" = yes; then
+ CFLAGS="${CFLAGS} -Wall"
+ else
+ CFLAGS="-O2 -Wall -fomit-frame-pointer"
+ fi
+fi
+if test "$on_qnx" = yes; then
+ if test "$with_debug" = yes; then
+ CFLAGS="-g"
+ else
+ CFLAGS="-Otax"
+ fi
+fi
+
+# Check whether --enable-widec was given.
+if test "${enable_widec+set}" = set; then
+ enableval=$enable_widec; with_widec=$enableval
+else
+ with_widec=no
+fi
+
+if test "$with_widec" = yes; then
+ SYS_DEFS="$SYS_DEFS -DPDC_WIDE"
+fi
+
+# Check whether --enable-xim was given.
+if test "${enable_xim+set}" = set; then
+ enableval=$enable_xim; with_xim=$enableval
+else
+ with_xim=no
+fi
+
+if test "$with_xim" = yes; then
+ SYS_DEFS="$SYS_DEFS -DPDC_XIM"
+fi
+
+# Check whether --enable-force-utf8 was given.
+if test "${enable_force_utf8+set}" = set; then
+ enableval=$enable_force_utf8; force_utf8=$enableval
+else
+ force_utf8=no
+fi
+
+if test "$force_utf8" = yes; then
+ SYS_DEFS="$SYS_DEFS -DPDC_FORCE_UTF8"
+fi
+
+# Check whether --enable-purify was given.
+if test "${enable_purify+set}" = set; then
+ enableval=$enable_purify; with_purify=$enableval
+else
+ with_purify=no
+fi
+
+if test "$with_purify" = yes; then
+ PURIFY="purify"
+else
+ PURIFY=""
+fi
+
+
+
+# Check whether --with-xaw3d was given.
+if test "${with_xaw3d+set}" = set; then
+ withval=$with_xaw3d; with_xaw3d=$withval
+else
+ with_xaw3d=no
+fi
+
+if test "$with_xaw3d" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define USE_XAW3D 1
+_ACEOF
+
+fi
+
+
+# Check whether --with-nextaw was given.
+if test "${with_nextaw+set}" = set; then
+ withval=$with_nextaw; with_nextaw=$withval
+else
+ with_nextaw=no
+fi
+
+if test "$with_nextaw" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define USE_NEXTAW 1
+_ACEOF
+
+fi
+
+
+{ echo "$as_me:$LINENO: checking shared library extension" >&5
+echo $ECHO_N "checking shared library extension... $ECHO_C" >&6; }
+SHLPST=".so"
+
+case "$target" in
+ *hp-hpux*)
+ SHLPST=".sl"
+ ;;
+ *ibm-aix*)
+ SHLPST=".a"
+ ;;
+ *qnx*)
+ SHLPST=""
+ ;;
+ *cygwin*)
+ SHLPST=".dll"
+ ;;
+ *darwin*)
+ SHLPST=".dylib"
+ ;;
+esac
+
+{ echo "$as_me:$LINENO: result: $SHLPST" >&5
+echo "${ECHO_T}$SHLPST" >&6; }
+
+
+
+AIX_DYN="no"
+BEOS_DYN="no"
+SHLFILE="XCurses"
+SHLFILES="XCurses"
+RXPACKEXPORTS=""
+SHLPRE="lib"
+LD_RXLIB1=""
+
+
+case "$target" in
+ *hp-hpux*)
+ SYS_DEFS="-D_HPUX_SOURCE"
+ LD_RXLIB1="ld -b -q -n"
+ ;;
+ *ibm-aix*)
+ SYS_DEFS="-D_ALL_SOURCE -DAIX"
+ AIX_DYN="yes"
+ DYN_COMP="-DDYNAMIC"
+ LD_RXLIB1="ld -bnoentry -bM:SRE"
+ RXPACKEXPORTS="-bE:$SHLFILE.exp"
+ RXPACKEXP="$SHLFILE.exp"
+ ;;
+ *dec-osf*)
+ if test "$ac_cv_prog_CC" = "gcc"; then
+ SYS_DEFS="-D_POSIX_SOURCE -D_XOPEN_SOURCE"
+ else
+ SYS_DEFS="-D_POSIX_SOURCE -D_XOPEN_SOURCE -Olimit 800"
+ fi
+ LD_RXLIB1="ld -shared"
+ ;;
+ *sequent-dynix*|*esix*|*dgux*)
+ LD_RXLIB1="ld -G"
+ ;;
+ *solaris*)
+ if test "$ac_cv_prog_CC" = "gcc"; then
+ LD_RXLIB1="gcc -shared"
+ else
+ LD_RXLIB1="ld -G"
+ fi
+ ;;
+ sparc*sunos*)
+ SYS_DEFS="-DSUNOS -DSUNOS_STRTOD_BUG"
+ LD_RXLIB1="ld"
+ ;;
+ *linux*|*atheos*|*nto-qnx*)
+ LD_RXLIB1="${CC} -shared"
+ ;;
+ *freebsd*)
+ LD_RXLIB1="ld -Bdynamic -Bshareable"
+ ;;
+ *pc-sco*)
+ LD_RXLIB1="ld -dy -G"
+ ;;
+ *beos*)
+ LD_RXLIB1="${CC} -Wl,-shared -nostart -Xlinker -soname=\$(@)"
+ BEOS_DYN="yes"
+ ;;
+ *qnx*)
+ SHLPRE=""
+ DYN_COMP="-Q" # force no check for dynamic loading
+ SHLFILE=""
+ ;;
+ *cygwin)
+ SHLPRE=""
+ DYN_COMP="-DDYNAMIC"
+ LD_RXLIB1="dllwrap --def \$(srcdir)/../win32/pdcurses.def --target i386-cygwin32 --dllname \$(@)"
+# cygwininstall target MUST install the shared library itself because
+# it puts it into $(bindir) not $(libdir) as all other platforms
+ ;;
+ *darwin*)
+ DYN_COMP="-fno-common"
+ LD_RXLIB1="${CC} -flat_namespace -undefined suppress -dynamiclib -install_name=\$(@)"
+ ;;
+ *)
+ ;;
+esac
+
+
+if test "$DYN_COMP" = ""; then
+{ echo "$as_me:$LINENO: checking compiler flags for a dynamic object" >&5
+echo $ECHO_N "checking compiler flags for a dynamic object... $ECHO_C" >&6; }
+
+cat > conftest.$ac_ext <<EOF
+#line 5368 "configure"
+int a=0
+EOF
+
+ DYN_COMP=""
+ mh_cv_stop=no
+ save_cflags="$CFLAGS"
+ mh_cv_flags="-fPIC -KPIC +Z"
+ for a in $mh_cv_flags; do
+ CFLAGS="-c $a"
+
+ mh_compile='${CC-cc} -c $CFLAGS conftest.$ac_ext > conftest.tmp 2>&1'
+ if { (eval echo "$as_me:$LINENO: \"$mh_compile\"") >&5
+ (eval $mh_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ DYN_COMP=""
+ else
+ slash="\\"
+ mh_dyncomp="`egrep -c $slash$a conftest.tmp`"
+ if test "$mh_dyncomp" = "0"; then
+ DYN_COMP="$a -DDYNAMIC"
+ { echo "$as_me:$LINENO: result: $a" >&5
+echo "${ECHO_T}$a" >&6; }
+ break
+ else
+ DYN_COMP=""
+ fi
+ fi
+ done
+ if test "$DYN_COMP" = ""; then
+ { echo "$as_me:$LINENO: result: none of $mh_cv_flags supported" >&5
+echo "${ECHO_T}none of $mh_cv_flags supported" >&6; }
+ fi
+ if test "$LD_RXLIB1" = ""; then
+
+mh_compile='${CC-cc} -c $DYN_COMP conftest.$ac_ext 1>&5'
+cat > conftest.$ac_ext <<EOF
+#line 5407 "configure"
+int foo()
+{
+return(0);
+}
+EOF
+if { (eval echo "$as_me:$LINENO: \"$mh_compile\"") >&5
+ (eval $mh_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && test -s conftest.o; then
+ mh_dyn_link='ld -shared -o conftest.rxlib conftest.o -lc 1>&5'
+# mh_dyn_link='${CC} -Wl,-shared -o conftest.rxlib conftest.o -lc 1>&AC_FD_CC'
+ if { (eval echo "$as_me:$LINENO: \"$mh_dyn_link\"") >&5
+ (eval $mh_dyn_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && test -s conftest.rxlib; then
+ LD_RXLIB1="ld -shared"
+# LD_RXLIB1="${CC} -Wl,-shared"
+ SHLPRE="lib"
+ SHLPST=".so"
+ else
+ mh_dyn_link='ld -G -o conftest.rxlib conftest.o 1>&5'
+# mh_dyn_link='${CC} -Wl,-G -o conftest.rxlib conftest.o 1>&AC_FD_CC'
+ if { (eval echo "$as_me:$LINENO: \"$mh_dyn_link\"") >&5
+ (eval $mh_dyn_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && test -s conftest.rxlib; then
+ LD_RXLIB1="ld -G"
+# LD_RXLIB1="${CC} -Wl,-G"
+ SHLPRE="lib"
+ SHLPST=".so"
+ else
+ LD_RXLIB1=""
+ SHLPRE=""
+ SHLPST=""
+ fi
+ fi
+fi
+rm -f conftest*
+
+ fi
+ CFLAGS=$save_cflags
+ rm -f conftest.*
+fi
+
+
+SHL_TARGETS=""
+
+if test "$AIX_DYN" = "yes"; then
+ aix_exports="config.exports.aix"
+ echo "" > $aix_exports
+fi
+
+if test "$ac_cv_header_dl_h" = "yes" -o "$ac_cv_header_dlfcn_h" = "yes" -o "$AIX_DYN" = "yes" -o "$BEOS_DYN" = "yes" -o "$DLFCNINCDIR" != "" -o "$DLFCNLIBDIR" != ""; then
+ EXPS="1,2,3,4,5,6,7,8,9"
+ for a in $SHLFILES
+ do
+ SHL_TARGETS="${SHL_TARGETS} ${SHLPRE}${a}${SHLPST}"
+ this=`echo $EXPS | cut -d, -f1`
+ EXPS=`echo $EXPS | cut -d, -f2-`
+ if test "$AIX_DYN" = "yes"; then
+ echo "RXPACKEXP$this=$a.exp" >> $aix_exports
+ echo "RXPACKEXPORTS$this=-bE:$a.exp" >> $aix_exports
+ fi
+ done
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+ac_config_files="$ac_config_files Makefile x11/$mymakefile x11/xcurses-config"
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+ for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+ eval ac_val=\$$ac_var
+ case $ac_val in #(
+ *${as_nl}*)
+ case $ac_var in #(
+ *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
+echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ *) $as_unset $ac_var ;;
+ esac ;;
+ esac
+ done
+
+ (set) 2>&1 |
+ case $as_nl`(ac_space=' '; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote
+ # substitution turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ "s/'/'\\\\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+ ;; #(
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+) |
+ sed '
+ /^ac_cv_env_/b end
+ t clear
+ :clear
+ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ t end
+ s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+ :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+ if test -w "$cache_file"; then
+ test "x$cache_file" != "x/dev/null" &&
+ { echo "$as_me:$LINENO: updating cache $cache_file" >&5
+echo "$as_me: updating cache $cache_file" >&6;}
+ cat confcache >$cache_file
+ else
+ { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
+echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+ fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+ ac_i=`echo "$ac_i" | sed "$ac_script"`
+ # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
+ # will be set to the directory where LIBOBJS objects are built.
+ ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+ ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+
+: ${CONFIG_STATUS=./config.status}
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in
+ *posix*) set -o posix ;;
+esac
+
+fi
+
+
+
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+as_nl='
+'
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ { (exit 1); exit 1; }
+fi
+
+# Work around bugs in pre-3.0 UWIN ksh.
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# CDPATH.
+$as_unset CDPATH
+
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line after each line using $LINENO; the second 'sed'
+ # does the real work. The second script uses 'N' to pair each
+ # line-number line with the line containing $LINENO, and appends
+ # trailing '-' during substitution so that $LINENO is not a special
+ # case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # scripts with optimization help from Paolo Bonzini. Blame Lee
+ # E. McMahon (1931-1989) for sed's syntax. :-)
+ sed -n '
+ p
+ /[$]LINENO/=
+ ' <$as_myself |
+ sed '
+ s/[$]LINENO.*/&-/
+ t lineno
+ b
+ :lineno
+ N
+ :loop
+ s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+ t loop
+ s/-\n.*//
+ ' >$as_me.lineno &&
+ chmod +x "$as_me.lineno" ||
+ { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensitive to this).
+ . "./$as_me.lineno"
+ # Exit status is that of the last command.
+ exit
+}
+
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+ case `echo 'x\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ *) ECHO_C='\c';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir
+fi
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -p'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -p'
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+ as_test_x='test -x'
+else
+ if ls -dL / >/dev/null 2>&1; then
+ as_ls_L_option=L
+ else
+ as_ls_L_option=
+ fi
+ as_test_x='
+ eval sh -c '\''
+ if test -d "$1"; then
+ test -d "$1/.";
+ else
+ case $1 in
+ -*)set "./$1";;
+ esac;
+ case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
+ ???[sx]*):;;*)false;;esac;fi
+ '\'' sh
+ '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+
+# Save the log message, to keep $[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by PDCurses $as_me 3.4, which was
+generated by GNU Autoconf 2.61. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTIONS] [FILE]...
+
+ -h, --help print this help, then exit
+ -V, --version print version number and configuration settings, then exit
+ -q, --quiet do not print progress messages
+ -d, --debug don't remove temporary files
+ --recheck update $as_me by reconfiguring in the same conditions
+ --file=FILE[:TEMPLATE]
+ instantiate the configuration file FILE
+ --header=FILE[:TEMPLATE]
+ instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Report bugs to <bug-autoconf@gnu.org>."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+ac_cs_version="\\
+PDCurses config.status 3.4
+configured by $0, generated by GNU Autoconf 2.61,
+ with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright (C) 2006 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If no file are specified by the user, then we need to provide default
+# value. By we need to know if files were specified by the user.
+ac_need_defaults=:
+while test $# != 0
+do
+ case $1 in
+ --*=*)
+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
+ ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+ ac_shift=:
+ ;;
+ *)
+ ac_option=$1
+ ac_optarg=$2
+ ac_shift=shift
+ ;;
+ esac
+
+ case $ac_option in
+ # Handling of the options.
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ ac_cs_recheck=: ;;
+ --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+ echo "$ac_cs_version"; exit ;;
+ --debug | --debu | --deb | --de | --d | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ $ac_shift
+ CONFIG_FILES="$CONFIG_FILES $ac_optarg"
+ ac_need_defaults=false;;
+ --header | --heade | --head | --hea )
+ $ac_shift
+ CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
+ ac_need_defaults=false;;
+ --he | --h)
+ # Conflict between --help and --header
+ { echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; };;
+ --help | --hel | -h )
+ echo "$ac_cs_usage"; exit ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil | --si | --s)
+ ac_cs_silent=: ;;
+
+ # This is an error.
+ -*) { echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; } ;;
+
+ *) ac_config_targets="$ac_config_targets $1"
+ ac_need_defaults=false ;;
+
+ esac
+ shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+ exec 6>/dev/null
+ ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+if \$ac_cs_recheck; then
+ echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
+ CONFIG_SHELL=$SHELL
+ export CONFIG_SHELL
+ exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+exec 5>>config.log
+{
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+ echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+ case $ac_config_target in
+ "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+ "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+ "x11/$mymakefile") CONFIG_FILES="$CONFIG_FILES x11/$mymakefile" ;;
+ "x11/xcurses-config") CONFIG_FILES="$CONFIG_FILES x11/xcurses-config" ;;
+
+ *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used. Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+ test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+fi
+
+# Have a temporary directory for convenience. Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+ tmp=
+ trap 'exit_status=$?
+ { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+' 0
+ trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+ tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+ test -n "$tmp" && test -d "$tmp"
+} ||
+{
+ tmp=./conf$$-$RANDOM
+ (umask 077 && mkdir "$tmp")
+} ||
+{
+ echo "$me: cannot create a temporary directory in ." >&2
+ { (exit 1); exit 1; }
+}
+
+#
+# Set up the sed scripts for CONFIG_FILES section.
+#
+
+# No need to generate the scripts if there are no CONFIG_FILES.
+# This happens for instance when ./config.status config.h
+if test -n "$CONFIG_FILES"; then
+
+_ACEOF
+
+
+
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+ cat >conf$$subs.sed <<_ACEOF
+SHELL!$SHELL$ac_delim
+PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim
+PACKAGE_NAME!$PACKAGE_NAME$ac_delim
+PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim
+PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim
+PACKAGE_STRING!$PACKAGE_STRING$ac_delim
+PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim
+exec_prefix!$exec_prefix$ac_delim
+prefix!$prefix$ac_delim
+program_transform_name!$program_transform_name$ac_delim
+bindir!$bindir$ac_delim
+sbindir!$sbindir$ac_delim
+libexecdir!$libexecdir$ac_delim
+datarootdir!$datarootdir$ac_delim
+datadir!$datadir$ac_delim
+sysconfdir!$sysconfdir$ac_delim
+sharedstatedir!$sharedstatedir$ac_delim
+localstatedir!$localstatedir$ac_delim
+includedir!$includedir$ac_delim
+oldincludedir!$oldincludedir$ac_delim
+docdir!$docdir$ac_delim
+infodir!$infodir$ac_delim
+htmldir!$htmldir$ac_delim
+dvidir!$dvidir$ac_delim
+pdfdir!$pdfdir$ac_delim
+psdir!$psdir$ac_delim
+libdir!$libdir$ac_delim
+localedir!$localedir$ac_delim
+mandir!$mandir$ac_delim
+DEFS!$DEFS$ac_delim
+ECHO_C!$ECHO_C$ac_delim
+ECHO_N!$ECHO_N$ac_delim
+ECHO_T!$ECHO_T$ac_delim
+LIBS!$LIBS$ac_delim
+build_alias!$build_alias$ac_delim
+host_alias!$host_alias$ac_delim
+target_alias!$target_alias$ac_delim
+CC!$CC$ac_delim
+CFLAGS!$CFLAGS$ac_delim
+LDFLAGS!$LDFLAGS$ac_delim
+CPPFLAGS!$CPPFLAGS$ac_delim
+ac_ct_CC!$ac_ct_CC$ac_delim
+EXEEXT!$EXEEXT$ac_delim
+OBJEXT!$OBJEXT$ac_delim
+build!$build$ac_delim
+build_cpu!$build_cpu$ac_delim
+build_vendor!$build_vendor$ac_delim
+build_os!$build_os$ac_delim
+host!$host$ac_delim
+host_cpu!$host_cpu$ac_delim
+host_vendor!$host_vendor$ac_delim
+host_os!$host_os$ac_delim
+target!$target$ac_delim
+target_cpu!$target_cpu$ac_delim
+target_vendor!$target_vendor$ac_delim
+target_os!$target_os$ac_delim
+SYS_DEFS!$SYS_DEFS$ac_delim
+RANLIB!$RANLIB$ac_delim
+INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim
+INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim
+INSTALL_DATA!$INSTALL_DATA$ac_delim
+SET_MAKE!$SET_MAKE$ac_delim
+CPP!$CPP$ac_delim
+GREP!$GREP$ac_delim
+EGREP!$EGREP$ac_delim
+MH_EXTRA_LIBS!$MH_EXTRA_LIBS$ac_delim
+XMKMF!$XMKMF$ac_delim
+MH_XINC_DIR!$MH_XINC_DIR$ac_delim
+MH_XLIBS!$MH_XLIBS$ac_delim
+PURIFY!$PURIFY$ac_delim
+SHLPST!$SHLPST$ac_delim
+DYN_COMP!$DYN_COMP$ac_delim
+LD_RXLIB1!$LD_RXLIB1$ac_delim
+SHLPRE!$SHLPRE$ac_delim
+SHL_TARGETS!$SHL_TARGETS$ac_delim
+O2SAVE!$O2SAVE$ac_delim
+CC2O!$CC2O$ac_delim
+SAVE2O!$SAVE2O$ac_delim
+RXPACKEXPORTS!$RXPACKEXPORTS$ac_delim
+LIBOBJS!$LIBOBJS$ac_delim
+LTLIBOBJS!$LTLIBOBJS$ac_delim
+_ACEOF
+
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 81; then
+ break
+ elif $ac_last_try; then
+ { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+ { (exit 1); exit 1; }; }
+ else
+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+ fi
+done
+
+ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed`
+if test -n "$ac_eof"; then
+ ac_eof=`echo "$ac_eof" | sort -nru | sed 1q`
+ ac_eof=`expr $ac_eof + 1`
+fi
+
+cat >>$CONFIG_STATUS <<_ACEOF
+cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end
+_ACEOF
+sed '
+s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g
+s/^/s,@/; s/!/@,|#_!!_#|/
+:n
+t n
+s/'"$ac_delim"'$/,g/; t
+s/$/\\/; p
+N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n
+' >>$CONFIG_STATUS <conf$$subs.sed
+rm -f conf$$subs.sed
+cat >>$CONFIG_STATUS <<_ACEOF
+:end
+s/|#_!!_#|//g
+CEOF$ac_eof
+_ACEOF
+
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[ ]*\):*/\1/
+s/:*$//
+s/^[^=]*=[ ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+fi # test -n "$CONFIG_FILES"
+
+
+for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS
+do
+ case $ac_tag in
+ :[FHLC]) ac_mode=$ac_tag; continue;;
+ esac
+ case $ac_mode$ac_tag in
+ :[FHL]*:*);;
+ :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5
+echo "$as_me: error: Invalid tag $ac_tag." >&2;}
+ { (exit 1); exit 1; }; };;
+ :[FH]-) ac_tag=-:-;;
+ :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+ esac
+ ac_save_IFS=$IFS
+ IFS=:
+ set x $ac_tag
+ IFS=$ac_save_IFS
+ shift
+ ac_file=$1
+ shift
+
+ case $ac_mode in
+ :L) ac_source=$1;;
+ :[FH])
+ ac_file_inputs=
+ for ac_f
+ do
+ case $ac_f in
+ -) ac_f="$tmp/stdin";;
+ *) # Look for the file first in the build tree, then in the source tree
+ # (if the path is not absolute). The absolute path cannot be DOS-style,
+ # because $ac_f cannot contain `:'.
+ test -f "$ac_f" ||
+ case $ac_f in
+ [\\/$]*) false;;
+ *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+ esac ||
+ { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
+echo "$as_me: error: cannot find input file: $ac_f" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+ ac_file_inputs="$ac_file_inputs $ac_f"
+ done
+
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ configure_input="Generated from "`IFS=:
+ echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure."
+ if test x"$ac_file" != x-; then
+ configure_input="$ac_file. $configure_input"
+ { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+ fi
+
+ case $ac_tag in
+ *:-:* | *:-) cat >"$tmp/stdin";;
+ esac
+ ;;
+ esac
+
+ ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ { as_dir="$ac_dir"
+ case $as_dir in #(
+ -*) as_dir=./$as_dir;;
+ esac
+ test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
+ as_dirs=
+ while :; do
+ case $as_dir in #(
+ *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #(
+ *) as_qdir=$as_dir;;
+ esac
+ as_dirs="'$as_qdir' $as_dirs"
+ as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ test -d "$as_dir" && break
+ done
+ test -z "$as_dirs" || eval "mkdir $as_dirs"
+ } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
+echo "$as_me: error: cannot create directory $as_dir" >&2;}
+ { (exit 1); exit 1; }; }; }
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+ case $ac_mode in
+ :F)
+ #
+ # CONFIG_FILE
+ #
+
+ case $INSTALL in
+ [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+ *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+ esac
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+
+case `sed -n '/datarootdir/ {
+ p
+ q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p
+' $ac_file_inputs` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+ { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+ ac_datarootdir_hack='
+ s&@datadir@&$datadir&g
+ s&@docdir@&$docdir&g
+ s&@infodir@&$infodir&g
+ s&@localedir@&$localedir&g
+ s&@mandir@&$mandir&g
+ s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF
+ sed "$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s&@configure_input@&$configure_input&;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+$ac_datarootdir_hack
+" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+ { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+ { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+ { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined." >&5
+echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined." >&2;}
+
+ rm -f "$tmp/stdin"
+ case $ac_file in
+ -) cat "$tmp/out"; rm -f "$tmp/out";;
+ *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;;
+ esac
+ ;;
+ :H)
+ #
+ # CONFIG_HEADER
+ #
+_ACEOF
+
+# Transform confdefs.h into a sed script `conftest.defines', that
+# substitutes the proper values into config.h.in to produce config.h.
+rm -f conftest.defines conftest.tail
+# First, append a space to every undef/define line, to ease matching.
+echo 's/$/ /' >conftest.defines
+# Then, protect against being on the right side of a sed subst, or in
+# an unquoted here document, in config.status. If some macros were
+# called several times there might be several #defines for the same
+# symbol, which is useless. But do not sort them, since the last
+# AC_DEFINE must be honored.
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where
+# NAME is the cpp macro being defined, VALUE is the value it is being given.
+# PARAMS is the parameter list in the macro definition--in most cases, it's
+# just an empty string.
+ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*'
+ac_dB='\\)[ (].*,\\1define\\2'
+ac_dC=' '
+ac_dD=' ,'
+
+uniq confdefs.h |
+ sed -n '
+ t rset
+ :rset
+ s/^[ ]*#[ ]*define[ ][ ]*//
+ t ok
+ d
+ :ok
+ s/[\\&,]/\\&/g
+ s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p
+ s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p
+ ' >>conftest.defines
+
+# Remove the space that was appended to ease matching.
+# Then replace #undef with comments. This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+# (The regexp can be short, since the line contains either #define or #undef.)
+echo 's/ $//
+s,^[ #]*u.*,/* & */,' >>conftest.defines
+
+# Break up conftest.defines:
+ac_max_sed_lines=50
+
+# First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1"
+# Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2"
+# Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1"
+# et cetera.
+ac_in='$ac_file_inputs'
+ac_out='"$tmp/out1"'
+ac_nxt='"$tmp/out2"'
+
+while :
+do
+ # Write a here document:
+ cat >>$CONFIG_STATUS <<_ACEOF
+ # First, check the format of the line:
+ cat >"\$tmp/defines.sed" <<\\CEOF
+/^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def
+/^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def
+b
+:def
+_ACEOF
+ sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS
+ echo 'CEOF
+ sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS
+ ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in
+ sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail
+ grep . conftest.tail >/dev/null || break
+ rm -f conftest.defines
+ mv conftest.tail conftest.defines
+done
+rm -f conftest.defines conftest.tail
+
+echo "ac_result=$ac_in" >>$CONFIG_STATUS
+cat >>$CONFIG_STATUS <<\_ACEOF
+ if test x"$ac_file" != x-; then
+ echo "/* $configure_input */" >"$tmp/config.h"
+ cat "$ac_result" >>"$tmp/config.h"
+ if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then
+ { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
+echo "$as_me: $ac_file is unchanged" >&6;}
+ else
+ rm -f $ac_file
+ mv "$tmp/config.h" $ac_file
+ fi
+ else
+ echo "/* $configure_input */"
+ cat "$ac_result"
+ fi
+ rm -f "$tmp/out12"
+ ;;
+
+
+ esac
+
+done # for ac_tag
+
+
+{ (exit 0); exit 0; }
+_ACEOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded. So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status. When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+ ac_cs_success=:
+ ac_config_status_args=
+ test "$silent" = yes &&
+ ac_config_status_args="$ac_config_status_args --quiet"
+ exec 5>/dev/null
+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+ $ac_cs_success || { (exit 1); exit 1; }
+fi
+
+
+case "$target" in
+ *ibm-aix*)
+ mv x11/Makefile.aix x11/Makefile
+ { echo "$as_me:$LINENO: result: renaming x11/Makefile.aix to x11/Makefile" >&5
+echo "${ECHO_T}renaming x11/Makefile.aix to x11/Makefile" >&6; }
+ ;;
+ *)
+ ;;
+esac
+
+
+cat >>confdefs.h <<\_ACEOF
+#define PDC_MAX_SIGNALS
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_DECKEYSYM_H
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SUNKEYSYM_H
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XPM_H
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XK_KP_DELETE
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XK_KP_INSERT
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XK_KP_END
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XK_KP_DOWN
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XK_KP_NEXT
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XK_KP_LEFT
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XK_KP_RIGHT
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XK_KP_HOME
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XK_KP_UP
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XK_KP_PRIOR
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XK_KP_BEGIN
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define USE_XAW3D
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define USE_NEXTAW
+_ACEOF
+
+
+
+cat >>confdefs.h <<\_ACEOF
+#define XPOINTER_TYPEDEFED
+_ACEOF
+
diff --git a/payloads/libpayload/curses/PDCurses-3.4/configure.ac b/payloads/libpayload/curses/PDCurses-3.4/configure.ac
new file mode 100644
index 0000000000..cf87496d2c
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/configure.ac
@@ -0,0 +1,285 @@
+dnl $Id: configure.ac,v 1.35 2008/07/21 12:19:21 wmcbrine Exp $
+dnl Process this file with autoconf to produce a configure script.
+
+AC_INIT([PDCurses], [3.4], [wmcbrine@users.sf.net], [PDCurses])
+AC_CONFIG_SRCDIR([curspriv.h])
+
+AC_SUBST(prefix)
+
+AC_PROG_CC
+
+AC_CONFIG_HEADER(config.h)
+dnl Checks for system first
+AC_CANONICAL_SYSTEM([])
+
+mymakefile="Makefile"
+on_qnx=no
+case "$target" in
+ *hp-hpux*)
+ SYS_DEFS="-D_HPUX_SOURCE"
+ ;;
+ *ibm-aix*)
+ SYS_DEFS="-D_ALL_SOURCE"
+ mymakefile="Makefile.aix"
+ ;;
+ *dec-osf*)
+ SYS_DEFS="-D_XOPEN_SOURCE_EXTENDED"
+ ;;
+ *pc-sco*)
+ SYS_DEFS="-UM_XENIX -b elf"
+ ;;
+ *qnx*)
+ on_qnx=yes
+ SYS_DEFS="-Q"
+ ;;
+ *)
+ ;;
+esac
+AC_SUBST(SYS_DEFS)
+
+MH_CHECK_MAX_SIGNALS(NSIG __sys_nsig)
+
+dnl Check for other programs.
+AC_PROG_RANLIB
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
+
+dnl ensure that the system has System V IPC support
+MH_IPC
+
+if test $ac_cv_header_stdc != yes; then
+ AC_MSG_ERROR([Need ANSI C headers])
+fi
+
+dnl Checks for libraries.
+
+AC_CHECK_HEADERS(fcntl.h \
+ sys/time.h \
+ sys/select.h \
+ dlfcn.h \
+ dl.h
+)
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_HEADER_TIME
+MH_CHECK_LIB(socket nls)
+AC_SUBST(MH_EXTRA_LIBS)
+MH_CHECK_CC_O
+
+dnl Checks for library functions.
+AC_TYPE_SIGNAL
+AC_CHECK_FUNCS(vsscanf usleep poll vsnprintf)
+
+dnl Check for X includes and X libraries
+AC_PATH_X
+MH_CHECK_X_INC
+MH_CHECK_X_LIB
+MH_CHECK_X_HEADERS(DECkeysym.h Sunkeysym.h xpm.h)
+MH_CHECK_X_KEYDEFS(XK_KP_Delete XK_KP_Insert XK_KP_End XK_KP_Down XK_KP_Next \
+ XK_KP_Left XK_KP_Right XK_KP_Home XK_KP_Up XK_KP_Prior XK_KP_Begin)
+MH_CHECK_X_TYPEDEF(XPointer)
+dnl
+dnl extra for xpm library
+if test $ac_cv_header_xpm_h = yes; then
+ MH_XLIBS="$MH_XLIBS -lXpm"
+fi
+dnl ---------- allow --enable-debug to compile in debug mode ---------
+AC_ARG_ENABLE(debug,
+ [ --enable-debug turn on debugging],
+ [with_debug=$enableval],
+ [with_debug=no],
+)
+cflags_g="`echo $CFLAGS | grep -c '\-g'`"
+cflags_O="`echo $CFLAGS | grep -c '\-O'`"
+
+if test "$with_debug" = yes; then
+ if test "$cflags_g" = "0"; then
+ CFLAGS="${CFLAGS} -g"
+ fi
+ if test "$cflags_O" != "0"; then
+ CFLAGS="`echo ${CFLAGS} | sed -e s/-O.//`"
+ fi
+ CFLAGS="${CFLAGS} -DPDCDEBUG"
+else
+ if test "$cflags_O" = "0"; then
+ CFLAGS="${CFLAGS} -O"
+ fi
+ if test "$cflags_g" != "0"; then
+ CFLAGS="`echo ${CFLAGS} | sed -e s/-g//`"
+ fi
+fi
+if test "$ac_cv_prog_CC" = "gcc"; then
+ if test "$with_debug" = yes; then
+ CFLAGS="${CFLAGS} -Wall"
+ else
+ CFLAGS="-O2 -Wall -fomit-frame-pointer"
+ fi
+fi
+if test "$on_qnx" = yes; then
+ if test "$with_debug" = yes; then
+ CFLAGS="-g"
+ else
+ CFLAGS="-Otax"
+ fi
+fi
+
+dnl --------------- check for wide character support -----------------
+dnl allow --enable-widec to include wide character support
+AC_ARG_ENABLE(widec,
+ [ --enable-widec include support for wide characters],
+ [with_widec=$enableval],
+ [with_widec=no],
+)
+if test "$with_widec" = yes; then
+ SYS_DEFS="$SYS_DEFS -DPDC_WIDE"
+fi
+
+dnl -------------------- check for XIM support -----------------------
+dnl allow --enable-xim to include XIM support
+AC_ARG_ENABLE(xim,
+ [ --enable-xim include support for XIM],
+ [with_xim=$enableval],
+ [with_xim=no],
+)
+if test "$with_xim" = yes; then
+ SYS_DEFS="$SYS_DEFS -DPDC_XIM"
+fi
+
+dnl ------------------------ force UTF-8? ----------------------------
+dnl allow --enable-force-utf8 to override locale settings
+AC_ARG_ENABLE(force-utf8,
+ [ --enable-force-utf8 override locale settings; use UTF-8],
+ [force_utf8=$enableval],
+ [force_utf8=no],
+)
+if test "$force_utf8" = yes; then
+ SYS_DEFS="$SYS_DEFS -DPDC_FORCE_UTF8"
+fi
+
+dnl ----------------- check for Purify support -----------------------
+dnl allow --enable-purify to enable linking with Purify
+AC_ARG_ENABLE(purify,
+ [ --enable-purify link with Purify (TM)],
+ [with_purify=$enableval],
+ [with_purify=no],
+)
+if test "$with_purify" = yes; then
+ PURIFY="purify"
+else
+ PURIFY=""
+fi
+AC_SUBST(PURIFY)
+
+dnl --------------------- check for Xaw3d library --------------------
+dnl allow --with-xaw3d to link with PDCurses
+AC_ARG_WITH(xaw3d,
+ [ --with-xaw3d link with Xaw3d],
+ [with_xaw3d=$withval],
+ [with_xaw3d=no],
+)
+if test "$with_xaw3d" = yes; then
+ AC_DEFINE([USE_XAW3D], [1],
+ [Define if you want to use Xaw3d library]
+ )
+fi
+
+dnl --------------------- check for neXtaw library -------------------
+dnl allow --with-nextaw to link with PDCurses
+AC_ARG_WITH(nextaw,
+ [ --with-nextaw link with neXtaw],
+ [with_nextaw=$withval],
+ [with_nextaw=no],
+)
+if test "$with_nextaw" = yes; then
+ AC_DEFINE([USE_NEXTAW], [1],
+ [Define if you want to use neXtaw library]
+ )
+fi
+
+dnl -------------- check how to make shared libraries ----------------
+dnl Force the ability of shared library usage
+MH_SHARED_LIBRARY(XCurses)
+
+AC_CONFIG_FILES([Makefile x11/$mymakefile x11/xcurses-config])
+AC_OUTPUT
+
+case "$target" in
+ *ibm-aix*)
+ mv x11/Makefile.aix x11/Makefile
+ AC_MSG_RESULT(renaming x11/Makefile.aix to x11/Makefile)
+ ;;
+ *)
+ ;;
+esac
+
+AC_DEFINE([PDC_MAX_SIGNALS], [],
+ [Define as the system defined limit for number of signals]
+)
+
+AC_DEFINE([HAVE_DECKEYSYM_H], [],
+ [Define if you have the <DECkeySym.h> header file]
+)
+
+AC_DEFINE([HAVE_SUNKEYSYM_H], [],
+ [Define if you have the <Sunkeysym.h> header file]
+)
+
+AC_DEFINE([HAVE_XPM_H], [],
+ [Define if you have the <xpm.h> header file]
+)
+
+AC_DEFINE([HAVE_XK_KP_DELETE], [],
+ [Define if you have this defined in <keysym.h>]
+)
+
+AC_DEFINE([HAVE_XK_KP_INSERT], [],
+ [Define if you have this defined in <keysym.h>]
+)
+
+AC_DEFINE([HAVE_XK_KP_END], [],
+ [Define if you have this defined in <keysym.h>]
+)
+
+AC_DEFINE([HAVE_XK_KP_DOWN], [],
+ [Define if you have this defined in <keysym.h>]
+)
+
+AC_DEFINE([HAVE_XK_KP_NEXT], [],
+ [Define if you have this defined in <keysym.h>]
+)
+
+AC_DEFINE([HAVE_XK_KP_LEFT], [],
+ [Define if you have this defined in <keysym.h>]
+)
+
+AC_DEFINE([HAVE_XK_KP_RIGHT], [],
+ [Define if you have this defined in <keysym.h>]
+)
+
+AC_DEFINE([HAVE_XK_KP_HOME], [],
+ [Define if you have this defined in <keysym.h>]
+)
+
+AC_DEFINE([HAVE_XK_KP_UP], [],
+ [Define if you have this defined in <keysym.h>]
+)
+
+AC_DEFINE([HAVE_XK_KP_PRIOR], [],
+ [Define if you have this defined in <keysym.h>]
+)
+
+AC_DEFINE([HAVE_XK_KP_BEGIN], [],
+ [Define if you have this defined in <keysym.h>]
+)
+
+AC_DEFINE([USE_XAW3D], [],
+ [Define if you want to use Xaw3d library]
+)
+
+AC_DEFINE([USE_NEXTAW], [],
+ [Define if you want to use neXtaw library]
+)
+
+AC_DEFINE([XPOINTER_TYPEDEFED], [],
+ [Define XPointer is typedefed in X11/Xlib.h]
+)
diff --git a/payloads/libpayload/curses/PDCurses-3.4/curses.h b/payloads/libpayload/curses/PDCurses-3.4/curses.h
new file mode 100644
index 0000000000..6f3ce19d42
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/curses.h
@@ -0,0 +1,1377 @@
+/* Public Domain Curses */
+
+/* $Id: curses.h,v 1.295 2008/07/15 17:13:25 wmcbrine Exp $ */
+
+/*----------------------------------------------------------------------*
+ * PDCurses *
+ *----------------------------------------------------------------------*/
+
+#ifndef __PDCURSES__
+#define __PDCURSES__ 1
+
+/*man-start**************************************************************
+
+PDCurses definitions list: (Only define those needed)
+
+ XCURSES True if compiling for X11.
+ PDC_RGB True if you want to use RGB color definitions
+ (Red = 1, Green = 2, Blue = 4) instead of BGR.
+ PDC_WIDE True if building wide-character support.
+ PDC_DLL_BUILD True if building a Win32 DLL.
+ NCURSES_MOUSE_VERSION Use the ncurses mouse API instead
+ of PDCurses' traditional mouse API.
+
+PDCurses portable platform definitions list:
+
+ PDC_BUILD Defines API build version.
+ PDCURSES Enables access to PDCurses-only routines.
+ XOPEN Always true.
+ SYSVcurses True if you are compiling for SYSV portability.
+ BSDcurses True if you are compiling for BSD portability.
+
+**man-end****************************************************************/
+
+#define PDC_BUILD 3401
+#define PDCURSES 1 /* PDCurses-only routines */
+#define XOPEN 1 /* X/Open Curses routines */
+#define SYSVcurses 1 /* System V Curses routines */
+#define BSDcurses 1 /* BSD Curses routines */
+#define CHTYPE_LONG 1 /* size of chtype; long */
+
+/*----------------------------------------------------------------------*/
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h> /* Required by X/Open usage below */
+
+#ifdef PDC_WIDE
+# include <wchar.h>
+#endif
+
+#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
+extern "C"
+{
+# define bool _bool
+#endif
+
+/*----------------------------------------------------------------------
+ *
+ * PDCurses Manifest Constants
+ *
+ */
+
+#ifndef FALSE
+# define FALSE 0
+#endif
+#ifndef TRUE
+# define TRUE 1
+#endif
+#ifndef NULL
+# define NULL (void *)0
+#endif
+#ifndef ERR
+# define ERR (-1)
+#endif
+#ifndef OK
+# define OK 0
+#endif
+
+/*----------------------------------------------------------------------
+ *
+ * PDCurses Type Declarations
+ *
+ */
+
+typedef unsigned char bool; /* PDCurses Boolean type */
+
+#ifdef CHTYPE_LONG
+# if _LP64
+typedef unsigned int chtype;
+# else
+typedef unsigned long chtype; /* 16-bit attr + 16-bit char */
+# endif
+#else
+typedef unsigned short chtype; /* 8-bit attr + 8-bit char */
+#endif
+
+#ifdef PDC_WIDE
+typedef chtype cchar_t;
+#endif
+
+typedef chtype attr_t;
+
+/*----------------------------------------------------------------------
+ *
+ * PDCurses Mouse Interface -- SYSVR4, with extensions
+ *
+ */
+
+typedef struct
+{
+ int x; /* absolute column, 0 based, measured in characters */
+ int y; /* absolute row, 0 based, measured in characters */
+ short button[3]; /* state of each button */
+ int changes; /* flags indicating what has changed with the mouse */
+} MOUSE_STATUS;
+
+#define BUTTON_RELEASED 0x0000
+#define BUTTON_PRESSED 0x0001
+#define BUTTON_CLICKED 0x0002
+#define BUTTON_DOUBLE_CLICKED 0x0003
+#define BUTTON_TRIPLE_CLICKED 0x0004
+#define BUTTON_MOVED 0x0005 /* PDCurses */
+#define WHEEL_SCROLLED 0x0006 /* PDCurses */
+#define BUTTON_ACTION_MASK 0x0007 /* PDCurses */
+
+#define PDC_BUTTON_SHIFT 0x0008 /* PDCurses */
+#define PDC_BUTTON_CONTROL 0x0010 /* PDCurses */
+#define PDC_BUTTON_ALT 0x0020 /* PDCurses */
+#define BUTTON_MODIFIER_MASK 0x0038 /* PDCurses */
+
+#define MOUSE_X_POS (Mouse_status.x)
+#define MOUSE_Y_POS (Mouse_status.y)
+
+/*
+ * Bits associated with the .changes field:
+ * 3 2 1 0
+ * 210987654321098765432109876543210
+ * 1 <- button 1 has changed
+ * 10 <- button 2 has changed
+ * 100 <- button 3 has changed
+ * 1000 <- mouse has moved
+ * 10000 <- mouse position report
+ * 100000 <- mouse wheel up
+ * 1000000 <- mouse wheel down
+ */
+
+#define PDC_MOUSE_MOVED 0x0008
+#define PDC_MOUSE_POSITION 0x0010
+#define PDC_MOUSE_WHEEL_UP 0x0020
+#define PDC_MOUSE_WHEEL_DOWN 0x0040
+
+#define A_BUTTON_CHANGED (Mouse_status.changes & 7)
+#define MOUSE_MOVED (Mouse_status.changes & PDC_MOUSE_MOVED)
+#define MOUSE_POS_REPORT (Mouse_status.changes & PDC_MOUSE_POSITION)
+#define BUTTON_CHANGED(x) (Mouse_status.changes & (1 << ((x) - 1)))
+#define BUTTON_STATUS(x) (Mouse_status.button[(x) - 1])
+#define MOUSE_WHEEL_UP (Mouse_status.changes & PDC_MOUSE_WHEEL_UP)
+#define MOUSE_WHEEL_DOWN (Mouse_status.changes & PDC_MOUSE_WHEEL_DOWN)
+
+/* mouse bit-masks */
+
+#define BUTTON1_RELEASED 0x00000001L
+#define BUTTON1_PRESSED 0x00000002L
+#define BUTTON1_CLICKED 0x00000004L
+#define BUTTON1_DOUBLE_CLICKED 0x00000008L
+#define BUTTON1_TRIPLE_CLICKED 0x00000010L
+#define BUTTON1_MOVED 0x00000010L /* PDCurses */
+
+#define BUTTON2_RELEASED 0x00000020L
+#define BUTTON2_PRESSED 0x00000040L
+#define BUTTON2_CLICKED 0x00000080L
+#define BUTTON2_DOUBLE_CLICKED 0x00000100L
+#define BUTTON2_TRIPLE_CLICKED 0x00000200L
+#define BUTTON2_MOVED 0x00000200L /* PDCurses */
+
+#define BUTTON3_RELEASED 0x00000400L
+#define BUTTON3_PRESSED 0x00000800L
+#define BUTTON3_CLICKED 0x00001000L
+#define BUTTON3_DOUBLE_CLICKED 0x00002000L
+#define BUTTON3_TRIPLE_CLICKED 0x00004000L
+#define BUTTON3_MOVED 0x00004000L /* PDCurses */
+
+/* For the ncurses-compatible functions only, BUTTON4_PRESSED and
+ BUTTON5_PRESSED are returned for mouse scroll wheel up and down;
+ otherwise PDCurses doesn't support buttons 4 and 5 */
+
+#define BUTTON4_RELEASED 0x00008000L
+#define BUTTON4_PRESSED 0x00010000L
+#define BUTTON4_CLICKED 0x00020000L
+#define BUTTON4_DOUBLE_CLICKED 0x00040000L
+#define BUTTON4_TRIPLE_CLICKED 0x00080000L
+
+#define BUTTON5_RELEASED 0x00100000L
+#define BUTTON5_PRESSED 0x00200000L
+#define BUTTON5_CLICKED 0x00400000L
+#define BUTTON5_DOUBLE_CLICKED 0x00800000L
+#define BUTTON5_TRIPLE_CLICKED 0x01000000L
+
+#define MOUSE_WHEEL_SCROLL 0x02000000L /* PDCurses */
+#define BUTTON_MODIFIER_SHIFT 0x04000000L /* PDCurses */
+#define BUTTON_MODIFIER_CONTROL 0x08000000L /* PDCurses */
+#define BUTTON_MODIFIER_ALT 0x10000000L /* PDCurses */
+
+#define ALL_MOUSE_EVENTS 0x1fffffffL
+#define REPORT_MOUSE_POSITION 0x20000000L
+
+/* ncurses mouse interface */
+
+typedef unsigned long mmask_t;
+
+typedef struct
+{
+ short id; /* unused, always 0 */
+ int x, y, z; /* x, y same as MOUSE_STATUS; z unused */
+ mmask_t bstate; /* equivalent to changes + button[], but
+ in the same format as used for mousemask() */
+} MEVENT;
+
+#ifdef NCURSES_MOUSE_VERSION
+# define BUTTON_SHIFT BUTTON_MODIFIER_SHIFT
+# define BUTTON_CONTROL BUTTON_MODIFIER_CONTROL
+# define BUTTON_CTRL BUTTON_MODIFIER_CONTROL
+# define BUTTON_ALT BUTTON_MODIFIER_ALT
+#else
+# define BUTTON_SHIFT PDC_BUTTON_SHIFT
+# define BUTTON_CONTROL PDC_BUTTON_CONTROL
+# define BUTTON_ALT PDC_BUTTON_ALT
+#endif
+
+/*----------------------------------------------------------------------
+ *
+ * PDCurses Structure Definitions
+ *
+ */
+
+typedef struct _win /* definition of a window */
+{
+ int _cury; /* current pseudo-cursor */
+ int _curx;
+ int _maxy; /* max window coordinates */
+ int _maxx;
+ int _begy; /* origin on screen */
+ int _begx;
+ int _flags; /* window properties */
+ chtype _attrs; /* standard attributes and colors */
+ chtype _bkgd; /* background, normally blank */
+ bool _clear; /* causes clear at next refresh */
+ bool _leaveit; /* leaves cursor where it is */
+ bool _scroll; /* allows window scrolling */
+ bool _nodelay; /* input character wait flag */
+ bool _immed; /* immediate update flag */
+ bool _sync; /* synchronise window ancestors */
+ bool _use_keypad; /* flags keypad key mode active */
+ chtype **_y; /* pointer to line pointer array */
+ int *_firstch; /* first changed character in line */
+ int *_lastch; /* last changed character in line */
+ int _tmarg; /* top of scrolling region */
+ int _bmarg; /* bottom of scrolling region */
+ int _delayms; /* milliseconds of delay for getch() */
+ int _parx, _pary; /* coords relative to parent (0,0) */
+ struct _win *_parent; /* subwin's pointer to parent win */
+} WINDOW;
+
+/* Avoid using the SCREEN struct directly -- use the corresponding
+ functions if possible. This struct may eventually be made private. */
+
+typedef struct
+{
+ bool alive; /* if initscr() called, and not endwin() */
+ bool autocr; /* if cr -> lf */
+ bool cbreak; /* if terminal unbuffered */
+ bool echo; /* if terminal echo */
+ bool raw_inp; /* raw input mode (v. cooked input) */
+ bool raw_out; /* raw output mode (7 v. 8 bits) */
+ bool audible; /* FALSE if the bell is visual */
+ bool mono; /* TRUE if current screen is mono */
+ bool resized; /* TRUE if TERM has been resized */
+ bool orig_attr; /* TRUE if we have the original colors */
+ short orig_fore; /* original screen foreground color */
+ short orig_back; /* original screen foreground color */
+ int cursrow; /* position of physical cursor */
+ int curscol; /* position of physical cursor */
+ int visibility; /* visibility of cursor */
+ int orig_cursor; /* original cursor size */
+ int lines; /* new value for LINES */
+ int cols; /* new value for COLS */
+ unsigned long _trap_mbe; /* trap these mouse button events */
+ unsigned long _map_mbe_to_key; /* map mouse buttons to slk */
+ int mouse_wait; /* time to wait (in ms) for a
+ button release after a press, in
+ order to count it as a click */
+ int slklines; /* lines in use by slk_init() */
+ WINDOW *slk_winptr; /* window for slk */
+ int linesrippedoff; /* lines ripped off via ripoffline() */
+ int linesrippedoffontop; /* lines ripped off on
+ top via ripoffline() */
+ int delaytenths; /* 1/10ths second to wait block
+ getch() for */
+ bool _preserve; /* TRUE if screen background
+ to be preserved */
+ int _restore; /* specifies if screen background
+ to be restored, and how */
+ bool save_key_modifiers; /* TRUE if each key modifiers saved
+ with each key press */
+ bool return_key_modifiers; /* TRUE if modifier keys are
+ returned as "real" keys */
+ bool key_code; /* TRUE if last key is a special key;
+ used internally by get_wch() */
+#ifdef XCURSES
+ int XcurscrSize; /* size of Xcurscr shared memory block */
+ bool sb_on;
+ int sb_viewport_y;
+ int sb_viewport_x;
+ int sb_total_y;
+ int sb_total_x;
+ int sb_cur_y;
+ int sb_cur_x;
+#endif
+ short line_color; /* color of line attributes - default -1 */
+} SCREEN;
+
+/*----------------------------------------------------------------------
+ *
+ * PDCurses External Variables
+ *
+ */
+
+#ifdef PDC_DLL_BUILD
+# ifdef CURSES_LIBRARY
+# define PDCEX __declspec(dllexport) extern
+# else
+# define PDCEX __declspec(dllimport)
+# endif
+#else
+# define PDCEX extern
+#endif
+
+PDCEX int LINES; /* terminal height */
+PDCEX int COLS; /* terminal width */
+PDCEX WINDOW *stdscr; /* the default screen window */
+PDCEX WINDOW *curscr; /* the current screen image */
+PDCEX SCREEN *SP; /* curses variables */
+PDCEX MOUSE_STATUS Mouse_status;
+PDCEX int COLORS;
+PDCEX int COLOR_PAIRS;
+PDCEX int TABSIZE;
+PDCEX chtype acs_map[]; /* alternate character set map */
+PDCEX char ttytype[]; /* terminal name/description */
+
+/*man-start**************************************************************
+
+PDCurses Text Attributes
+========================
+
+Originally, PDCurses used a short (16 bits) for its chtype. To include
+color, a number of things had to be sacrificed from the strict Unix and
+System V support. The main problem was fitting all character attributes
+and color into an unsigned char (all 8 bits!).
+
+Today, PDCurses by default uses a long (32 bits) for its chtype, as in
+System V. The short chtype is still available, by undefining CHTYPE_LONG
+and rebuilding the library.
+
+The following is the structure of a win->_attrs chtype:
+
+short form:
+
+-------------------------------------------------
+|15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0|
+-------------------------------------------------
+ color number | attrs | character eg 'a'
+
+The available non-color attributes are bold, reverse and blink. Others
+have no effect. The high order char is an index into an array of
+physical colors (defined in color.c) -- 32 foreground/background color
+pairs (5 bits) plus 3 bits for other attributes.
+
+long form:
+
+----------------------------------------------------------------------------
+|31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|..| 3| 2| 1| 0|
+----------------------------------------------------------------------------
+ color number | modifiers | character eg 'a'
+
+The available non-color attributes are bold, underline, invisible,
+right-line, left-line, protect, reverse and blink. 256 color pairs (8
+bits), 8 bits for other attributes, and 16 bits for character data.
+
+**man-end****************************************************************/
+
+/*** Video attribute macros ***/
+
+#define A_NORMAL (chtype)0
+
+#ifdef CHTYPE_LONG
+# define A_ALTCHARSET (chtype)0x00010000
+# define A_RIGHTLINE (chtype)0x00020000
+# define A_LEFTLINE (chtype)0x00040000
+# define A_INVIS (chtype)0x00080000
+# define A_UNDERLINE (chtype)0x00100000
+# define A_REVERSE (chtype)0x00200000
+# define A_BLINK (chtype)0x00400000
+# define A_BOLD (chtype)0x00800000
+
+# define A_ATTRIBUTES (chtype)0xffff0000
+# define A_CHARTEXT (chtype)0x0000ffff
+# define A_COLOR (chtype)0xff000000
+
+# define A_ITALIC A_INVIS
+# define A_PROTECT (A_UNDERLINE | A_LEFTLINE | A_RIGHTLINE)
+
+# define PDC_ATTR_SHIFT 19
+# define PDC_COLOR_SHIFT 24
+#else
+# define A_BOLD (chtype)0x0100 /* X/Open */
+# define A_REVERSE (chtype)0x0200 /* X/Open */
+# define A_BLINK (chtype)0x0400 /* X/Open */
+
+# define A_ATTRIBUTES (chtype)0xff00 /* X/Open */
+# define A_CHARTEXT (chtype)0x00ff /* X/Open */
+# define A_COLOR (chtype)0xf800 /* System V */
+
+# define A_ALTCHARSET A_NORMAL /* X/Open */
+# define A_PROTECT A_NORMAL /* X/Open */
+# define A_UNDERLINE A_NORMAL /* X/Open */
+
+# define A_LEFTLINE A_NORMAL
+# define A_RIGHTLINE A_NORMAL
+# define A_ITALIC A_NORMAL
+# define A_INVIS A_NORMAL
+
+# define PDC_ATTR_SHIFT 8
+# define PDC_COLOR_SHIFT 11
+#endif
+
+#define A_STANDOUT (A_REVERSE | A_BOLD) /* X/Open */
+#define A_DIM A_NORMAL
+
+#define CHR_MSK A_CHARTEXT /* Obsolete */
+#define ATR_MSK A_ATTRIBUTES /* Obsolete */
+#define ATR_NRM A_NORMAL /* Obsolete */
+
+/* For use with attr_t -- X/Open says, "these shall be distinct", so
+ this is a non-conforming implementation. */
+
+#define WA_ALTCHARSET A_ALTCHARSET
+#define WA_BLINK A_BLINK
+#define WA_BOLD A_BOLD
+#define WA_DIM A_DIM
+#define WA_INVIS A_INVIS
+#define WA_LEFT A_LEFTLINE
+#define WA_PROTECT A_PROTECT
+#define WA_REVERSE A_REVERSE
+#define WA_RIGHT A_RIGHTLINE
+#define WA_STANDOUT A_STANDOUT
+#define WA_UNDERLINE A_UNDERLINE
+
+#define WA_HORIZONTAL A_NORMAL
+#define WA_LOW A_NORMAL
+#define WA_TOP A_NORMAL
+#define WA_VERTICAL A_NORMAL
+
+/*** Alternate character set macros ***/
+
+/* 'w' = 32-bit chtype; acs_map[] index | A_ALTCHARSET
+ 'n' = 16-bit chtype; it gets the fallback set because no bit is
+ available for A_ALTCHARSET */
+
+#ifdef CHTYPE_LONG
+# define ACS_PICK(w, n) ((chtype)w | A_ALTCHARSET)
+#else
+# define ACS_PICK(w, n) ((chtype)n)
+#endif
+
+/* VT100-compatible symbols -- box chars */
+
+#define ACS_ULCORNER ACS_PICK('l', '+')
+#define ACS_LLCORNER ACS_PICK('m', '+')
+#define ACS_URCORNER ACS_PICK('k', '+')
+#define ACS_LRCORNER ACS_PICK('j', '+')
+#define ACS_RTEE ACS_PICK('u', '+')
+#define ACS_LTEE ACS_PICK('t', '+')
+#define ACS_BTEE ACS_PICK('v', '+')
+#define ACS_TTEE ACS_PICK('w', '+')
+#define ACS_HLINE ACS_PICK('q', '-')
+#define ACS_VLINE ACS_PICK('x', '|')
+#define ACS_PLUS ACS_PICK('n', '+')
+
+/* VT100-compatible symbols -- other */
+
+#define ACS_S1 ACS_PICK('o', '-')
+#define ACS_S9 ACS_PICK('s', '_')
+#define ACS_DIAMOND ACS_PICK('`', '+')
+#define ACS_CKBOARD ACS_PICK('a', ':')
+#define ACS_DEGREE ACS_PICK('f', '\'')
+#define ACS_PLMINUS ACS_PICK('g', '#')
+#define ACS_BULLET ACS_PICK('~', 'o')
+
+/* Teletype 5410v1 symbols -- these are defined in SysV curses, but
+ are not well-supported by most terminals. Stick to VT100 characters
+ for optimum portability. */
+
+#define ACS_LARROW ACS_PICK(',', '<')
+#define ACS_RARROW ACS_PICK('+', '>')
+#define ACS_DARROW ACS_PICK('.', 'v')
+#define ACS_UARROW ACS_PICK('-', '^')
+#define ACS_BOARD ACS_PICK('h', '#')
+#define ACS_LANTERN ACS_PICK('i', '*')
+#define ACS_BLOCK ACS_PICK('0', '#')
+
+/* That goes double for these -- undocumented SysV symbols. Don't use
+ them. */
+
+#define ACS_S3 ACS_PICK('p', '-')
+#define ACS_S7 ACS_PICK('r', '-')
+#define ACS_LEQUAL ACS_PICK('y', '<')
+#define ACS_GEQUAL ACS_PICK('z', '>')
+#define ACS_PI ACS_PICK('{', 'n')
+#define ACS_NEQUAL ACS_PICK('|', '+')
+#define ACS_STERLING ACS_PICK('}', 'L')
+
+/* Box char aliases */
+
+#define ACS_BSSB ACS_ULCORNER
+#define ACS_SSBB ACS_LLCORNER
+#define ACS_BBSS ACS_URCORNER
+#define ACS_SBBS ACS_LRCORNER
+#define ACS_SBSS ACS_RTEE
+#define ACS_SSSB ACS_LTEE
+#define ACS_SSBS ACS_BTEE
+#define ACS_BSSS ACS_TTEE
+#define ACS_BSBS ACS_HLINE
+#define ACS_SBSB ACS_VLINE
+#define ACS_SSSS ACS_PLUS
+
+/* cchar_t aliases */
+
+#ifdef PDC_WIDE
+# define WACS_ULCORNER (&(acs_map['l']))
+# define WACS_LLCORNER (&(acs_map['m']))
+# define WACS_URCORNER (&(acs_map['k']))
+# define WACS_LRCORNER (&(acs_map['j']))
+# define WACS_RTEE (&(acs_map['u']))
+# define WACS_LTEE (&(acs_map['t']))
+# define WACS_BTEE (&(acs_map['v']))
+# define WACS_TTEE (&(acs_map['w']))
+# define WACS_HLINE (&(acs_map['q']))
+# define WACS_VLINE (&(acs_map['x']))
+# define WACS_PLUS (&(acs_map['n']))
+
+# define WACS_S1 (&(acs_map['o']))
+# define WACS_S9 (&(acs_map['s']))
+# define WACS_DIAMOND (&(acs_map['`']))
+# define WACS_CKBOARD (&(acs_map['a']))
+# define WACS_DEGREE (&(acs_map['f']))
+# define WACS_PLMINUS (&(acs_map['g']))
+# define WACS_BULLET (&(acs_map['~']))
+
+# define WACS_LARROW (&(acs_map[',']))
+# define WACS_RARROW (&(acs_map['+']))
+# define WACS_DARROW (&(acs_map['.']))
+# define WACS_UARROW (&(acs_map['-']))
+# define WACS_BOARD (&(acs_map['h']))
+# define WACS_LANTERN (&(acs_map['i']))
+# define WACS_BLOCK (&(acs_map['0']))
+
+# define WACS_S3 (&(acs_map['p']))
+# define WACS_S7 (&(acs_map['r']))
+# define WACS_LEQUAL (&(acs_map['y']))
+# define WACS_GEQUAL (&(acs_map['z']))
+# define WACS_PI (&(acs_map['{']))
+# define WACS_NEQUAL (&(acs_map['|']))
+# define WACS_STERLING (&(acs_map['}']))
+
+# define WACS_BSSB WACS_ULCORNER
+# define WACS_SSBB WACS_LLCORNER
+# define WACS_BBSS WACS_URCORNER
+# define WACS_SBBS WACS_LRCORNER
+# define WACS_SBSS WACS_RTEE
+# define WACS_SSSB WACS_LTEE
+# define WACS_SSBS WACS_BTEE
+# define WACS_BSSS WACS_TTEE
+# define WACS_BSBS WACS_HLINE
+# define WACS_SBSB WACS_VLINE
+# define WACS_SSSS WACS_PLUS
+#endif
+
+/*** Color macros ***/
+
+#define COLOR_BLACK 0
+
+#ifdef PDC_RGB /* RGB */
+# define COLOR_RED 1
+# define COLOR_GREEN 2
+# define COLOR_BLUE 4
+#else /* BGR */
+# define COLOR_BLUE 1
+# define COLOR_GREEN 2
+# define COLOR_RED 4
+#endif
+
+#define COLOR_CYAN (COLOR_BLUE | COLOR_GREEN)
+#define COLOR_MAGENTA (COLOR_RED | COLOR_BLUE)
+#define COLOR_YELLOW (COLOR_RED | COLOR_GREEN)
+
+#define COLOR_WHITE 7
+
+/*----------------------------------------------------------------------
+ *
+ * Function and Keypad Key Definitions.
+ * Many are just for compatibility.
+ *
+ */
+
+#define KEY_CODE_YES 0x100 /* If get_wch() gives a key code */
+
+#define KEY_BREAK 0x101 /* Not on PC KBD */
+#define KEY_DOWN 0x102 /* Down arrow key */
+#define KEY_UP 0x103 /* Up arrow key */
+#define KEY_LEFT 0x104 /* Left arrow key */
+#define KEY_RIGHT 0x105 /* Right arrow key */
+#define KEY_HOME 0x106 /* home key */
+#define KEY_BACKSPACE 0x107 /* not on pc */
+#define KEY_F0 0x108 /* function keys; 64 reserved */
+
+#define KEY_DL 0x148 /* delete line */
+#define KEY_IL 0x149 /* insert line */
+#define KEY_DC 0x14a /* delete character */
+#define KEY_IC 0x14b /* insert char or enter ins mode */
+#define KEY_EIC 0x14c /* exit insert char mode */
+#define KEY_CLEAR 0x14d /* clear screen */
+#define KEY_EOS 0x14e /* clear to end of screen */
+#define KEY_EOL 0x14f /* clear to end of line */
+#define KEY_SF 0x150 /* scroll 1 line forward */
+#define KEY_SR 0x151 /* scroll 1 line back (reverse) */
+#define KEY_NPAGE 0x152 /* next page */
+#define KEY_PPAGE 0x153 /* previous page */
+#define KEY_STAB 0x154 /* set tab */
+#define KEY_CTAB 0x155 /* clear tab */
+#define KEY_CATAB 0x156 /* clear all tabs */
+#define KEY_ENTER 0x157 /* enter or send (unreliable) */
+#define KEY_SRESET 0x158 /* soft/reset (partial/unreliable) */
+#define KEY_RESET 0x159 /* reset/hard reset (unreliable) */
+#define KEY_PRINT 0x15a /* print/copy */
+#define KEY_LL 0x15b /* home down/bottom (lower left) */
+#define KEY_ABORT 0x15c /* abort/terminate key (any) */
+#define KEY_SHELP 0x15d /* short help */
+#define KEY_LHELP 0x15e /* long help */
+#define KEY_BTAB 0x15f /* Back tab key */
+#define KEY_BEG 0x160 /* beg(inning) key */
+#define KEY_CANCEL 0x161 /* cancel key */
+#define KEY_CLOSE 0x162 /* close key */
+#define KEY_COMMAND 0x163 /* cmd (command) key */
+#define KEY_COPY 0x164 /* copy key */
+#define KEY_CREATE 0x165 /* create key */
+#define KEY_END 0x166 /* end key */
+#define KEY_EXIT 0x167 /* exit key */
+#define KEY_FIND 0x168 /* find key */
+#define KEY_HELP 0x169 /* help key */
+#define KEY_MARK 0x16a /* mark key */
+#define KEY_MESSAGE 0x16b /* message key */
+#define KEY_MOVE 0x16c /* move key */
+#define KEY_NEXT 0x16d /* next object key */
+#define KEY_OPEN 0x16e /* open key */
+#define KEY_OPTIONS 0x16f /* options key */
+#define KEY_PREVIOUS 0x170 /* previous object key */
+#define KEY_REDO 0x171 /* redo key */
+#define KEY_REFERENCE 0x172 /* ref(erence) key */
+#define KEY_REFRESH 0x173 /* refresh key */
+#define KEY_REPLACE 0x174 /* replace key */
+#define KEY_RESTART 0x175 /* restart key */
+#define KEY_RESUME 0x176 /* resume key */
+#define KEY_SAVE 0x177 /* save key */
+#define KEY_SBEG 0x178 /* shifted beginning key */
+#define KEY_SCANCEL 0x179 /* shifted cancel key */
+#define KEY_SCOMMAND 0x17a /* shifted command key */
+#define KEY_SCOPY 0x17b /* shifted copy key */
+#define KEY_SCREATE 0x17c /* shifted create key */
+#define KEY_SDC 0x17d /* shifted delete char key */
+#define KEY_SDL 0x17e /* shifted delete line key */
+#define KEY_SELECT 0x17f /* select key */
+#define KEY_SEND 0x180 /* shifted end key */
+#define KEY_SEOL 0x181 /* shifted clear line key */
+#define KEY_SEXIT 0x182 /* shifted exit key */
+#define KEY_SFIND 0x183 /* shifted find key */
+#define KEY_SHOME 0x184 /* shifted home key */
+#define KEY_SIC 0x185 /* shifted input key */
+
+#define KEY_SLEFT 0x187 /* shifted left arrow key */
+#define KEY_SMESSAGE 0x188 /* shifted message key */
+#define KEY_SMOVE 0x189 /* shifted move key */
+#define KEY_SNEXT 0x18a /* shifted next key */
+#define KEY_SOPTIONS 0x18b /* shifted options key */
+#define KEY_SPREVIOUS 0x18c /* shifted prev key */
+#define KEY_SPRINT 0x18d /* shifted print key */
+#define KEY_SREDO 0x18e /* shifted redo key */
+#define KEY_SREPLACE 0x18f /* shifted replace key */
+#define KEY_SRIGHT 0x190 /* shifted right arrow */
+#define KEY_SRSUME 0x191 /* shifted resume key */
+#define KEY_SSAVE 0x192 /* shifted save key */
+#define KEY_SSUSPEND 0x193 /* shifted suspend key */
+#define KEY_SUNDO 0x194 /* shifted undo key */
+#define KEY_SUSPEND 0x195 /* suspend key */
+#define KEY_UNDO 0x196 /* undo key */
+
+/* PDCurses-specific key definitions -- PC only */
+
+#define ALT_0 0x197
+#define ALT_1 0x198
+#define ALT_2 0x199
+#define ALT_3 0x19a
+#define ALT_4 0x19b
+#define ALT_5 0x19c
+#define ALT_6 0x19d
+#define ALT_7 0x19e
+#define ALT_8 0x19f
+#define ALT_9 0x1a0
+#define ALT_A 0x1a1
+#define ALT_B 0x1a2
+#define ALT_C 0x1a3
+#define ALT_D 0x1a4
+#define ALT_E 0x1a5
+#define ALT_F 0x1a6
+#define ALT_G 0x1a7
+#define ALT_H 0x1a8
+#define ALT_I 0x1a9
+#define ALT_J 0x1aa
+#define ALT_K 0x1ab
+#define ALT_L 0x1ac
+#define ALT_M 0x1ad
+#define ALT_N 0x1ae
+#define ALT_O 0x1af
+#define ALT_P 0x1b0
+#define ALT_Q 0x1b1
+#define ALT_R 0x1b2
+#define ALT_S 0x1b3
+#define ALT_T 0x1b4
+#define ALT_U 0x1b5
+#define ALT_V 0x1b6
+#define ALT_W 0x1b7
+#define ALT_X 0x1b8
+#define ALT_Y 0x1b9
+#define ALT_Z 0x1ba
+
+#define CTL_LEFT 0x1bb /* Control-Left-Arrow */
+#define CTL_RIGHT 0x1bc
+#define CTL_PGUP 0x1bd
+#define CTL_PGDN 0x1be
+#define CTL_HOME 0x1bf
+#define CTL_END 0x1c0
+
+#define KEY_A1 0x1c1 /* upper left on Virtual keypad */
+#define KEY_A2 0x1c2 /* upper middle on Virt. keypad */
+#define KEY_A3 0x1c3 /* upper right on Vir. keypad */
+#define KEY_B1 0x1c4 /* middle left on Virt. keypad */
+#define KEY_B2 0x1c5 /* center on Virt. keypad */
+#define KEY_B3 0x1c6 /* middle right on Vir. keypad */
+#define KEY_C1 0x1c7 /* lower left on Virt. keypad */
+#define KEY_C2 0x1c8 /* lower middle on Virt. keypad */
+#define KEY_C3 0x1c9 /* lower right on Vir. keypad */
+
+#define PADSLASH 0x1ca /* slash on keypad */
+#define PADENTER 0x1cb /* enter on keypad */
+#define CTL_PADENTER 0x1cc /* ctl-enter on keypad */
+#define ALT_PADENTER 0x1cd /* alt-enter on keypad */
+#define PADSTOP 0x1ce /* stop on keypad */
+#define PADSTAR 0x1cf /* star on keypad */
+#define PADMINUS 0x1d0 /* minus on keypad */
+#define PADPLUS 0x1d1 /* plus on keypad */
+#define CTL_PADSTOP 0x1d2 /* ctl-stop on keypad */
+#define CTL_PADCENTER 0x1d3 /* ctl-enter on keypad */
+#define CTL_PADPLUS 0x1d4 /* ctl-plus on keypad */
+#define CTL_PADMINUS 0x1d5 /* ctl-minus on keypad */
+#define CTL_PADSLASH 0x1d6 /* ctl-slash on keypad */
+#define CTL_PADSTAR 0x1d7 /* ctl-star on keypad */
+#define ALT_PADPLUS 0x1d8 /* alt-plus on keypad */
+#define ALT_PADMINUS 0x1d9 /* alt-minus on keypad */
+#define ALT_PADSLASH 0x1da /* alt-slash on keypad */
+#define ALT_PADSTAR 0x1db /* alt-star on keypad */
+#define ALT_PADSTOP 0x1dc /* alt-stop on keypad */
+#define CTL_INS 0x1dd /* ctl-insert */
+#define ALT_DEL 0x1de /* alt-delete */
+#define ALT_INS 0x1df /* alt-insert */
+#define CTL_UP 0x1e0 /* ctl-up arrow */
+#define CTL_DOWN 0x1e1 /* ctl-down arrow */
+#define CTL_TAB 0x1e2 /* ctl-tab */
+#define ALT_TAB 0x1e3
+#define ALT_MINUS 0x1e4
+#define ALT_EQUAL 0x1e5
+#define ALT_HOME 0x1e6
+#define ALT_PGUP 0x1e7
+#define ALT_PGDN 0x1e8
+#define ALT_END 0x1e9
+#define ALT_UP 0x1ea /* alt-up arrow */
+#define ALT_DOWN 0x1eb /* alt-down arrow */
+#define ALT_RIGHT 0x1ec /* alt-right arrow */
+#define ALT_LEFT 0x1ed /* alt-left arrow */
+#define ALT_ENTER 0x1ee /* alt-enter */
+#define ALT_ESC 0x1ef /* alt-escape */
+#define ALT_BQUOTE 0x1f0 /* alt-back quote */
+#define ALT_LBRACKET 0x1f1 /* alt-left bracket */
+#define ALT_RBRACKET 0x1f2 /* alt-right bracket */
+#define ALT_SEMICOLON 0x1f3 /* alt-semi-colon */
+#define ALT_FQUOTE 0x1f4 /* alt-forward quote */
+#define ALT_COMMA 0x1f5 /* alt-comma */
+#define ALT_STOP 0x1f6 /* alt-stop */
+#define ALT_FSLASH 0x1f7 /* alt-forward slash */
+#define ALT_BKSP 0x1f8 /* alt-backspace */
+#define CTL_BKSP 0x1f9 /* ctl-backspace */
+#define PAD0 0x1fa /* keypad 0 */
+
+#define CTL_PAD0 0x1fb /* ctl-keypad 0 */
+#define CTL_PAD1 0x1fc
+#define CTL_PAD2 0x1fd
+#define CTL_PAD3 0x1fe
+#define CTL_PAD4 0x1ff
+#define CTL_PAD5 0x200
+#define CTL_PAD6 0x201
+#define CTL_PAD7 0x202
+#define CTL_PAD8 0x203
+#define CTL_PAD9 0x204
+
+#define ALT_PAD0 0x205 /* alt-keypad 0 */
+#define ALT_PAD1 0x206
+#define ALT_PAD2 0x207
+#define ALT_PAD3 0x208
+#define ALT_PAD4 0x209
+#define ALT_PAD5 0x20a
+#define ALT_PAD6 0x20b
+#define ALT_PAD7 0x20c
+#define ALT_PAD8 0x20d
+#define ALT_PAD9 0x20e
+
+#define CTL_DEL 0x20f /* clt-delete */
+#define ALT_BSLASH 0x210 /* alt-back slash */
+#define CTL_ENTER 0x211 /* ctl-enter */
+
+#define SHF_PADENTER 0x212 /* shift-enter on keypad */
+#define SHF_PADSLASH 0x213 /* shift-slash on keypad */
+#define SHF_PADSTAR 0x214 /* shift-star on keypad */
+#define SHF_PADPLUS 0x215 /* shift-plus on keypad */
+#define SHF_PADMINUS 0x216 /* shift-minus on keypad */
+#define SHF_UP 0x217 /* shift-up on keypad */
+#define SHF_DOWN 0x218 /* shift-down on keypad */
+#define SHF_IC 0x219 /* shift-insert on keypad */
+#define SHF_DC 0x21a /* shift-delete on keypad */
+
+#define KEY_MOUSE 0x21b /* "mouse" key */
+#define KEY_SHIFT_L 0x21c /* Left-shift */
+#define KEY_SHIFT_R 0x21d /* Right-shift */
+#define KEY_CONTROL_L 0x21e /* Left-control */
+#define KEY_CONTROL_R 0x21f /* Right-control */
+#define KEY_ALT_L 0x220 /* Left-alt */
+#define KEY_ALT_R 0x221 /* Right-alt */
+#define KEY_RESIZE 0x222 /* Window resize */
+#define KEY_SUP 0x223 /* Shifted up arrow */
+#define KEY_SDOWN 0x224 /* Shifted down arrow */
+
+#define KEY_MIN KEY_BREAK /* Minimum curses key value */
+#define KEY_MAX KEY_SDOWN /* Maximum curses key */
+
+#define KEY_F(n) (KEY_F0 + (n))
+
+/*----------------------------------------------------------------------
+ *
+ * PDCurses Function Declarations
+ *
+ */
+
+/* Standard */
+
+int addch(const chtype);
+int addchnstr(const chtype *, int);
+int addchstr(const chtype *);
+int addnstr(const char *, int);
+int addstr(const char *);
+int attroff(chtype);
+int attron(chtype);
+int attrset(chtype);
+int attr_get(attr_t *, short *, void *);
+int attr_off(attr_t, void *);
+int attr_on(attr_t, void *);
+int attr_set(attr_t, short, void *);
+int baudrate(void);
+int beep(void);
+int bkgd(chtype);
+void bkgdset(chtype);
+int border(chtype, chtype, chtype, chtype, chtype, chtype, chtype, chtype);
+int box(WINDOW *, chtype, chtype);
+bool can_change_color(void);
+int cbreak(void);
+int chgat(int, attr_t, short, const void *);
+int clearok(WINDOW *, bool);
+int clear(void);
+int clrtobot(void);
+int clrtoeol(void);
+int color_content(short, short *, short *, short *);
+int color_set(short, void *);
+int copywin(const WINDOW *, WINDOW *, int, int, int, int, int, int, int);
+int curs_set(int);
+int def_prog_mode(void);
+int def_shell_mode(void);
+int delay_output(int);
+int delch(void);
+int deleteln(void);
+void delscreen(SCREEN *);
+int delwin(WINDOW *);
+WINDOW *derwin(WINDOW *, int, int, int, int);
+int doupdate(void);
+WINDOW *dupwin(WINDOW *);
+int echochar(const chtype);
+int echo(void);
+int endwin(void);
+char erasechar(void);
+int erase(void);
+void filter(void);
+int flash(void);
+int flushinp(void);
+chtype getbkgd(WINDOW *);
+int getnstr(char *, int);
+int getstr(char *);
+WINDOW *getwin(FILE *);
+int halfdelay(int);
+bool has_colors(void);
+bool has_ic(void);
+bool has_il(void);
+int hline(chtype, int);
+void idcok(WINDOW *, bool);
+int idlok(WINDOW *, bool);
+void immedok(WINDOW *, bool);
+int inchnstr(chtype *, int);
+int inchstr(chtype *);
+chtype inch(void);
+int init_color(short, short, short, short);
+int init_pair(short, short, short);
+WINDOW *initscr(void);
+int innstr(char *, int);
+int insch(chtype);
+int insdelln(int);
+int insertln(void);
+int insnstr(const char *, int);
+int insstr(const char *);
+int instr(char *);
+int intrflush(WINDOW *, bool);
+bool isendwin(void);
+bool is_linetouched(WINDOW *, int);
+bool is_wintouched(WINDOW *);
+char *keyname(int);
+int keypad(WINDOW *, bool);
+char killchar(void);
+int leaveok(WINDOW *, bool);
+char *longname(void);
+int meta(WINDOW *, bool);
+int move(int, int);
+int mvaddch(int, int, const chtype);
+int mvaddchnstr(int, int, const chtype *, int);
+int mvaddchstr(int, int, const chtype *);
+int mvaddnstr(int, int, const char *, int);
+int mvaddstr(int, int, const char *);
+int mvchgat(int, int, int, attr_t, short, const void *);
+int mvcur(int, int, int, int);
+int mvdelch(int, int);
+int mvderwin(WINDOW *, int, int);
+int mvgetch(int, int);
+int mvgetnstr(int, int, char *, int);
+int mvgetstr(int, int, char *);
+int mvhline(int, int, chtype, int);
+chtype mvinch(int, int);
+int mvinchnstr(int, int, chtype *, int);
+int mvinchstr(int, int, chtype *);
+int mvinnstr(int, int, char *, int);
+int mvinsch(int, int, chtype);
+int mvinsnstr(int, int, const char *, int);
+int mvinsstr(int, int, const char *);
+int mvinstr(int, int, char *);
+int mvprintw(int, int, const char *, ...);
+int mvscanw(int, int, const char *, ...);
+int mvvline(int, int, chtype, int);
+int mvwaddchnstr(WINDOW *, int, int, const chtype *, int);
+int mvwaddchstr(WINDOW *, int, int, const chtype *);
+int mvwaddch(WINDOW *, int, int, const chtype);
+int mvwaddnstr(WINDOW *, int, int, const char *, int);
+int mvwaddstr(WINDOW *, int, int, const char *);
+int mvwchgat(WINDOW *, int, int, int, attr_t, short, const void *);
+int mvwdelch(WINDOW *, int, int);
+int mvwgetch(WINDOW *, int, int);
+int mvwgetnstr(WINDOW *, int, int, char *, int);
+int mvwgetstr(WINDOW *, int, int, char *);
+int mvwhline(WINDOW *, int, int, chtype, int);
+int mvwinchnstr(WINDOW *, int, int, chtype *, int);
+int mvwinchstr(WINDOW *, int, int, chtype *);
+chtype mvwinch(WINDOW *, int, int);
+int mvwinnstr(WINDOW *, int, int, char *, int);
+int mvwinsch(WINDOW *, int, int, chtype);
+int mvwinsnstr(WINDOW *, int, int, const char *, int);
+int mvwinsstr(WINDOW *, int, int, const char *);
+int mvwinstr(WINDOW *, int, int, char *);
+int mvwin(WINDOW *, int, int);
+int mvwprintw(WINDOW *, int, int, const char *, ...);
+int mvwscanw(WINDOW *, int, int, const char *, ...);
+int mvwvline(WINDOW *, int, int, chtype, int);
+int napms(int);
+WINDOW *newpad(int, int);
+SCREEN *newterm(const char *, FILE *, FILE *);
+WINDOW *newwin(int, int, int, int);
+int nl(void);
+int nocbreak(void);
+int nodelay(WINDOW *, bool);
+int noecho(void);
+int nonl(void);
+void noqiflush(void);
+int noraw(void);
+int notimeout(WINDOW *, bool);
+int overlay(const WINDOW *, WINDOW *);
+int overwrite(const WINDOW *, WINDOW *);
+int pair_content(short, short *, short *);
+int pechochar(WINDOW *, chtype);
+int pnoutrefresh(WINDOW *, int, int, int, int, int, int);
+int prefresh(WINDOW *, int, int, int, int, int, int);
+int printw(const char *, ...);
+int putwin(WINDOW *, FILE *);
+void qiflush(void);
+int raw(void);
+int redrawwin(WINDOW *);
+int refresh(void);
+int reset_prog_mode(void);
+int reset_shell_mode(void);
+int resetty(void);
+int ripoffline(int, int (*)(WINDOW *, int));
+int savetty(void);
+int scanw(const char *, ...);
+int scr_dump(const char *);
+int scr_init(const char *);
+int scr_restore(const char *);
+int scr_set(const char *);
+int scrl(int);
+int scroll(WINDOW *);
+int scrollok(WINDOW *, bool);
+SCREEN *set_term(SCREEN *);
+int setscrreg(int, int);
+int slk_attroff(const chtype);
+int slk_attr_off(const attr_t, void *);
+int slk_attron(const chtype);
+int slk_attr_on(const attr_t, void *);
+int slk_attrset(const chtype);
+int slk_attr_set(const attr_t, short, void *);
+int slk_clear(void);
+int slk_color(short);
+int slk_init(int);
+char *slk_label(int);
+int slk_noutrefresh(void);
+int slk_refresh(void);
+int slk_restore(void);
+int slk_set(int, const char *, int);
+int slk_touch(void);
+int standend(void);
+int standout(void);
+int start_color(void);
+WINDOW *subpad(WINDOW *, int, int, int, int);
+WINDOW *subwin(WINDOW *, int, int, int, int);
+int syncok(WINDOW *, bool);
+chtype termattrs(void);
+attr_t term_attrs(void);
+char *termname(void);
+void timeout(int);
+int touchline(WINDOW *, int, int);
+int touchwin(WINDOW *);
+int typeahead(int);
+int untouchwin(WINDOW *);
+void use_env(bool);
+int vidattr(chtype);
+int vid_attr(attr_t, short, void *);
+int vidputs(chtype, int (*)(int));
+int vid_puts(attr_t, short, void *, int (*)(int));
+int vline(chtype, int);
+int vw_printw(WINDOW *, const char *, va_list);
+int vwprintw(WINDOW *, const char *, va_list);
+int vw_scanw(WINDOW *, const char *, va_list);
+int vwscanw(WINDOW *, const char *, va_list);
+int waddchnstr(WINDOW *, const chtype *, int);
+int waddchstr(WINDOW *, const chtype *);
+int waddch(WINDOW *, const chtype);
+int waddnstr(WINDOW *, const char *, int);
+int waddstr(WINDOW *, const char *);
+int wattroff(WINDOW *, chtype);
+int wattron(WINDOW *, chtype);
+int wattrset(WINDOW *, chtype);
+int wattr_get(WINDOW *, attr_t *, short *, void *);
+int wattr_off(WINDOW *, attr_t, void *);
+int wattr_on(WINDOW *, attr_t, void *);
+int wattr_set(WINDOW *, attr_t, short, void *);
+void wbkgdset(WINDOW *, chtype);
+int wbkgd(WINDOW *, chtype);
+int wborder(WINDOW *, chtype, chtype, chtype, chtype,
+ chtype, chtype, chtype, chtype);
+int wchgat(WINDOW *, int, attr_t, short, const void *);
+int wclear(WINDOW *);
+int wclrtobot(WINDOW *);
+int wclrtoeol(WINDOW *);
+int wcolor_set(WINDOW *, short, void *);
+void wcursyncup(WINDOW *);
+int wdelch(WINDOW *);
+int wdeleteln(WINDOW *);
+int wechochar(WINDOW *, const chtype);
+int werase(WINDOW *);
+int wgetch(WINDOW *);
+int wgetnstr(WINDOW *, char *, int);
+int wgetstr(WINDOW *, char *);
+int whline(WINDOW *, chtype, int);
+int winchnstr(WINDOW *, chtype *, int);
+int winchstr(WINDOW *, chtype *);
+chtype winch(WINDOW *);
+int winnstr(WINDOW *, char *, int);
+int winsch(WINDOW *, chtype);
+int winsdelln(WINDOW *, int);
+int winsertln(WINDOW *);
+int winsnstr(WINDOW *, const char *, int);
+int winsstr(WINDOW *, const char *);
+int winstr(WINDOW *, char *);
+int wmove(WINDOW *, int, int);
+int wnoutrefresh(WINDOW *);
+int wprintw(WINDOW *, const char *, ...);
+int wredrawln(WINDOW *, int, int);
+int wrefresh(WINDOW *);
+int wscanw(WINDOW *, const char *, ...);
+int wscrl(WINDOW *, int);
+int wsetscrreg(WINDOW *, int, int);
+int wstandend(WINDOW *);
+int wstandout(WINDOW *);
+void wsyncdown(WINDOW *);
+void wsyncup(WINDOW *);
+void wtimeout(WINDOW *, int);
+int wtouchln(WINDOW *, int, int, int);
+int wvline(WINDOW *, chtype, int);
+
+/* Wide-character functions */
+
+#ifdef PDC_WIDE
+int addnwstr(const wchar_t *, int);
+int addwstr(const wchar_t *);
+int add_wch(const cchar_t *);
+int add_wchnstr(const cchar_t *, int);
+int add_wchstr(const cchar_t *);
+int border_set(const cchar_t *, const cchar_t *, const cchar_t *,
+ const cchar_t *, const cchar_t *, const cchar_t *,
+ const cchar_t *, const cchar_t *);
+int box_set(WINDOW *, const cchar_t *, const cchar_t *);
+int echo_wchar(const cchar_t *);
+int erasewchar(wchar_t *);
+int getbkgrnd(cchar_t *);
+int getcchar(const cchar_t *, wchar_t *, attr_t *, short *, void *);
+int getn_wstr(wint_t *, int);
+int get_wch(wint_t *);
+int get_wstr(wint_t *);
+int hline_set(const cchar_t *, int);
+int innwstr(wchar_t *, int);
+int ins_nwstr(const wchar_t *, int);
+int ins_wch(const cchar_t *);
+int ins_wstr(const wchar_t *);
+int inwstr(wchar_t *);
+int in_wch(cchar_t *);
+int in_wchnstr(cchar_t *, int);
+int in_wchstr(cchar_t *);
+char *key_name(wchar_t);
+int killwchar(wchar_t *);
+int mvaddnwstr(int, int, const wchar_t *, int);
+int mvaddwstr(int, int, const wchar_t *);
+int mvadd_wch(int, int, const cchar_t *);
+int mvadd_wchnstr(int, int, const cchar_t *, int);
+int mvadd_wchstr(int, int, const cchar_t *);
+int mvgetn_wstr(int, int, wint_t *, int);
+int mvget_wch(int, int, wint_t *);
+int mvget_wstr(int, int, wint_t *);
+int mvhline_set(int, int, const cchar_t *, int);
+int mvinnwstr(int, int, wchar_t *, int);
+int mvins_nwstr(int, int, const wchar_t *, int);
+int mvins_wch(int, int, const cchar_t *);
+int mvins_wstr(int, int, const wchar_t *);
+int mvinwstr(int, int, wchar_t *);
+int mvin_wch(int, int, cchar_t *);
+int mvin_wchnstr(int, int, cchar_t *, int);
+int mvin_wchstr(int, int, cchar_t *);
+int mvvline_set(int, int, const cchar_t *, int);
+int mvwaddnwstr(WINDOW *, int, int, const wchar_t *, int);
+int mvwaddwstr(WINDOW *, int, int, const wchar_t *);
+int mvwadd_wch(WINDOW *, int, int, const cchar_t *);
+int mvwadd_wchnstr(WINDOW *, int, int, const cchar_t *, int);
+int mvwadd_wchstr(WINDOW *, int, int, const cchar_t *);
+int mvwgetn_wstr(WINDOW *, int, int, wint_t *, int);
+int mvwget_wch(WINDOW *, int, int, wint_t *);
+int mvwget_wstr(WINDOW *, int, int, wint_t *);
+int mvwhline_set(WINDOW *, int, int, const cchar_t *, int);
+int mvwinnwstr(WINDOW *, int, int, wchar_t *, int);
+int mvwins_nwstr(WINDOW *, int, int, const wchar_t *, int);
+int mvwins_wch(WINDOW *, int, int, const cchar_t *);
+int mvwins_wstr(WINDOW *, int, int, const wchar_t *);
+int mvwin_wch(WINDOW *, int, int, cchar_t *);
+int mvwin_wchnstr(WINDOW *, int, int, cchar_t *, int);
+int mvwin_wchstr(WINDOW *, int, int, cchar_t *);
+int mvwinwstr(WINDOW *, int, int, wchar_t *);
+int mvwvline_set(WINDOW *, int, int, const cchar_t *, int);
+int pecho_wchar(WINDOW *, const cchar_t*);
+int setcchar(cchar_t*, const wchar_t*, const attr_t, short, const void*);
+int slk_wset(int, const wchar_t *, int);
+int unget_wch(const wchar_t);
+int vline_set(const cchar_t *, int);
+int waddnwstr(WINDOW *, const wchar_t *, int);
+int waddwstr(WINDOW *, const wchar_t *);
+int wadd_wch(WINDOW *, const cchar_t *);
+int wadd_wchnstr(WINDOW *, const cchar_t *, int);
+int wadd_wchstr(WINDOW *, const cchar_t *);
+int wbkgrnd(WINDOW *, const cchar_t *);
+void wbkgrndset(WINDOW *, const cchar_t *);
+int wborder_set(WINDOW *, const cchar_t *, const cchar_t *,
+ const cchar_t *, const cchar_t *, const cchar_t *,
+ const cchar_t *, const cchar_t *, const cchar_t *);
+int wecho_wchar(WINDOW *, const cchar_t *);
+int wgetbkgrnd(WINDOW *, cchar_t *);
+int wgetn_wstr(WINDOW *, wint_t *, int);
+int wget_wch(WINDOW *, wint_t *);
+int wget_wstr(WINDOW *, wint_t *);
+int whline_set(WINDOW *, const cchar_t *, int);
+int winnwstr(WINDOW *, wchar_t *, int);
+int wins_nwstr(WINDOW *, const wchar_t *, int);
+int wins_wch(WINDOW *, const cchar_t *);
+int wins_wstr(WINDOW *, const wchar_t *);
+int winwstr(WINDOW *, wchar_t *);
+int win_wch(WINDOW *, cchar_t *);
+int win_wchnstr(WINDOW *, cchar_t *, int);
+int win_wchstr(WINDOW *, cchar_t *);
+wchar_t *wunctrl(cchar_t *);
+int wvline_set(WINDOW *, const cchar_t *, int);
+#endif
+
+/* Quasi-standard */
+
+chtype getattrs(WINDOW *);
+int getbegx(WINDOW *);
+int getbegy(WINDOW *);
+int getmaxx(WINDOW *);
+int getmaxy(WINDOW *);
+int getparx(WINDOW *);
+int getpary(WINDOW *);
+int getcurx(WINDOW *);
+int getcury(WINDOW *);
+void traceoff(void);
+void traceon(void);
+char *unctrl(chtype);
+
+int crmode(void);
+int nocrmode(void);
+int draino(int);
+int resetterm(void);
+int fixterm(void);
+int saveterm(void);
+int setsyx(int, int);
+
+int mouse_set(unsigned long);
+int mouse_on(unsigned long);
+int mouse_off(unsigned long);
+int request_mouse_pos(void);
+int map_button(unsigned long);
+void wmouse_position(WINDOW *, int *, int *);
+unsigned long getmouse(void);
+unsigned long getbmap(void);
+
+/* ncurses */
+
+int assume_default_colors(int, int);
+const char *curses_version(void);
+bool has_key(int);
+int use_default_colors(void);
+int wresize(WINDOW *, int, int);
+
+int mouseinterval(int);
+mmask_t mousemask(mmask_t, mmask_t *);
+bool mouse_trafo(int *, int *, bool);
+int nc_getmouse(MEVENT *);
+int ungetmouse(MEVENT *);
+bool wenclose(const WINDOW *, int, int);
+bool wmouse_trafo(const WINDOW *, int *, int *, bool);
+
+/* PDCurses */
+
+int addrawch(chtype);
+int insrawch(chtype);
+bool is_termresized(void);
+int mvaddrawch(int, int, chtype);
+int mvdeleteln(int, int);
+int mvinsertln(int, int);
+int mvinsrawch(int, int, chtype);
+int mvwaddrawch(WINDOW *, int, int, chtype);
+int mvwdeleteln(WINDOW *, int, int);
+int mvwinsertln(WINDOW *, int, int);
+int mvwinsrawch(WINDOW *, int, int, chtype);
+int raw_output(bool);
+int resize_term(int, int);
+WINDOW *resize_window(WINDOW *, int, int);
+int waddrawch(WINDOW *, chtype);
+int winsrawch(WINDOW *, chtype);
+char wordchar(void);
+
+#ifdef PDC_WIDE
+wchar_t *slk_wlabel(int);
+#endif
+
+void PDC_debug(const char *, ...);
+int PDC_ungetch(int);
+int PDC_set_blink(bool);
+int PDC_set_line_color(short);
+void PDC_set_title(const char *);
+
+int PDC_clearclipboard(void);
+int PDC_freeclipboard(char *);
+int PDC_getclipboard(char **, long *);
+int PDC_setclipboard(const char *, long);
+
+unsigned long PDC_get_input_fd(void);
+unsigned long PDC_get_key_modifiers(void);
+int PDC_return_key_modifiers(bool);
+int PDC_save_key_modifiers(bool);
+
+#ifdef XCURSES
+WINDOW *Xinitscr(int, char **);
+void XCursesExit(void);
+int sb_init(void);
+int sb_set_horz(int, int, int);
+int sb_set_vert(int, int, int);
+int sb_get_horz(int *, int *, int *);
+int sb_get_vert(int *, int *, int *);
+int sb_refresh(void);
+#endif
+
+/*** Functions defined as macros ***/
+
+/* getch() and ungetch() conflict with some DOS libraries */
+
+#define getch() wgetch(stdscr)
+#define ungetch(ch) PDC_ungetch(ch)
+
+#define COLOR_PAIR(n) (((chtype)(n) << PDC_COLOR_SHIFT) & A_COLOR)
+#define PAIR_NUMBER(n) (((n) & A_COLOR) >> PDC_COLOR_SHIFT)
+
+/* These will _only_ work as macros */
+
+#define getbegyx(w, y, x) (y = getbegy(w), x = getbegx(w))
+#define getmaxyx(w, y, x) (y = getmaxy(w), x = getmaxx(w))
+#define getparyx(w, y, x) (y = getpary(w), x = getparx(w))
+#define getyx(w, y, x) (y = getcury(w), x = getcurx(w))
+
+#define getsyx(y, x) { if (curscr->_leaveit) (y)=(x)=-1; \
+ else getyx(curscr,(y),(x)); }
+
+#ifdef NCURSES_MOUSE_VERSION
+# define getmouse(x) nc_getmouse(x)
+#endif
+
+/* return codes from PDC_getclipboard() and PDC_setclipboard() calls */
+
+#define PDC_CLIP_SUCCESS 0
+#define PDC_CLIP_ACCESS_ERROR 1
+#define PDC_CLIP_EMPTY 2
+#define PDC_CLIP_MEMORY_ERROR 3
+
+/* PDCurses key modifier masks */
+
+#define PDC_KEY_MODIFIER_SHIFT 1
+#define PDC_KEY_MODIFIER_CONTROL 2
+#define PDC_KEY_MODIFIER_ALT 4
+#define PDC_KEY_MODIFIER_NUMLOCK 8
+
+#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
+# undef bool
+}
+#endif
+
+#endif /* __PDCURSES__ */
diff --git a/payloads/libpayload/curses/PDCurses-3.4/curspriv.h b/payloads/libpayload/curses/PDCurses-3.4/curspriv.h
new file mode 100644
index 0000000000..8b34f010ce
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/curspriv.h
@@ -0,0 +1,142 @@
+/* Public Domain Curses */
+
+/* $Id: curspriv.h,v 1.158 2008/07/13 16:08:16 wmcbrine Exp $ */
+
+/* Private definitions and declarations for use within PDCurses.
+ These should generally not be referenced by applications. */
+
+#ifndef __CURSES_INTERNALS__
+#define __CURSES_INTERNALS__ 1
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#define CURSES_LIBRARY
+#include <curses.h>
+
+#if defined(__TURBOC__) || defined(__EMX__) || defined(__DJGPP__) || \
+ defined(__CYGWIN32__) || defined(__MINGW32__) || \
+ defined(__WATCOMC__) || defined(__PACIFIC__)
+# ifndef HAVE_VSSCANF
+# define HAVE_VSSCANF /* have vsscanf() */
+# endif
+#endif
+
+#if defined(__CYGWIN32__) || defined(__MINGW32__) || \
+ defined(__LCC__) || defined(__WATCOMC__)
+# ifndef HAVE_VSNPRINTF
+# define HAVE_VSNPRINTF /* have vsnprintf() */
+# endif
+#endif
+
+#if defined(_MSC_VER) && defined(_WIN32) && !defined(_CRT_SECURE_NO_DEPRECATE)
+# define _CRT_SECURE_NO_DEPRECATE 1 /* kill nonsense warnings */
+#endif
+
+/*----------------------------------------------------------------------*/
+
+typedef struct /* structure for ripped off lines */
+{
+ int line;
+ int (*init)(WINDOW *, int);
+} RIPPEDOFFLINE;
+
+/* Window properties */
+
+#define _SUBWIN 0x01 /* window is a subwindow */
+#define _PAD 0x10 /* X/Open Pad. */
+#define _SUBPAD 0x20 /* X/Open subpad. */
+
+/* Miscellaneous */
+
+#define _NO_CHANGE -1 /* flags line edge unchanged */
+
+#define _ECHAR 0x08 /* Erase char (^H) */
+#define _DWCHAR 0x17 /* Delete Word char (^W) */
+#define _DLCHAR 0x15 /* Delete Line char (^U) */
+
+extern WINDOW *pdc_lastscr;
+extern bool pdc_trace_on; /* tracing flag */
+extern bool pdc_color_started;
+extern unsigned long pdc_key_modifiers;
+extern MOUSE_STATUS pdc_mouse_status;
+
+/*----------------------------------------------------------------------*/
+
+/* Platform implementation functions */
+
+void PDC_beep(void);
+bool PDC_can_change_color(void);
+int PDC_color_content(short, short *, short *, short *);
+bool PDC_check_key(void);
+int PDC_curs_set(int);
+void PDC_flushinp(void);
+int PDC_get_columns(void);
+int PDC_get_cursor_mode(void);
+int PDC_get_key(void);
+int PDC_get_rows(void);
+void PDC_gotoyx(int, int);
+int PDC_init_color(short, short, short, short);
+void PDC_init_pair(short, short, short);
+int PDC_modifiers_set(void);
+int PDC_mouse_set(void);
+void PDC_napms(int);
+int PDC_pair_content(short, short *, short *);
+void PDC_reset_prog_mode(void);
+void PDC_reset_shell_mode(void);
+int PDC_resize_screen(int, int);
+void PDC_restore_screen_mode(int);
+void PDC_save_screen_mode(int);
+void PDC_scr_close(void);
+void PDC_scr_free(void);
+int PDC_scr_open(int, char **);
+void PDC_set_keyboard_binary(bool);
+void PDC_transform_line(int, int, int, const chtype *);
+const char *PDC_sysname(void);
+
+/* Internal cross-module functions */
+
+void PDC_init_atrtab(void);
+WINDOW *PDC_makelines(WINDOW *);
+WINDOW *PDC_makenew(int, int, int, int);
+int PDC_mouse_in_slk(int, int);
+void PDC_slk_free(void);
+void PDC_slk_initialize(void);
+void PDC_sync(WINDOW *);
+
+#ifdef PDC_WIDE
+int PDC_mbtowc(wchar_t *, const char *, size_t);
+size_t PDC_mbstowcs(wchar_t *, const char *, size_t);
+size_t PDC_wcstombs(char *, const wchar_t *, size_t);
+#endif
+
+#ifdef PDCDEBUG
+# define PDC_LOG(x) if (pdc_trace_on) PDC_debug x
+# define RCSID(x) static const char *rcsid = x;
+#else
+# define PDC_LOG(x)
+# define RCSID(x)
+#endif
+
+/* Internal macros for attributes */
+
+#ifdef CHTYPE_LONG
+# define PDC_COLOR_PAIRS 256
+#else
+# define PDC_COLOR_PAIRS 32
+#endif
+
+#ifndef max
+# define max(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+#ifndef min
+# define min(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#define DIVROUND(num, divisor) ((num) + ((divisor) >> 1)) / (divisor)
+
+#define PDC_CLICK_PERIOD 150 /* time to wait for a click, if
+ not set by mouseinterval() */
+
+#endif /* __CURSES_INTERNALS__*/
diff --git a/payloads/libpayload/curses/PDCurses-3.4/demos/README b/payloads/libpayload/curses/PDCurses-3.4/demos/README
new file mode 100644
index 0000000000..8f4b5c6c23
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/demos/README
@@ -0,0 +1,25 @@
+PDCurses Demos
+==============
+
+This directory contains demonstration programs to show and test the
+capabilities of curses libraries. Some of them predate PDCurses,
+PCcurses or even pcurses/ncurses. Although some PDCurses-specific code
+has been added, all programs remain portable to other implementations
+(at a minimum, to ncurses).
+
+
+Building
+--------
+
+The demos are built by the platform-specific makefiles, in the platform
+directories. Alternatively, you can build them manually, individually,
+and link with any curses library; e.g., "cc -lcurses -orain rain.c".
+There are no dependencies besides curses and the standard C library, and
+no configuration is needed.
+
+
+Distribution Status
+-------------------
+
+Public Domain, except for rain.c and worm.c, which are under the ncurses
+license (MIT-like).
diff --git a/payloads/libpayload/curses/PDCurses-3.4/demos/firework.c b/payloads/libpayload/curses/PDCurses-3.4/demos/firework.c
new file mode 100644
index 0000000000..8d7921f3df
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/demos/firework.c
@@ -0,0 +1,148 @@
+/* $Id: firework.c,v 1.25 2008/07/13 16:08:17 wmcbrine Exp $ */
+
+#include <stdio.h>
+#include <signal.h>
+#include <curses.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <time.h>
+
+#define DELAYSIZE 200
+
+void myrefresh(void);
+void get_color(void);
+void explode(int, int);
+
+short color_table[] =
+{
+ COLOR_RED, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN,
+ COLOR_RED, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE
+};
+
+int main(int argc, char **argv)
+{
+ int i, start, end, row, diff, flag, direction, seed;
+
+#ifdef XCURSES
+ Xinitscr(argc, argv);
+#else
+ initscr();
+#endif
+ nodelay(stdscr, TRUE);
+ noecho();
+
+ if (has_colors())
+ start_color();
+
+ for (i = 0; i < 8; i++)
+ init_pair(i, color_table[i], COLOR_BLACK);
+
+ seed = time((time_t *)0);
+ srand(seed);
+ flag = 0;
+
+ while (getch() == ERR) /* loop until a key is hit */
+ {
+ do {
+ start = rand() % (COLS - 3);
+ end = rand() % (COLS - 3);
+ start = (start < 2) ? 2 : start;
+ end = (end < 2) ? 2 : end;
+ direction = (start > end) ? -1 : 1;
+ diff = abs(start - end);
+
+ } while (diff < 2 || diff >= LINES - 2);
+
+ attrset(A_NORMAL);
+
+ for (row = 0; row < diff; row++)
+ {
+ mvaddstr(LINES - row, row * direction + start,
+ (direction < 0) ? "\\" : "/");
+
+ if (flag++)
+ {
+ myrefresh();
+ erase();
+ flag = 0;
+ }
+ }
+
+ if (flag++)
+ {
+ myrefresh();
+ flag = 0;
+ }
+
+ explode(LINES - row, diff * direction + start);
+ erase();
+ myrefresh();
+ }
+
+ endwin();
+
+ return 0;
+}
+
+void explode(int row, int col)
+{
+ erase();
+ mvaddstr(row, col, "-");
+ myrefresh();
+
+ --col;
+
+ get_color();
+ mvaddstr(row - 1, col, " - ");
+ mvaddstr(row, col, "-+-");
+ mvaddstr(row + 1, col, " - ");
+ myrefresh();
+
+ --col;
+
+ get_color();
+ mvaddstr(row - 2, col, " --- ");
+ mvaddstr(row - 1, col, "-+++-");
+ mvaddstr(row, col, "-+#+-");
+ mvaddstr(row + 1, col, "-+++-");
+ mvaddstr(row + 2, col, " --- ");
+ myrefresh();
+
+ get_color();
+ mvaddstr(row - 2, col, " +++ ");
+ mvaddstr(row - 1, col, "++#++");
+ mvaddstr(row, col, "+# #+");
+ mvaddstr(row + 1, col, "++#++");
+ mvaddstr(row + 2, col, " +++ ");
+ myrefresh();
+
+ get_color();
+ mvaddstr(row - 2, col, " # ");
+ mvaddstr(row - 1, col, "## ##");
+ mvaddstr(row, col, "# #");
+ mvaddstr(row + 1, col, "## ##");
+ mvaddstr(row + 2, col, " # ");
+ myrefresh();
+
+ get_color();
+ mvaddstr(row - 2, col, " # # ");
+ mvaddstr(row - 1, col, "# #");
+ mvaddstr(row, col, " ");
+ mvaddstr(row + 1, col, "# #");
+ mvaddstr(row + 2, col, " # # ");
+ myrefresh();
+}
+
+void myrefresh(void)
+{
+ napms(DELAYSIZE);
+ move(LINES - 1, COLS - 1);
+ refresh();
+}
+
+void get_color(void)
+{
+ chtype bold = (rand() % 2) ? A_BOLD : A_NORMAL;
+ attrset(COLOR_PAIR(rand() % 8) | bold);
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/demos/newdemo.c b/payloads/libpayload/curses/PDCurses-3.4/demos/newdemo.c
new file mode 100644
index 0000000000..3eae98d439
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/demos/newdemo.c
@@ -0,0 +1,425 @@
+/*
+ * newdemo.c - A demo program using PDCurses. The program
+ * illustrates the use of colors for text output.
+ *
+ * Hacks by jbuhler@cs.washington.edu on 12/29/96
+ *
+ * $Id: newdemo.c,v 1.39 2008/07/13 16:08:17 wmcbrine Exp $
+ */
+
+#include <stdio.h>
+#include <signal.h>
+#include <string.h>
+#include <curses.h>
+#include <stdlib.h>
+#include <time.h>
+
+int WaitForUser(void);
+int SubWinTest(WINDOW *);
+int BouncingBalls(WINDOW *);
+void trap(int);
+
+/* An ASCII map of Australia */
+
+char *AusMap[17] =
+{
+ " A ",
+ " AA AA ",
+ " N.T. AAAAA AAAA ",
+ " AAAAAAAAAAA AAAAAAAA ",
+ " AAAAAAAAAAAAAAAAAAAAAAAAA Qld.",
+ " AAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
+ " AAAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
+ " AAAAAAAAAAAAAAAAAAAAAAAAAAAA ",
+ " AAAAAAAAAAAAAAAAAAAAAAAAA N.S.W.",
+ "W.A. AAAAAAAAA AAAAAA Vic.",
+ " AAA S.A. AA",
+ " A Tas.",
+ ""
+};
+
+/* Funny messages for the scroller */
+
+char *messages[] =
+{
+ "Hello from the Land Down Under",
+ "The Land of crocs, and a big Red Rock",
+ "Where the sunflower runs along the highways",
+ "The dusty red roads lead one to loneliness",
+ "Blue sky in the morning and",
+ "Freezing nights and twinkling stars",
+ NULL
+};
+
+int WaitForUser(void)
+{
+ chtype ch;
+
+ nodelay(stdscr, TRUE);
+ halfdelay(50);
+
+ ch = getch();
+
+ nodelay(stdscr, FALSE);
+ nocbreak(); /* Reset the halfdelay() value */
+ cbreak();
+
+ return (ch == '\033') ? ch : 0;
+}
+
+int SubWinTest(WINDOW *win)
+{
+ WINDOW *swin1, *swin2, *swin3;
+ int w, h, sw, sh, bx, by;
+
+ wattrset(win, 0);
+ getmaxyx(win, h, w);
+ getbegyx(win, by, bx);
+
+ sw = w / 3;
+ sh = h / 3;
+
+ if ((swin1 = derwin(win, sh, sw, 3, 5)) == NULL)
+ return 1;
+ if ((swin2 = subwin(win, sh, sw, by + 4, bx + 8)) == NULL)
+ return 1;
+ if ((swin3 = subwin(win, sh, sw, by + 5, bx + 11)) == NULL)
+ return 1;
+
+ init_pair(8, COLOR_RED, COLOR_BLUE);
+ wbkgd(swin1, COLOR_PAIR(8));
+ werase(swin1);
+ mvwaddstr(swin1, 0, 3, "Sub-window 1");
+ wrefresh(swin1);
+
+ init_pair(9, COLOR_CYAN, COLOR_MAGENTA);
+ wbkgd(swin2, COLOR_PAIR(9));
+ werase(swin2);
+ mvwaddstr(swin2, 0, 3, "Sub-window 2");
+ wrefresh(swin2);
+
+ init_pair(10, COLOR_YELLOW, COLOR_GREEN);
+ wbkgd(swin3, COLOR_PAIR(10));
+ werase(swin3);
+ mvwaddstr(swin3, 0, 3, "Sub-window 3");
+ wrefresh(swin3);
+
+ delwin(swin1);
+ delwin(swin2);
+ delwin(swin3);
+ WaitForUser();
+
+ return 0;
+}
+
+int BouncingBalls(WINDOW *win)
+{
+ chtype c1, c2, c3, ball1, ball2, ball3;
+ int w, h, x1, y1, xd1, yd1, x2, y2, xd2, yd2, x3, y3, xd3, yd3, c;
+
+ curs_set(0);
+
+ wbkgd(win, COLOR_PAIR(1));
+ wrefresh(win);
+ wattrset(win, 0);
+
+ init_pair(11, COLOR_RED, COLOR_GREEN);
+ init_pair(12, COLOR_BLUE, COLOR_RED);
+ init_pair(13, COLOR_YELLOW, COLOR_WHITE);
+
+ ball1 = 'O' | COLOR_PAIR(11);
+ ball2 = '*' | COLOR_PAIR(12);
+ ball3 = '@' | COLOR_PAIR(13);
+
+ getmaxyx(win, h, w);
+
+ x1 = 2 + rand() % (w - 4);
+ y1 = 2 + rand() % (h - 4);
+ x2 = 2 + rand() % (w - 4);
+ y2 = 2 + rand() % (h - 4);
+ x3 = 2 + rand() % (w - 4);
+ y3 = 2 + rand() % (h - 4);
+
+ xd1 = 1;
+ yd1 = 1;
+ xd2 = 1;
+ yd2 = -1;
+ xd3 = -1;
+ yd3 = 1;
+
+ nodelay(stdscr, TRUE);
+
+ while ((c = getch()) == ERR)
+ {
+ x1 += xd1;
+ if (x1 <= 1 || x1 >= w - 2)
+ xd1 *= -1;
+
+ y1 += yd1;
+ if (y1 <= 1 || y1 >= h - 2)
+ yd1 *= -1;
+
+ x2 += xd2;
+ if (x2 <= 1 || x2 >= w - 2)
+ xd2 *= -1;
+
+ y2 += yd2;
+ if (y2 <= 1 || y2 >= h - 2)
+ yd2 *= -1;
+
+ x3 += xd3;
+ if (x3 <= 1 || x3 >= w - 2)
+ xd3 *= -1;
+
+ y3 += yd3;
+ if (y3 <= 1 || y3 >= h - 2)
+ yd3 *= -1;
+
+ c1 = mvwinch(win, y1, x1);
+ c2 = mvwinch(win, y2, x2);
+ c3 = mvwinch(win, y3, x3);
+
+ mvwaddch(win, y1, x1, ball1);
+ mvwaddch(win, y2, x2, ball2);
+ mvwaddch(win, y3, x3, ball3);
+
+ wmove(win, 0, 0);
+ wrefresh(win);
+
+ mvwaddch(win, y1, x1, c1);
+ mvwaddch(win, y2, x2, c2);
+ mvwaddch(win, y3, x3, c3);
+
+ napms(150);
+ }
+
+ nodelay(stdscr, FALSE);
+ ungetch(c);
+ return 0;
+}
+
+/* Trap interrupt */
+
+void trap(int sig)
+{
+ if (sig == SIGINT)
+ {
+ endwin();
+
+ exit(0);
+ }
+}
+
+int main(int argc, char **argv)
+{
+ WINDOW *win;
+ chtype save[80], ch;
+ int width, height, w, x, y, i, j, seed;
+
+#ifdef XCURSES
+ Xinitscr(argc, argv);
+#else
+ initscr();
+#endif
+ seed = time((time_t *)0);
+ srand(seed);
+
+ start_color();
+# if defined(NCURSES_VERSION) || (defined(PDC_BUILD) && PDC_BUILD > 3000)
+ use_default_colors();
+# endif
+ cbreak();
+ noecho();
+
+ curs_set(0);
+
+#if !defined(__TURBOC__) && !defined(OS2)
+ signal(SIGINT, trap);
+#endif
+ noecho();
+
+ /* refresh stdscr so that reading from it will not cause it to
+ overwrite the other windows that are being created */
+
+ refresh();
+
+ /* Create a drawing window */
+
+ width = 48;
+ height = 15;
+
+ win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2);
+
+ if (win == NULL)
+ {
+ endwin();
+
+ return 1;
+ }
+
+ for (;;)
+ {
+ init_pair(1, COLOR_WHITE, COLOR_BLUE);
+ wbkgd(win, COLOR_PAIR(1));
+ werase(win);
+
+ init_pair(2, COLOR_RED, COLOR_RED);
+ wattrset(win, COLOR_PAIR(2));
+ box(win, ' ', ' ');
+ wrefresh(win);
+
+ wattrset(win, 0);
+
+ /* Do random output of a character */
+
+ ch = 'a';
+
+ nodelay(stdscr, TRUE);
+
+ for (i = 0; i < 5000; ++i)
+ {
+ x = rand() % (width - 2) + 1;
+ y = rand() % (height - 2) + 1;
+
+ mvwaddch(win, y, x, ch);
+ wrefresh(win);
+
+ if (getch() != ERR)
+ break;
+
+ if (i == 2000)
+ {
+ ch = 'b';
+ init_pair(3, COLOR_CYAN, COLOR_YELLOW);
+ wattrset(win, COLOR_PAIR(3));
+ }
+ }
+
+ nodelay(stdscr, FALSE);
+
+ SubWinTest(win);
+
+ /* Erase and draw green window */
+
+ init_pair(4, COLOR_YELLOW, COLOR_GREEN);
+ wbkgd(win, COLOR_PAIR(4));
+ wattrset(win, A_BOLD);
+ werase(win);
+ wrefresh(win);
+
+ /* Draw RED bounding box */
+
+ wattrset(win, COLOR_PAIR(2));
+ box(win, ' ', ' ');
+ wrefresh(win);
+
+ /* Display Australia map */
+
+ wattrset(win, A_BOLD);
+ i = 0;
+
+ while (*AusMap[i])
+ {
+ mvwaddstr(win, i + 1, 8, AusMap[i]);
+ wrefresh(win);
+ napms(100);
+ ++i;
+ }
+
+ init_pair(5, COLOR_BLUE, COLOR_WHITE);
+ wattrset(win, COLOR_PAIR(5) | A_BLINK);
+ mvwaddstr(win, height - 2, 3,
+ " PDCurses 3.4 - DOS, OS/2, Win32, X11, SDL");
+ wrefresh(win);
+
+ /* Draw running messages */
+
+ init_pair(6, COLOR_BLACK, COLOR_WHITE);
+ wattrset(win, COLOR_PAIR(6));
+ w = width - 2;
+ nodelay(win, TRUE);
+
+ /* jbuhler's re-hacked scrolling messages */
+
+ for (j = 0; messages[j] != NULL; j++)
+ {
+ char *message = messages[j];
+ int msg_len = strlen(message);
+ int scroll_len = w + 2 * msg_len;
+ char *scrollbuf = malloc(scroll_len);
+ char *visbuf = scrollbuf + msg_len;
+ int stop = 0;
+ int i;
+
+ for (i = w + msg_len; i > 0; i--)
+ {
+ memset(visbuf, ' ', w);
+ strncpy(scrollbuf + i, message, msg_len);
+ mvwaddnstr(win, height / 2, 1, visbuf, w);
+ wrefresh(win);
+
+ if (wgetch(win) != ERR)
+ {
+ flushinp();
+ stop = 1;
+ break;
+ }
+
+ napms(100);
+ }
+
+ free(scrollbuf);
+
+ if (stop)
+ break;
+ }
+
+ j = 0;
+
+ /* Draw running 'A's across in RED */
+
+ init_pair(7, COLOR_RED, COLOR_GREEN);
+ wattron(win, COLOR_PAIR(7));
+
+ for (i = 2; i < width - 4; ++i)
+ {
+ ch = mvwinch(win, 5, i);
+ save[j++] = ch;
+ ch = ch & 0x7f;
+ mvwaddch(win, 5, i, ch);
+ }
+
+ wrefresh(win);
+
+ /* Put a message up; wait for a key */
+
+ i = height - 2;
+ wattrset(win, COLOR_PAIR(5));
+ mvwaddstr(win, i, 3,
+ " Type a key to continue or ESC to quit ");
+ wrefresh(win);
+
+ if (WaitForUser() == '\033')
+ break;
+
+ /* Restore the old line */
+
+ wattrset(win, 0);
+
+ for (i = 2, j = 0; i < width - 4; ++i)
+ mvwaddch(win, 5, i, save[j++]);
+
+ wrefresh(win);
+
+ BouncingBalls(win);
+
+ /* BouncingBalls() leaves a keystroke in the queue */
+
+ if (WaitForUser() == '\033')
+ break;
+ }
+
+ endwin();
+
+ return 0;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/demos/ptest.c b/payloads/libpayload/curses/PDCurses-3.4/demos/ptest.c
new file mode 100644
index 0000000000..1134f6ffca
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/demos/ptest.c
@@ -0,0 +1,285 @@
+/* $Id: ptest.c,v 1.24 2008/07/13 16:08:17 wmcbrine Exp $ */
+
+#include <curses.h>
+#include <panel.h>
+#include <stdlib.h>
+
+PANEL *p1, *p2, *p3, *p4, *p5;
+WINDOW *w4, *w5;
+
+long nap_msec = 1;
+
+char *mod[] =
+{
+ "test ", "TEST ", "(**) ", "*()* ", "<--> ", "LAST "
+};
+
+void pflush(void)
+{
+ update_panels();
+ doupdate();
+}
+
+void backfill(void)
+{
+ int y, x;
+
+ erase();
+
+ for (y = 0; y < LINES - 1; y++)
+ for (x = 0; x < COLS; x++)
+ printw("%d", (y + x) % 10);
+}
+
+void wait_a_while(long msec)
+{
+ int c;
+
+ if (msec != 1)
+ timeout(msec);
+
+ c = getch();
+
+ if (c == 'q')
+ {
+ endwin();
+ exit(1);
+ }
+}
+
+void saywhat(const char *text)
+{
+ mvprintw(LINES - 1, 0, "%-20.20s", text);
+}
+
+/* mkpanel - alloc a win and panel and associate them */
+
+PANEL *mkpanel(int rows, int cols, int tly, int tlx)
+{
+ WINDOW *win = newwin(rows, cols, tly, tlx);
+ PANEL *pan = (PANEL *)0;
+
+ if (win)
+ {
+ pan = new_panel(win);
+
+ if (!pan)
+ delwin(win);
+ }
+
+ return pan;
+}
+
+void rmpanel(PANEL *pan)
+{
+ WINDOW *win = pan->win;
+
+ del_panel(pan);
+ delwin(win);
+}
+
+void fill_panel(PANEL *pan)
+{
+ WINDOW *win = pan->win;
+ char num = *((char *)pan->user + 1);
+ int y, x, maxy, maxx;
+
+ box(win, 0, 0);
+ mvwprintw(win, 1, 1, "-pan%c-", num);
+ getmaxyx(win, maxy, maxx);
+
+ for (y = 2; y < maxy - 1; y++)
+ for (x = 1; x < maxx - 1; x++)
+ mvwaddch(win, y, x, num);
+}
+
+int main(int argc, char **argv)
+{
+ int itmp, y;
+
+ if (argc > 1 && atol(argv[1]))
+ nap_msec = atol(argv[1]);
+
+#ifdef XCURSES
+ Xinitscr(argc, argv);
+#else
+ initscr();
+#endif
+ backfill();
+
+ for (y = 0; y < 5; y++)
+ {
+ p1 = mkpanel(10, 10, 0, 0);
+ set_panel_userptr(p1, "p1");
+
+ p2 = mkpanel(14, 14, 5, 5);
+ set_panel_userptr(p2, "p2");
+
+ p3 = mkpanel(6, 8, 12, 12);
+ set_panel_userptr(p3, "p3");
+
+ p4 = mkpanel(10, 10, 10, 30);
+ w4 = panel_window(p4);
+ set_panel_userptr(p4, "p4");
+
+ p5 = mkpanel(10, 10, 13, 37);
+ w5 = panel_window(p5);
+ set_panel_userptr(p5, "p5");
+
+ fill_panel(p1);
+ fill_panel(p2);
+ fill_panel(p3);
+ fill_panel(p4);
+ fill_panel(p5);
+ hide_panel(p4);
+ hide_panel(p5);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("h3 s1 s2 s4 s5;");
+ move_panel(p1, 0, 0);
+ hide_panel(p3);
+ show_panel(p1);
+ show_panel(p2);
+ show_panel(p4);
+ show_panel(p5);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("s1;");
+ show_panel(p1);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("s2;");
+ show_panel(p2);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("m2;");
+ move_panel(p2, 10, 10);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("s3;");
+ show_panel(p3);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("m3;");
+ move_panel(p3, 5, 5);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("b3;");
+ bottom_panel(p3);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("s4;");
+ show_panel(p4);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("s5;");
+ show_panel(p5);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("t3;");
+ top_panel(p3);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("t1;");
+ top_panel(p1);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("t2;");
+ top_panel(p2);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("t3;");
+ top_panel(p3);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("t4;");
+ top_panel(p4);
+ pflush();
+ wait_a_while(nap_msec);
+
+ for (itmp = 0; itmp < 6; itmp++)
+ {
+ saywhat("m4;");
+ mvwaddstr(w4, 3, 1, mod[itmp]);
+ move_panel(p4, 4, itmp * 10);
+ mvwaddstr(w5, 4, 1, mod[itmp]);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("m5;");
+ mvwaddstr(w4, 4, 1, mod[itmp]);
+ move_panel(p5, 7, itmp * 10 + 6);
+ mvwaddstr(w5, 3, 1, mod[itmp]);
+ pflush();
+ wait_a_while(nap_msec);
+ }
+
+ saywhat("m4;");
+ move_panel(p4, 4, itmp * 10);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("t5;");
+ top_panel(p5);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("t2;");
+ top_panel(p2);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("t1;");
+ top_panel(p1);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("d2;");
+ rmpanel(p2);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("h3;");
+ hide_panel(p3);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("d1;");
+ rmpanel(p1);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("d4; ");
+ rmpanel(p4);
+ pflush();
+ wait_a_while(nap_msec);
+
+ saywhat("d5; ");
+ rmpanel(p5);
+ pflush();
+ wait_a_while(nap_msec);
+
+ if (nap_msec == 1)
+ break;
+
+ nap_msec = 100L;
+ }
+
+ endwin();
+
+ return 0;
+} /* end of main */
diff --git a/payloads/libpayload/curses/PDCurses-3.4/demos/rain.c b/payloads/libpayload/curses/PDCurses-3.4/demos/rain.c
new file mode 100644
index 0000000000..51d05a9056
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/demos/rain.c
@@ -0,0 +1,159 @@
+/****************************************************************************
+ * Copyright (c) 2002 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/* $Id: rain.c,v 1.11 2008/07/13 16:08:17 wmcbrine Exp $ */
+
+#include <curses.h>
+#include <stdlib.h>
+#include <time.h>
+
+/* rain 11/3/1980 EPS/CITHEP */
+
+static int next_j(int j)
+{
+ if (j == 0)
+ j = 4;
+ else
+ --j;
+
+ if (has_colors())
+ {
+ int z = rand() % 3;
+ chtype color = COLOR_PAIR(z);
+
+ if (z)
+ color |= A_BOLD;
+
+ attrset(color);
+ }
+
+ return j;
+}
+
+int main(int argc, char *argv[])
+{
+ int x, y, j, r, c, seed;
+ static int xpos[5], ypos[5];
+
+#ifdef XCURSES
+ Xinitscr(argc, argv);
+#else
+ initscr();
+#endif
+ seed = time((time_t *)0);
+ srand(seed);
+
+ if (has_colors())
+ {
+ int bg = COLOR_BLACK;
+
+ start_color();
+
+#if defined(NCURSES_VERSION) || (defined(PDC_BUILD) && PDC_BUILD > 3000)
+ if (use_default_colors() == OK)
+ bg = -1;
+#endif
+ init_pair(1, COLOR_BLUE, bg);
+ init_pair(2, COLOR_CYAN, bg);
+ }
+
+ nl();
+ noecho();
+ curs_set(0);
+ timeout(0);
+ keypad(stdscr, TRUE);
+
+ r = LINES - 4;
+ c = COLS - 4;
+
+ for (j = 5; --j >= 0;)
+ {
+ xpos[j] = rand() % c + 2;
+ ypos[j] = rand() % r + 2;
+ }
+
+ for (j = 0;;)
+ {
+ x = rand() % c + 2;
+ y = rand() % r + 2;
+
+ mvaddch(y, x, '.');
+
+ mvaddch(ypos[j], xpos[j], 'o');
+
+ j = next_j(j);
+ mvaddch(ypos[j], xpos[j], 'O');
+
+ j = next_j(j);
+ mvaddch(ypos[j] - 1, xpos[j], '-');
+ mvaddstr(ypos[j], xpos[j] - 1, "|.|");
+ mvaddch(ypos[j] + 1, xpos[j], '-');
+
+ j = next_j(j);
+ mvaddch(ypos[j] - 2, xpos[j], '-');
+ mvaddstr(ypos[j] - 1, xpos[j] - 1, "/ \\");
+ mvaddstr(ypos[j], xpos[j] - 2, "| O |");
+ mvaddstr(ypos[j] + 1, xpos[j] - 1, "\\ /");
+ mvaddch(ypos[j] + 2, xpos[j], '-');
+
+ j = next_j(j);
+ mvaddch(ypos[j] - 2, xpos[j], ' ');
+ mvaddstr(ypos[j] - 1, xpos[j] - 1, " ");
+ mvaddstr(ypos[j], xpos[j] - 2, " ");
+ mvaddstr(ypos[j] + 1, xpos[j] - 1, " ");
+ mvaddch(ypos[j] + 2, xpos[j], ' ');
+
+ xpos[j] = x;
+ ypos[j] = y;
+
+ switch (getch())
+ {
+ case 'q':
+ case 'Q':
+ curs_set(1);
+ endwin();
+ return EXIT_SUCCESS;
+ case 's':
+ nodelay(stdscr, FALSE);
+ break;
+ case ' ':
+ nodelay(stdscr, TRUE);
+#ifdef KEY_RESIZE
+ break;
+ case KEY_RESIZE:
+# ifdef PDCURSES
+ resize_term(0, 0);
+ erase();
+# endif
+ r = LINES - 4;
+ c = COLS - 4;
+#endif
+ }
+ napms(50);
+ }
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/demos/testcurs.c b/payloads/libpayload/curses/PDCurses-3.4/demos/testcurs.c
new file mode 100644
index 0000000000..5b330f558b
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/demos/testcurs.c
@@ -0,0 +1,1144 @@
+/*
+ * This is a test program for PDCurses. Originally by
+ * John Burnell <johnb@kea.am.dsir.govt.nz>
+ *
+ * wrs(5/28/93) -- modified to be consistent (perform identically)
+ * with either PDCurses or under Unix System V, R4
+ *
+ * $Id: testcurs.c,v 1.85 2008/07/14 12:35:23 wmcbrine Exp $
+ */
+
+#ifndef _XOPEN_SOURCE_EXTENDED
+# define _XOPEN_SOURCE_EXTENDED 1
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <curses.h>
+
+#ifdef WACS_S1
+# define HAVE_WIDE 1
+#else
+# define HAVE_WIDE 0
+#endif
+
+#include <locale.h>
+
+#if HAVE_WIDE
+# include <wchar.h>
+#endif
+
+#if defined(PDCURSES) && !defined(XCURSES)
+# define HAVE_RESIZE 1
+#else
+# define HAVE_RESIZE 0
+#endif
+
+#ifdef A_COLOR
+# define HAVE_COLOR 1
+#else
+# define HAVE_COLOR 0
+#endif
+
+/* Set to non-zero if you want to test the PDCurses clipboard */
+
+#define HAVE_CLIPBOARD 0
+
+void inputTest(WINDOW *);
+void scrollTest(WINDOW *);
+void introTest(WINDOW *);
+int initTest(WINDOW **, int, char **);
+void outputTest(WINDOW *);
+void padTest(WINDOW *);
+void acsTest(WINDOW *);
+
+#if HAVE_COLOR
+void colorTest(WINDOW *);
+#endif
+
+#if HAVE_RESIZE
+void resizeTest(WINDOW *);
+#endif
+
+#if HAVE_CLIPBOARD
+void clipboardTest(WINDOW *);
+#endif
+
+#if HAVE_WIDE
+void wideTest(WINDOW *);
+#endif
+
+void display_menu(int, int);
+
+struct commands
+{
+ const char *text;
+ void (*function)(WINDOW *);
+};
+
+typedef struct commands COMMAND;
+
+#define MAX_OPTIONS (6 + HAVE_COLOR + HAVE_RESIZE + HAVE_CLIPBOARD + HAVE_WIDE)
+
+COMMAND command[MAX_OPTIONS] =
+{
+ {"Intro Test", introTest},
+ {"Pad Test", padTest},
+#if HAVE_RESIZE
+ {"Resize Test", resizeTest},
+#endif
+ {"Scroll Test", scrollTest},
+ {"Input Test", inputTest},
+ {"Output Test", outputTest},
+ {"ACS Test", acsTest},
+#if HAVE_COLOR
+ {"Color Test", colorTest},
+#endif
+#if HAVE_CLIPBOARD
+ {"Clipboard Test", clipboardTest},
+#endif
+#if HAVE_WIDE
+ {"Wide Input", wideTest}
+#endif
+};
+
+int width, height;
+
+int main(int argc, char *argv[])
+{
+ WINDOW *win;
+ int key, old_option = -1, new_option = 0;
+ bool quit = FALSE;
+
+ setlocale(LC_ALL, "");
+
+ if (initTest(&win, argc, argv))
+ return 1;
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(1, COLOR_WHITE, COLOR_BLUE);
+ wbkgd(win, COLOR_PAIR(1));
+ }
+ else
+#endif
+ wbkgd(win, A_REVERSE);
+
+ erase();
+ display_menu(old_option, new_option);
+
+ while (1)
+ {
+ noecho();
+ keypad(stdscr, TRUE);
+ raw();
+
+ key = getch();
+
+ switch(key)
+ {
+ case 10:
+ case 13:
+ case KEY_ENTER:
+ old_option = -1;
+ erase();
+ refresh();
+ (*command[new_option].function)(win);
+ erase();
+ display_menu(old_option, new_option);
+ break;
+
+ case KEY_PPAGE:
+ case KEY_HOME:
+ old_option = new_option;
+ new_option = 0;
+ display_menu(old_option, new_option);
+ break;
+
+ case KEY_NPAGE:
+ case KEY_END:
+ old_option = new_option;
+ new_option = MAX_OPTIONS - 1;
+ display_menu(old_option, new_option);
+ break;
+
+ case KEY_UP:
+ old_option = new_option;
+ new_option = (new_option == 0) ?
+ new_option : new_option - 1;
+ display_menu(old_option, new_option);
+ break;
+
+ case KEY_DOWN:
+ old_option = new_option;
+ new_option = (new_option == MAX_OPTIONS - 1) ?
+ new_option : new_option + 1;
+ display_menu(old_option, new_option);
+ break;
+#ifdef KEY_RESIZE
+ case KEY_RESIZE:
+# ifdef PDCURSES
+ resize_term(0, 0);
+# endif
+ old_option = -1;
+ erase();
+ display_menu(old_option, new_option);
+ break;
+#endif
+ case 'Q':
+ case 'q':
+ quit = TRUE;
+ }
+
+ if (quit == TRUE)
+ break;
+ }
+
+ delwin(win);
+ endwin();
+
+ return 0;
+}
+
+void Continue(WINDOW *win)
+{
+ mvwaddstr(win, 10, 1, " Press any key to continue");
+ wrefresh(win);
+ raw();
+ wgetch(win);
+}
+
+void Continue2(void)
+{
+ move(LINES - 1, 1);
+ clrtoeol();
+ mvaddstr(LINES - 2, 1, " Press any key to continue");
+ refresh();
+ raw();
+ getch();
+}
+
+int initTest(WINDOW **win, int argc, char *argv[])
+{
+#ifdef XCURSES
+ Xinitscr(argc, argv);
+#else
+ initscr();
+#endif
+#ifdef A_COLOR
+ if (has_colors())
+ start_color();
+#endif
+ /* Create a drawing window */
+
+ width = 60;
+ height = 13;
+
+ *win = newwin(height, width, (LINES - height) / 2, (COLS - width) / 2);
+
+ if (*win == NULL)
+ {
+ endwin();
+ return 1;
+ }
+
+ return 0;
+}
+
+void introTest(WINDOW *win)
+{
+ werase(win);
+ wmove(win, height / 2 - 5, width / 2);
+ wvline(win, ACS_VLINE, 10);
+ wmove(win, height / 2, width / 2 - 10);
+ whline(win, ACS_HLINE, 20);
+ Continue(win);
+
+ beep();
+ werase(win);
+
+ box(win, ACS_VLINE, ACS_HLINE);
+ wrefresh(win);
+
+ cbreak();
+ mvwaddstr(win, 1, 1,
+ "You should have a rectangle in the middle of the screen");
+ mvwaddstr(win, 2, 1, "You should have heard a beep");
+ Continue(win);
+
+ flash();
+ mvwaddstr(win, 3, 1, "You should have seen a flash");
+ Continue(win);
+}
+
+void scrollTest(WINDOW *win)
+{
+ int i, OldY;
+#ifndef PDCURSES
+ int OldX;
+#endif
+ werase(win);
+ mvwaddstr(win, height - 2, 1, "The window will now scroll slowly");
+ box(win, ACS_VLINE, ACS_HLINE);
+ wrefresh(win);
+ scrollok(win, TRUE);
+ napms(500);
+
+ for (i = 1; i <= height; i++)
+ {
+ napms(150);
+ scroll(win);
+ wrefresh(win);
+ };
+
+#ifdef PDCURSES
+ OldY = getmaxy(win);
+#else
+ getmaxyx(win, OldY, OldX);
+#endif
+ mvwaddstr(win, 6, 1, "The top of the window will scroll");
+ wmove(win, 1, 1);
+ wsetscrreg(win, 0, 4);
+ box(win, ACS_VLINE, ACS_HLINE);
+ wrefresh(win);
+
+ for (i = 1; i <= 5; i++)
+ {
+ napms(500);
+ scroll(win);
+ wrefresh(win);
+ }
+
+ mvwaddstr(win, 3, 1, "The bottom of the window will scroll");
+ wmove(win, 8, 1);
+ wsetscrreg(win, 5, --OldY);
+ box(win, ACS_VLINE, ACS_HLINE);
+ wrefresh(win);
+
+ for (i = 5; i <= OldY; i++)
+ {
+ napms(300);
+ wscrl(win, -1);
+ wrefresh(win);
+ }
+
+ wsetscrreg(win, 0, OldY);
+}
+
+void inputTest(WINDOW *win)
+{
+ int w, h, bx, by, sw, sh, i, c, num = 0;
+ char buffer[80];
+ WINDOW *subWin;
+ static const char spinner[4] = "/-\\|";
+ int spinner_count = 0;
+
+ wclear(win);
+
+ getmaxyx(win, h, w);
+ getbegyx(win, by, bx);
+
+ sw = w / 3;
+ sh = h / 3;
+
+ if ((subWin = subwin(win, sh, sw, by + h - sh - 2, bx + w - sw - 2))
+ == NULL)
+ return;
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(2, COLOR_WHITE, COLOR_RED);
+ wbkgd(subWin, COLOR_PAIR(2) | A_BOLD);
+ }
+ else
+#endif
+ wbkgd(subWin, A_BOLD);
+
+ box(subWin, ACS_VLINE, ACS_HLINE);
+ wrefresh(win);
+
+ nocbreak();
+
+ wclear (win);
+ mvwaddstr(win, 1, 1,
+ "Press keys (or mouse buttons) to show their names");
+ mvwaddstr(win, 2, 1, "Press spacebar to finish");
+ wrefresh(win);
+
+ keypad(win, TRUE);
+ raw();
+ noecho();
+
+ wtimeout(win, 200);
+
+#ifdef PDCURSES
+ mouse_set(ALL_MOUSE_EVENTS);
+ PDC_save_key_modifiers(TRUE);
+ PDC_return_key_modifiers(TRUE);
+#endif
+ curs_set(0); /* turn cursor off */
+
+ while (1)
+ {
+ while (1)
+ {
+ c = wgetch(win);
+
+ if (c == ERR)
+ {
+ spinner_count++;
+ if (spinner_count == 4)
+ spinner_count = 0;
+ mvwaddch(win, 3, 3, spinner[spinner_count]);
+ wrefresh(win);
+ }
+ else
+ break;
+ }
+#ifdef PDCURSES
+ wmove(win, 4, 18);
+ wclrtoeol(win);
+#endif
+ mvwaddstr(win, 3, 5, "Key Pressed: ");
+ wclrtoeol(win);
+
+ if (c >= KEY_MIN)
+ wprintw(win, "%s", keyname(c));
+ else if (isprint(c))
+ wprintw(win, "%c", c);
+ else
+ wprintw(win, "%s", unctrl(c));
+#ifdef PDCURSES
+ if (c == KEY_MOUSE)
+ {
+ int button = 0;
+ request_mouse_pos();
+
+ if (BUTTON_CHANGED(1))
+ button = 1;
+ else if (BUTTON_CHANGED(2))
+ button = 2;
+ else if (BUTTON_CHANGED(3))
+ button = 3;
+
+ if (button && (BUTTON_STATUS(button) &
+ BUTTON_MODIFIER_MASK))
+ {
+ waddstr(win, " Modifier(s):");
+
+ if (BUTTON_STATUS(button) & BUTTON_SHIFT)
+ waddstr(win, " SHIFT");
+
+ if (BUTTON_STATUS(button) & BUTTON_CONTROL)
+ waddstr(win, " CONTROL");
+
+ if (BUTTON_STATUS(button) & BUTTON_ALT)
+ waddstr(win, " ALT");
+ }
+
+ wmove(win, 4, 18);
+ wclrtoeol(win);
+ wprintw(win, "Button %d: ", button);
+
+ if (MOUSE_MOVED)
+ waddstr(win, "moved: ");
+ else if (MOUSE_WHEEL_UP)
+ waddstr(win, "wheel up: ");
+ else if (MOUSE_WHEEL_DOWN)
+ waddstr(win, "wheel dn: ");
+ else if ((BUTTON_STATUS(button) &
+ BUTTON_ACTION_MASK) == BUTTON_PRESSED)
+ waddstr(win, "pressed: ");
+ else if ((BUTTON_STATUS(button) &
+ BUTTON_ACTION_MASK) == BUTTON_CLICKED)
+ waddstr(win, "clicked: ");
+ else if ((BUTTON_STATUS(button) &
+ BUTTON_ACTION_MASK) == BUTTON_DOUBLE_CLICKED)
+ waddstr(win, "double: ");
+ else
+ waddstr(win, "released: ");
+
+ wprintw(win, "Position: Y: %d X: %d", MOUSE_Y_POS, MOUSE_X_POS);
+ }
+ else if (PDC_get_key_modifiers())
+ {
+ waddstr(win, " Modifier(s):");
+ if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_SHIFT)
+ waddstr(win, " SHIFT");
+
+ if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_CONTROL)
+ waddstr(win, " CONTROL");
+
+ if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_ALT)
+ waddstr(win, " ALT");
+
+ if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_NUMLOCK)
+ waddstr(win, " NUMLOCK");
+ }
+#endif
+ wrefresh(win);
+
+ if (c == ' ')
+ break;
+ }
+
+ wtimeout(win, -1); /* turn off timeout() */
+ curs_set(1); /* turn cursor back on */
+
+#ifdef PDCURSES
+ mouse_set(0L);
+ PDC_save_key_modifiers(FALSE);
+ PDC_return_key_modifiers(FALSE);
+#endif
+ wclear(win);
+ mvwaddstr(win, 2, 1, "Press some keys for 5 seconds");
+ mvwaddstr(win, 1, 1, "Pressing ^C should do nothing");
+ wrefresh(win);
+
+ werase(subWin);
+ box(subWin, ACS_VLINE, ACS_HLINE);
+
+ for (i = 0; i < 5; i++)
+ {
+ mvwprintw(subWin, 1, 1, "Time = %d", i);
+ wrefresh(subWin);
+ napms(1000);
+ flushinp();
+ }
+
+ delwin(subWin);
+ werase(win);
+ flash();
+ wrefresh(win);
+ napms(500);
+ flushinp();
+
+ mvwaddstr(win, 2, 1, "Press a key, followed by ENTER");
+ wmove(win, 9, 10);
+ wrefresh(win);
+ echo();
+
+ keypad(win, TRUE);
+ raw();
+ wgetnstr(win, buffer, 3);
+ flushinp();
+
+ wmove(win, 9, 10);
+ wdelch(win);
+ mvwaddstr(win, 4, 1, "The character should now have been deleted");
+ Continue(win);
+
+ refresh();
+ wclear(win);
+ echo();
+ buffer[0] = '\0';
+ mvwaddstr(win, 3, 2, "The window should have moved");
+ mvwaddstr(win, 4, 2,
+ "This text should have appeared without you pressing a key");
+ mvwaddstr(win, 6, 2, "Enter a number then a string seperated by space");
+ mvwin(win, 2, 1);
+ wrefresh(win);
+ mvwscanw(win, 7, 6, "%d %s", &num, buffer);
+ mvwprintw(win, 8, 6, "String: %s Number: %d", buffer, num);
+ Continue(win);
+
+ refresh();
+ wclear(win);
+ echo();
+ mvwaddstr(win, 3, 2, "Enter a 5 character string: ");
+ wgetnstr(win, buffer, 5);
+ mvwprintw(win, 4, 2, "String: %s", buffer);
+ Continue(win);
+}
+
+void outputTest(WINDOW *win)
+{
+ WINDOW *win1;
+ char Buffer[80];
+ chtype ch;
+ int by, bx;
+
+ nl();
+ wclear(win);
+ mvwaddstr(win, 1, 1, "You should now have a screen in the upper "
+ "left corner, and this text should have wrapped");
+ waddstr(win,"\nThis text should be down\n");
+ waddstr(win, "and broken into two here ^");
+ Continue(win);
+
+ wclear(win);
+ wattron(win, A_BOLD);
+ mvwaddstr(win, 1, 1, "A new window will appear with this text in it");
+ mvwaddstr(win, 8, 1, "Press any key to continue");
+ wrefresh(win);
+ wgetch(win);
+
+ getbegyx(win, by, bx);
+
+ if (LINES < 24 || COLS < 75)
+ {
+ mvwaddstr(win, 5, 1, "Some tests have been skipped as they require a");
+ mvwaddstr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS");
+ Continue(win);
+ }
+ else
+ {
+ win1 = newwin(10, 50, 14, 25);
+
+ if (win1 == NULL)
+ {
+ endwin();
+ return;
+ }
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(3, COLOR_BLUE, COLOR_WHITE);
+ wbkgd(win1, COLOR_PAIR(3));
+ }
+ else
+#endif
+ wbkgd(win1, A_NORMAL);
+
+ wclear(win1);
+ mvwaddstr(win1, 5, 1, "This text should appear; using overlay option");
+ copywin(win, win1, 0, 0, 0, 0, 9, 49, TRUE);
+ box(win1, ACS_VLINE, ACS_HLINE);
+ wmove(win1, 8, 26);
+ wrefresh(win1);
+ wgetch(win1);
+
+ wclear(win1);
+
+ wattron(win1, A_BLINK);
+ mvwaddstr(win1, 4, 1,
+ "This blinking text should appear in only the second window");
+ wattroff(win1, A_BLINK);
+
+ mvwin(win1, by, bx);
+ overlay(win, win1);
+ mvwin(win1, 14, 25);
+ wmove(win1, 8, 26);
+ wrefresh(win1);
+ wgetch(win1);
+
+ delwin(win1);
+ }
+
+ clear();
+ wclear(win);
+ wrefresh(win);
+ mvwaddstr(win, 6, 2, "This line shouldn't appear");
+ mvwaddstr(win, 4, 2, "Only half of the next line is visible");
+ mvwaddstr(win, 5, 2, "Only half of the next line is visible");
+ wmove(win, 6, 1);
+ wclrtobot(win);
+ wmove(win, 5, 20);
+ wclrtoeol(win);
+ mvwaddstr(win, 8, 2, "This line also shouldn't appear");
+ wmove(win, 8, 1);
+ winsdelln(win, -1);
+ Continue(win);
+
+ wmove(win, 5, 9);
+ ch = winch(win);
+
+ wclear(win);
+ wmove(win, 6, 2);
+ waddstr(win, "The next char should be l: ");
+ winsch(win, ch);
+ Continue(win);
+
+ mvwinsstr(win, 6, 2, "A1B2C3D4E5");
+ Continue(win);
+
+ wmove(win, 5, 1);
+ winsdelln(win, 1);
+ mvwaddstr(win, 5, 2, "The lines below should have moved down");
+ Continue(win);
+
+ wclear(win);
+ wmove(win, 2, 2);
+ wprintw(win, "This is a formatted string in a window: %d %s\n",
+ 42, "is it");
+ mvwaddstr(win, 10, 1, "Enter a string: ");
+ wrefresh(win);
+ echo();
+ wscanw(win, "%s", Buffer);
+
+ printw("This is a formatted string in stdscr: %d %s\n", 42, "is it");
+ mvaddstr(10, 1, "Enter a string: ");
+ scanw("%s", Buffer);
+
+ wclear(win);
+ curs_set(2);
+ mvwaddstr(win, 1, 1, "The cursor should be in high-visibility mode");
+ Continue(win);
+
+ wclear(win);
+ curs_set(0);
+ mvwaddstr(win, 1, 1, "The cursor should have disappeared");
+ Continue(win);
+
+ wclear(win);
+ curs_set(1);
+ mvwaddstr(win, 1, 1, "The cursor should be normal");
+ Continue(win);
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ wclear(win);
+ mvwaddstr(win, 1, 1, "Colors should change after you press a key");
+ Continue(win);
+
+ init_pair(1, COLOR_RED, COLOR_WHITE);
+ wrefresh(win);
+ }
+#endif
+ werase(win);
+ mvwaddstr(win, 1, 1, "Information About Your Terminal");
+ mvwaddstr(win, 3, 1, termname());
+ mvwaddstr(win, 4, 1, longname());
+
+ if (termattrs() & A_BLINK)
+ mvwaddstr(win, 5, 1, "This terminal claims to support blinking.");
+ else
+ mvwaddstr(win, 5, 1, "This terminal does NOT support blinking.");
+
+ mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16);
+ wrefresh(win);
+
+ mvwinnstr(win, 7, 5, Buffer, 18);
+ mvaddstr(LINES - 2, 10, Buffer);
+ refresh();
+ Continue(win);
+}
+
+#if HAVE_RESIZE
+void resizeTest(WINDOW *dummy)
+{
+ WINDOW *win1;
+ int nwidth = 135, nheight = 52;
+ int owidth = COLS, oheight = LINES;
+
+ savetty();
+
+ resize_term(nheight, nwidth);
+
+ clear();
+ refresh();
+
+ win1 = newwin(10, 50, 14, 25);
+
+ if (win1 == NULL)
+ {
+ endwin();
+ return;
+ }
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(3, COLOR_BLUE, COLOR_WHITE);
+ wattrset(win1, COLOR_PAIR(3));
+ }
+
+ wclear(win1);
+#endif
+ mvwaddstr(win1, 0, 0, "The screen may now be resized");
+ mvwprintw(win1, 1, 4, "Given size: %d by %d", nwidth, nheight);
+ mvwprintw(win1, 2, 4, "Actual size: %d by %d", COLS, LINES);
+ Continue(win1);
+
+ wclear(win1);
+ resetty();
+
+ mvwaddstr(win1, 0, 0, "The screen should now be reset");
+ mvwprintw(win1, 1, 6, "Old size: %d by %d", owidth, oheight);
+ mvwprintw(win1, 2, 6, "Size now: %d by %d", COLS, LINES);
+ Continue(win1);
+
+ delwin(win1);
+
+ clear();
+ refresh();
+}
+#endif /* HAVE_RESIZE */
+
+void padTest(WINDOW *dummy)
+{
+ WINDOW *pad, *spad;
+
+ pad = newpad(50, 100);
+ wattron(pad, A_REVERSE);
+ mvwaddstr(pad, 5, 2, "This is a new pad");
+ wattrset(pad, 0);
+ mvwaddstr(pad, 8, 0,
+ "The end of this line should be truncated here:except now");
+ mvwaddstr(pad, 11, 1, "This line should not appear.It will now");
+ wmove(pad, 10, 1);
+ wclrtoeol(pad);
+ mvwaddstr(pad, 10, 1, " Press any key to continue");
+ prefresh(pad, 0, 0, 0, 0, 10, 45);
+ keypad(pad, TRUE);
+ raw();
+ wgetch(pad);
+
+ spad = subpad(pad, 12, 25, 7, 52);
+ mvwaddstr(spad, 2, 2, "This is a new subpad");
+ box(spad, 0, 0);
+ prefresh(pad, 0, 0, 0, 0, 15, 75);
+ keypad(pad, TRUE);
+ raw();
+ wgetch(pad);
+
+ mvwaddstr(pad, 35, 2, "This is displayed at line 35 in the pad");
+ mvwaddstr(pad, 40, 1, " Press any key to continue");
+ prefresh(pad, 30, 0, 0, 0, 10, 45);
+ keypad(pad, TRUE);
+ raw();
+ wgetch(pad);
+
+ delwin(pad);
+}
+
+#if HAVE_CLIPBOARD
+void clipboardTest(WINDOW *win)
+{
+ static const char *text =
+ "This string placed in clipboard by PDCurses test program, testcurs.";
+ char *ptr = NULL;
+ long i, length = 0;
+
+ mvaddstr(1, 1,
+ "This test will display the contents of the system clipboard");
+
+ Continue2();
+
+ scrollok(stdscr, TRUE);
+ i = PDC_getclipboard(&ptr, &length);
+
+ switch(i)
+ {
+ case PDC_CLIP_ACCESS_ERROR:
+ mvaddstr(3, 1, "There was an error accessing the clipboard");
+ refresh();
+ break;
+
+ case PDC_CLIP_MEMORY_ERROR:
+ mvaddstr(3, 1,
+ "Unable to allocate memory for clipboard contents");
+ break;
+
+ case PDC_CLIP_EMPTY:
+ mvaddstr(3, 1, "There was no text in the clipboard");
+ break;
+
+ default:
+ wsetscrreg(stdscr, 0, LINES - 1);
+ clear();
+ mvaddstr(1, 1, "Clipboard contents...");
+ mvprintw(2, 1, "%s\n", ptr);
+ }
+
+ Continue2();
+
+ clear();
+ mvaddstr(1, 1,
+ "This test will place the following string in the system clipboard:");
+ mvaddstr(2, 1, text);
+
+ i = PDC_setclipboard(text, strlen(text));
+
+ switch(i)
+ {
+ case PDC_CLIP_ACCESS_ERROR:
+ mvaddstr(3, 1, "There was an error accessing the clipboard");
+ break;
+
+ case PDC_CLIP_MEMORY_ERROR:
+ mvaddstr(3, 1, "Unable to allocate memory for clipboard contents");
+ break;
+
+ default:
+ mvaddstr(3, 1, "The string was placed in the clipboard successfully");
+ }
+
+ Continue2();
+}
+#endif /* HAVE_CLIPBOARD */
+
+void acsTest(WINDOW *win)
+{
+#ifdef ACS_S3
+# define ACSNUM 32
+#else
+# define ACSNUM 25
+#endif
+ static const char *acs_names[] =
+ {
+ "ACS_ULCORNER", "ACS_URCORNER", "ACS_LLCORNER", "ACS_LRCORNER",
+ "ACS_LTEE", "ACS_RTEE", "ACS_TTEE", "ACS_BTEE", "ACS_HLINE",
+ "ACS_VLINE", "ACS_PLUS",
+
+ "ACS_S1", "ACS_S9", "ACS_DIAMOND", "ACS_CKBOARD", "ACS_DEGREE",
+ "ACS_PLMINUS", "ACS_BULLET",
+
+ "ACS_LARROW", "ACS_RARROW", "ACS_UARROW", "ACS_DARROW",
+ "ACS_BOARD", "ACS_LANTERN", "ACS_BLOCK"
+#ifdef ACS_S3
+ , "ACS_S3", "ACS_S7", "ACS_LEQUAL", "ACS_GEQUAL",
+ "ACS_PI", "ACS_NEQUAL", "ACS_STERLING"
+#endif
+ };
+
+ chtype acs_values[ACSNUM];
+
+#if HAVE_WIDE
+ cchar_t *wacs_values[] =
+ {
+ WACS_ULCORNER, WACS_URCORNER, WACS_LLCORNER, WACS_LRCORNER,
+ WACS_LTEE, WACS_RTEE, WACS_TTEE, WACS_BTEE, WACS_HLINE,
+ WACS_VLINE, WACS_PLUS,
+
+ WACS_S1, WACS_S9, WACS_DIAMOND, WACS_CKBOARD, WACS_DEGREE,
+ WACS_PLMINUS, WACS_BULLET,
+
+ WACS_LARROW, WACS_RARROW, WACS_UARROW, WACS_DARROW, WACS_BOARD,
+ WACS_LANTERN, WACS_BLOCK
+# ifdef WACS_S3
+ , WACS_S3, WACS_S7, WACS_LEQUAL, WACS_GEQUAL, WACS_PI,
+ WACS_NEQUAL, WACS_STERLING
+# endif
+ };
+
+ static const wchar_t russian[] = {0x0420, 0x0443, 0x0441, 0x0441,
+ 0x043a, 0x0438, 0x0439, L' ', 0x044f, 0x0437, 0x044b, 0x043a, 0};
+
+ static const wchar_t greek[] = {0x0395, 0x03bb, 0x03bb, 0x03b7,
+ 0x03bd, 0x03b9, 0x03ba, 0x03ac, 0};
+
+ static const wchar_t georgian[] = {0x10e5, 0x10d0, 0x10e0, 0x10d7,
+ 0x10e3, 0x10da, 0x10d8, L' ', 0x10d4, 0x10dc, 0x10d0, 0};
+#endif
+
+ int i, tmarg = (LINES - 22) / 2;
+
+ attrset(A_BOLD);
+ mvaddstr(tmarg, (COLS - 23) / 2, "Alternate Character Set");
+ attrset(A_NORMAL);
+
+ tmarg += 3;
+
+#define A(b,c) acs_values[b] = ACS_##c
+
+ A(0,ULCORNER); A(1,URCORNER); A(2,LLCORNER); A(3,LRCORNER);
+ A(4,LTEE); A(5,RTEE); A(6,TTEE); A(7,BTEE);
+ A(8,HLINE); A(9,VLINE); A(10,PLUS); A(11,S1);
+ A(12,S9); A(13,DIAMOND); A(14,CKBOARD); A(15,DEGREE);
+
+ A(16,PLMINUS); A(17,BULLET); A(18,LARROW); A(19,RARROW);
+ A(20,UARROW); A(21,DARROW); A(22,BOARD); A(23,LANTERN);
+ A(24,BLOCK);
+#ifdef ACS_S3
+ A(25,S3); A(26,S7); A(27,LEQUAL); A(28,GEQUAL);
+ A(29,PI); A(30,NEQUAL); A(31,STERLING);
+#endif
+
+#undef A
+
+ for (i = 0; i < ACSNUM; i++)
+ {
+ move((i % 8) * 2 + tmarg, (i / 8) * (COLS / 4) + (COLS / 8 - 7));
+ addch(acs_values[i]);
+ printw(" %s", acs_names[i]);
+ }
+
+ mvaddstr(tmarg + 18, 3, "Press any key to continue");
+ getch();
+
+#if HAVE_WIDE
+ clear();
+
+ attrset(A_BOLD);
+ mvaddstr(tmarg - 3, (COLS - 28) / 2, "Wide Alternate Character Set");
+ attrset(A_NORMAL);
+
+ for (i = 0; i < ACSNUM; i++)
+ {
+ move((i % 8) * 2 + tmarg, (i / 8) * (COLS / 4) + (COLS / 8 - 7));
+ add_wch(wacs_values[i]);
+ printw(" W%s", acs_names[i]);
+ }
+
+ /* Spanish, Russian, Greek, Georgian */
+
+ mvaddwstr(tmarg + 16, COLS / 8 - 5, L"Espa\xf1ol");
+ mvaddwstr(tmarg + 16, 3 * (COLS / 8) - 5, russian);
+ mvaddwstr(tmarg + 16, 5 * (COLS / 8) - 5, greek);
+ mvaddwstr(tmarg + 16, 7 * (COLS / 8) - 5, georgian);
+
+ mvaddstr(tmarg + 18, 3, "Press any key to continue");
+ getch();
+#endif
+}
+
+#if HAVE_COLOR
+void colorTest(WINDOW *win)
+{
+ static const short colors[] =
+ {
+ COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_BLUE,
+ COLOR_CYAN, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE
+ };
+
+ static const char *colornames[] =
+ {
+ "COLOR_BLACK", "COLOR_RED", "COLOR_GREEN", "COLOR_BLUE",
+ "COLOR_CYAN", "COLOR_MAGENTA", "COLOR_YELLOW", "COLOR_WHITE"
+ };
+
+ chtype fill = ACS_BLOCK;
+
+ int i, j, tmarg, col1, col2, col3;
+
+ if (!has_colors())
+ return;
+
+ tmarg = (LINES - 19) / 2;
+ col1 = (COLS - 60) / 2;
+ col2 = col1 + 20;
+ col3 = col2 + 20;
+
+ attrset(A_BOLD);
+ mvaddstr(tmarg, (COLS - 22) / 2, "Color Attribute Macros");
+ attrset(A_NORMAL);
+
+ mvaddstr(tmarg + 3, col2 + 4, "A_NORMAL");
+ mvaddstr(tmarg + 3, col3 + 5, "A_BOLD");
+
+ for (i = 0; i < 8; i++)
+ {
+ init_pair(i + 4, colors[i], COLOR_BLACK);
+
+ mvaddstr(tmarg + i + 5, col1, colornames[i]);
+
+ for (j = 0; j < 16; j++)
+ {
+ mvaddch(tmarg + i + 5, col2 + j, fill | COLOR_PAIR(i + 4));
+ mvaddch(tmarg + i + 5, col3 + j, fill | COLOR_PAIR(i + 4) | A_BOLD);
+ }
+ }
+
+ mvprintw(tmarg + 15, col1, "COLORS = %d", COLORS);
+ mvprintw(tmarg + 16, col1, "COLOR_PAIRS = %d", COLOR_PAIRS);
+
+ mvaddstr(tmarg + 19, 3, "Press any key to continue");
+ getch();
+
+ if (can_change_color())
+ {
+ struct
+ {
+ short red, green, blue;
+ } orgcolors[16];
+
+ int MAXCOL = (COLORS >= 16) ? 16 : 8;
+
+ if (MAXCOL < 8)
+ return;
+
+ for (i = 0; i < MAXCOL; i++)
+ color_content(i, &(orgcolors[i].red),
+ &(orgcolors[i].green),
+ &(orgcolors[i].blue));
+
+ attrset(A_BOLD);
+ mvaddstr(tmarg, (COLS - 22) / 2, " init_color() Example ");
+ attrset(A_NORMAL);
+
+ refresh();
+
+ for (i = 0; i < 8; i++)
+ {
+ init_color(colors[i], i * 125, 0, i * 125);
+
+ if (MAXCOL == 16)
+ init_color(colors[i] + 8, 0, i * 125, 0);
+ }
+
+ mvaddstr(tmarg + 19, 3, "Press any key to continue");
+ getch();
+
+ for (i = 0; i < MAXCOL; i++)
+ init_color(i, orgcolors[i].red,
+ orgcolors[i].green,
+ orgcolors[i].blue);
+ }
+}
+#endif
+
+#if HAVE_WIDE
+void wideTest(WINDOW *win)
+{
+ wchar_t tmp[513];
+ size_t i;
+
+ attrset(A_BOLD);
+ mvaddstr(1, (COLS - 25) / 2, "Wide Character Input Test");
+ attrset(A_NORMAL);
+
+ mvaddstr(4, 1, "Enter a string: ");
+
+ echo();
+
+ get_wstr((wint_t *)tmp);
+ addstr("\n\n String:\n\n ");
+ addwstr(tmp);
+ addstr("\n\n\n Hex:\n\n ");
+
+ for (i = 0; i < wcslen(tmp); i++)
+ {
+ printw("%04x ", tmp[i]);
+ addnwstr(tmp + i, 1);
+ addstr(" ");
+ }
+
+ noecho();
+
+ Continue2();
+}
+#endif
+
+void display_menu(int old_option, int new_option)
+{
+ int lmarg = (COLS - 14) / 2,
+ tmarg = (LINES - (MAX_OPTIONS + 2)) / 2;
+
+ if (old_option == -1)
+ {
+ int i;
+
+ attrset(A_BOLD);
+ mvaddstr(tmarg - 3, lmarg - 5, "PDCurses Test Program");
+ attrset(A_NORMAL);
+
+ for (i = 0; i < MAX_OPTIONS; i++)
+ mvaddstr(tmarg + i, lmarg, command[i].text);
+ }
+ else
+ mvaddstr(tmarg + old_option, lmarg, command[old_option].text);
+
+ attrset(A_REVERSE);
+ mvaddstr(tmarg + new_option, lmarg, command[new_option].text);
+ attrset(A_NORMAL);
+
+ mvaddstr(tmarg + MAX_OPTIONS + 2, lmarg - 23,
+ "Use Up and Down Arrows to select - Enter to run - Q to quit");
+ refresh();
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/demos/tui.c b/payloads/libpayload/curses/PDCurses-3.4/demos/tui.c
new file mode 100644
index 0000000000..e57a1b0968
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/demos/tui.c
@@ -0,0 +1,821 @@
+/********************************* tui.c ************************************/
+/*
+ * 'textual user interface'
+ *
+ * $Id: tui.c,v 1.34 2008/07/14 12:35:23 wmcbrine Exp $
+ *
+ * Author : P.J. Kunst <kunst@prl.philips.nl>
+ * Date : 25-02-93
+ */
+
+#include <ctype.h>
+#include <curses.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include "tui.h"
+
+void statusmsg(char *);
+int waitforkey(void);
+void rmerror(void);
+
+#if defined(__unix) && !defined(__DJGPP__)
+#include <unistd.h>
+#endif
+
+#ifdef A_COLOR
+# define TITLECOLOR 1 /* color pair indices */
+# define MAINMENUCOLOR (2 | A_BOLD)
+# define MAINMENUREVCOLOR (3 | A_BOLD | A_REVERSE)
+# define SUBMENUCOLOR (4 | A_BOLD)
+# define SUBMENUREVCOLOR (5 | A_BOLD | A_REVERSE)
+# define BODYCOLOR 6
+# define STATUSCOLOR (7 | A_BOLD)
+# define INPUTBOXCOLOR 8
+# define EDITBOXCOLOR (9 | A_BOLD | A_REVERSE)
+#else
+# define TITLECOLOR 0 /* color pair indices */
+# define MAINMENUCOLOR (A_BOLD)
+# define MAINMENUREVCOLOR (A_BOLD | A_REVERSE)
+# define SUBMENUCOLOR (A_BOLD)
+# define SUBMENUREVCOLOR (A_BOLD | A_REVERSE)
+# define BODYCOLOR 0
+# define STATUSCOLOR (A_BOLD)
+# define INPUTBOXCOLOR 0
+# define EDITBOXCOLOR (A_BOLD | A_REVERSE)
+#endif
+
+
+#define th 1 /* title window height */
+#define mh 1 /* main menu height */
+#define sh 2 /* status window height */
+#define bh (LINES - th - mh - sh) /* body window height */
+#define bw COLS /* body window width */
+
+
+/******************************* STATIC ************************************/
+
+static WINDOW *wtitl, *wmain, *wbody, *wstat; /* title, menu, body, status win*/
+static int nexty, nextx;
+static int key = ERR, ch = ERR;
+static bool quit = FALSE;
+static bool incurses = FALSE;
+
+#ifndef PDCURSES
+static char wordchar(void)
+{
+ return 0x17; /* ^W */
+}
+#endif
+
+static char *padstr(char *s, int length)
+{
+ static char buf[MAXSTRLEN];
+ char fmt[10];
+
+ sprintf(fmt, (int)strlen(s) > length ? "%%.%ds" : "%%-%ds", length);
+ sprintf(buf, fmt, s);
+
+ return buf;
+}
+
+static char *prepad(char *s, int length)
+{
+ int i;
+ char *p = s;
+
+ if (length > 0)
+ {
+ memmove((void *)(s + length), (const void *)s, strlen(s) + 1);
+
+ for (i = 0; i < length; i++)
+ *p++ = ' ';
+ }
+
+ return s;
+}
+
+static void rmline(WINDOW *win, int nr) /* keeps box lines intact */
+{
+ mvwaddstr(win, nr, 1, padstr(" ", bw - 2));
+ wrefresh(win);
+}
+
+static void initcolor(void)
+{
+#ifdef A_COLOR
+ if (has_colors())
+ start_color();
+
+ /* foreground, background */
+
+ init_pair(TITLECOLOR & ~A_ATTR, COLOR_BLACK, COLOR_CYAN);
+ init_pair(MAINMENUCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_CYAN);
+ init_pair(MAINMENUREVCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_BLACK);
+ init_pair(SUBMENUCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_CYAN);
+ init_pair(SUBMENUREVCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_BLACK);
+ init_pair(BODYCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_BLUE);
+ init_pair(STATUSCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_CYAN);
+ init_pair(INPUTBOXCOLOR & ~A_ATTR, COLOR_BLACK, COLOR_CYAN);
+ init_pair(EDITBOXCOLOR & ~A_ATTR, COLOR_WHITE, COLOR_BLACK);
+#endif
+}
+
+static void setcolor(WINDOW *win, chtype color)
+{
+ chtype attr = color & A_ATTR; /* extract Bold, Reverse, Blink bits */
+
+#ifdef A_COLOR
+ attr &= ~A_REVERSE; /* ignore reverse, use colors instead! */
+ wattrset(win, COLOR_PAIR(color & A_CHARTEXT) | attr);
+#else
+ attr &= ~A_BOLD; /* ignore bold, gives messy display on HP-UX */
+ wattrset(win, attr);
+#endif
+}
+
+static void colorbox(WINDOW *win, chtype color, int hasbox)
+{
+ int maxy;
+#ifndef PDCURSES
+ int maxx;
+#endif
+ chtype attr = color & A_ATTR; /* extract Bold, Reverse, Blink bits */
+
+ setcolor(win, color);
+
+#ifdef A_COLOR
+ if (has_colors())
+ wbkgd(win, COLOR_PAIR(color & A_CHARTEXT) | (attr & ~A_REVERSE));
+ else
+#endif
+ wbkgd(win, attr);
+
+ werase(win);
+
+#ifdef PDCURSES
+ maxy = getmaxy(win);
+#else
+ getmaxyx(win, maxy, maxx);
+#endif
+ if (hasbox && (maxy > 2))
+ box(win, 0, 0);
+
+ touchwin(win);
+ wrefresh(win);
+}
+
+static void idle(void)
+{
+ char buf[MAXSTRLEN];
+ time_t t;
+ struct tm *tp;
+
+ if (time (&t) == -1)
+ return; /* time not available */
+
+ tp = localtime(&t);
+ sprintf(buf, " %.2d-%.2d-%.4d %.2d:%.2d:%.2d",
+ tp->tm_mday, tp->tm_mon + 1, tp->tm_year + 1900,
+ tp->tm_hour, tp->tm_min, tp->tm_sec);
+
+ mvwaddstr(wtitl, 0, bw - strlen(buf) - 2, buf);
+ wrefresh(wtitl);
+}
+
+static void menudim(menu *mp, int *lines, int *columns)
+{
+ int n, l, mmax = 0;
+
+ for (n=0; mp->func; n++, mp++)
+ if ((l = strlen(mp->name)) > mmax) mmax = l;
+
+ *lines = n;
+ *columns = mmax + 2;
+}
+
+static void setmenupos(int y, int x)
+{
+ nexty = y;
+ nextx = x;
+}
+
+static void getmenupos(int *y, int *x)
+{
+ *y = nexty;
+ *x = nextx;
+}
+
+static int hotkey(const char *s)
+{
+ int c0 = *s; /* if no upper case found, return first char */
+
+ for (; *s; s++)
+ if (isupper((unsigned char)*s))
+ break;
+
+ return *s ? *s : c0;
+}
+
+static void repaintmenu(WINDOW *wmenu, menu *mp)
+{
+ int i;
+ menu *p = mp;
+
+ for (i = 0; p->func; i++, p++)
+ mvwaddstr(wmenu, i + 1, 2, p->name);
+
+ touchwin(wmenu);
+ wrefresh(wmenu);
+}
+
+static void repaintmainmenu(int width, menu *mp)
+{
+ int i;
+ menu *p = mp;
+
+ for (i = 0; p->func; i++, p++)
+ mvwaddstr(wmain, 0, i * width, prepad(padstr(p->name, width - 1), 1));
+
+ touchwin(wmain);
+ wrefresh(wmain);
+}
+
+static void mainhelp(void)
+{
+#ifdef ALT_X
+ statusmsg("Use arrow keys and Enter to select (Alt-X to quit)");
+#else
+ statusmsg("Use arrow keys and Enter to select");
+#endif
+}
+
+static void mainmenu(menu *mp)
+{
+ int nitems, barlen, old = -1, cur = 0, c, cur0;
+
+ menudim(mp, &nitems, &barlen);
+ repaintmainmenu(barlen, mp);
+
+ while (!quit)
+ {
+ if (cur != old)
+ {
+ if (old != -1)
+ {
+ mvwaddstr(wmain, 0, old * barlen,
+ prepad(padstr(mp[old].name, barlen - 1), 1));
+
+ statusmsg(mp[cur].desc);
+ }
+ else
+ mainhelp();
+
+ setcolor(wmain, MAINMENUREVCOLOR);
+
+ mvwaddstr(wmain, 0, cur * barlen,
+ prepad(padstr(mp[cur].name, barlen - 1), 1));
+
+ setcolor(wmain, MAINMENUCOLOR);
+ old = cur;
+ wrefresh(wmain);
+ }
+
+ switch (c = (key != ERR ? key : waitforkey()))
+ {
+ case KEY_DOWN:
+ case '\n': /* menu item selected */
+ touchwin(wbody);
+ wrefresh(wbody);
+ rmerror();
+ setmenupos(th + mh, cur * barlen);
+ curs_set(1);
+ (mp[cur].func)(); /* perform function */
+ curs_set(0);
+
+ switch (key)
+ {
+ case KEY_LEFT:
+ cur = (cur + nitems - 1) % nitems;
+ key = '\n';
+ break;
+
+ case KEY_RIGHT:
+ cur = (cur + 1) % nitems;
+ key = '\n';
+ break;
+
+ default:
+ key = ERR;
+ }
+
+ repaintmainmenu(barlen, mp);
+ old = -1;
+ break;
+
+ case KEY_LEFT:
+ cur = (cur + nitems - 1) % nitems;
+ break;
+
+ case KEY_RIGHT:
+ cur = (cur + 1) % nitems;
+ break;
+
+ case KEY_ESC:
+ mainhelp();
+ break;
+
+ default:
+ cur0 = cur;
+
+ do
+ {
+ cur = (cur + 1) % nitems;
+
+ } while ((cur != cur0) && (hotkey(mp[cur].name) != toupper(c)));
+
+ if (hotkey(mp[cur].name) == toupper(c))
+ key = '\n';
+ }
+
+ }
+
+ rmerror();
+ touchwin(wbody);
+ wrefresh(wbody);
+}
+
+static void cleanup(void) /* cleanup curses settings */
+{
+ if (incurses)
+ {
+ delwin(wtitl);
+ delwin(wmain);
+ delwin(wbody);
+ delwin(wstat);
+ curs_set(1);
+ endwin();
+ incurses = FALSE;
+ }
+}
+
+
+/******************************* EXTERNAL **********************************/
+
+void clsbody(void)
+{
+ werase(wbody);
+ wmove(wbody, 0, 0);
+}
+
+int bodylen(void)
+{
+#ifdef PDCURSES
+ return getmaxy(wbody);
+#else
+ int maxy, maxx;
+
+ getmaxyx(wbody, maxy, maxx);
+ return maxy;
+#endif
+}
+
+WINDOW *bodywin(void)
+{
+ return wbody;
+}
+
+void rmerror(void)
+{
+ rmline(wstat, 0);
+}
+
+void rmstatus(void)
+{
+ rmline(wstat, 1);
+}
+
+void titlemsg(char *msg)
+{
+ mvwaddstr(wtitl, 0, 2, padstr(msg, bw - 3));
+ wrefresh(wtitl);
+}
+
+void bodymsg(char *msg)
+{
+ waddstr(wbody, msg);
+ wrefresh(wbody);
+}
+
+void errormsg(char *msg)
+{
+ beep();
+ mvwaddstr(wstat, 0, 2, padstr(msg, bw - 3));
+ wrefresh(wstat);
+}
+
+void statusmsg(char *msg)
+{
+ mvwaddstr(wstat, 1, 2, padstr(msg, bw - 3));
+ wrefresh(wstat);
+}
+
+bool keypressed(void)
+{
+ ch = wgetch(wbody);
+
+ return ch != ERR;
+}
+
+int getkey(void)
+{
+ int c = ch;
+
+ ch = ERR;
+#ifdef ALT_X
+ quit = (c == ALT_X); /* PC only ! */
+#endif
+ return c;
+}
+
+int waitforkey(void)
+{
+ do idle(); while (!keypressed());
+ return getkey();
+}
+
+void DoExit(void) /* terminate program */
+{
+ quit = TRUE;
+}
+
+void domenu(menu *mp)
+{
+ int y, x, nitems, barlen, mheight, mw, old = -1, cur = 0, cur0;
+ bool stop = FALSE;
+ WINDOW *wmenu;
+
+ curs_set(0);
+ getmenupos(&y, &x);
+ menudim(mp, &nitems, &barlen);
+ mheight = nitems + 2;
+ mw = barlen + 2;
+ wmenu = newwin(mheight, mw, y, x);
+ colorbox(wmenu, SUBMENUCOLOR, 1);
+ repaintmenu(wmenu, mp);
+
+ key = ERR;
+
+ while (!stop && !quit)
+ {
+ if (cur != old)
+ {
+ if (old != -1)
+ mvwaddstr(wmenu, old + 1, 1,
+ prepad(padstr(mp[old].name, barlen - 1), 1));
+
+ setcolor(wmenu, SUBMENUREVCOLOR);
+ mvwaddstr(wmenu, cur + 1, 1,
+ prepad(padstr(mp[cur].name, barlen - 1), 1));
+
+ setcolor(wmenu, SUBMENUCOLOR);
+ statusmsg(mp[cur].desc);
+
+ old = cur;
+ wrefresh(wmenu);
+ }
+
+ switch (key = ((key != ERR) ? key : waitforkey()))
+ {
+ case '\n': /* menu item selected */
+ touchwin(wbody);
+ wrefresh(wbody);
+ setmenupos(y + 1, x + 1);
+ rmerror();
+
+ key = ERR;
+ curs_set(1);
+ (mp[cur].func)(); /* perform function */
+ curs_set(0);
+
+ repaintmenu(wmenu, mp);
+
+ old = -1;
+ break;
+
+ case KEY_UP:
+ cur = (cur + nitems - 1) % nitems;
+ key = ERR;
+ break;
+
+ case KEY_DOWN:
+ cur = (cur + 1) % nitems;
+ key = ERR;
+ break;
+
+ case KEY_ESC:
+ case KEY_LEFT:
+ case KEY_RIGHT:
+ if (key == KEY_ESC)
+ key = ERR; /* return to prev submenu */
+
+ stop = TRUE;
+ break;
+
+ default:
+ cur0 = cur;
+
+ do
+ {
+ cur = (cur + 1) % nitems;
+
+ } while ((cur != cur0) &&
+ (hotkey(mp[cur].name) != toupper((int)key)));
+
+ key = (hotkey(mp[cur].name) == toupper((int)key)) ? '\n' : ERR;
+ }
+
+ }
+
+ rmerror();
+ delwin(wmenu);
+ touchwin(wbody);
+ wrefresh(wbody);
+}
+
+void startmenu(menu *mp, char *mtitle)
+{
+ initscr();
+ incurses = TRUE;
+ initcolor();
+
+ wtitl = subwin(stdscr, th, bw, 0, 0);
+ wmain = subwin(stdscr, mh, bw, th, 0);
+ wbody = subwin(stdscr, bh, bw, th + mh, 0);
+ wstat = subwin(stdscr, sh, bw, th + mh + bh, 0);
+
+ colorbox(wtitl, TITLECOLOR, 0);
+ colorbox(wmain, MAINMENUCOLOR, 0);
+ colorbox(wbody, BODYCOLOR, 0);
+ colorbox(wstat, STATUSCOLOR, 0);
+
+ if (mtitle)
+ titlemsg(mtitle);
+
+ cbreak(); /* direct input (no newline required)... */
+ noecho(); /* ... without echoing */
+ curs_set(0); /* hide cursor (if possible) */
+ nodelay(wbody, TRUE); /* don't wait for input... */
+ halfdelay(10); /* ...well, no more than a second, anyway */
+ keypad(wbody, TRUE); /* enable cursor keys */
+ scrollok(wbody, TRUE); /* enable scrolling in main window */
+
+ leaveok(stdscr, TRUE);
+ leaveok(wtitl, TRUE);
+ leaveok(wmain, TRUE);
+ leaveok(wstat, TRUE);
+
+ mainmenu(mp);
+
+ cleanup();
+}
+
+static void repainteditbox(WINDOW *win, int x, char *buf)
+{
+#ifndef PDCURSES
+ int maxy;
+#endif
+ int maxx;
+
+#ifdef PDCURSES
+ maxx = getmaxx(win);
+#else
+ getmaxyx(win, maxy, maxx);
+#endif
+ werase(win);
+ mvwprintw(win, 0, 0, "%s", padstr(buf, maxx));
+ wmove(win, 0, x);
+ wrefresh(win);
+}
+
+/*
+
+ weditstr() - edit string
+
+ Description:
+ The initial value of 'str' with a maximum length of 'field' - 1,
+ which is supplied by the calling routine, is editted. The user's
+ erase (^H), kill (^U) and delete word (^W) chars are interpreted.
+ The PC insert or Tab keys toggle between insert and edit mode.
+ Escape aborts the edit session, leaving 'str' unchanged.
+ Enter, Up or Down Arrow are used to accept the changes to 'str'.
+ NOTE: editstr(), mveditstr(), and mvweditstr() are macros.
+
+ Return Value:
+ Returns the input terminating character on success (Escape,
+ Enter, Up or Down Arrow) and ERR on error.
+
+ Errors:
+ It is an error to call this function with a NULL window pointer.
+ The length of the initial 'str' must not exceed 'field' - 1.
+
+*/
+
+int weditstr(WINDOW *win, char *buf, int field)
+{
+ char org[MAXSTRLEN], *tp, *bp = buf;
+ bool defdisp = TRUE, stop = FALSE, insert = FALSE;
+ int cury, curx, begy, begx, oldattr;
+ WINDOW *wedit;
+ int c = 0;
+
+ if ((field >= MAXSTRLEN) || (buf == NULL) ||
+ ((int)strlen(buf) > field - 1))
+ return ERR;
+
+ strcpy(org, buf); /* save original */
+
+ wrefresh(win);
+ getyx(win, cury, curx);
+ getbegyx(win, begy, begx);
+
+ wedit = subwin(win, 1, field, begy + cury, begx + curx);
+ oldattr = wedit->_attrs;
+ colorbox(wedit, EDITBOXCOLOR, 0);
+
+ keypad(wedit, TRUE);
+ curs_set(1);
+
+ while (!stop)
+ {
+ idle();
+ repainteditbox(wedit, bp - buf, buf);
+
+ switch (c = wgetch(wedit))
+ {
+ case ERR:
+ break;
+
+ case KEY_ESC:
+ strcpy(buf, org); /* restore original */
+ stop = TRUE;
+ break;
+
+ case '\n':
+ case KEY_UP:
+ case KEY_DOWN:
+ stop = TRUE;
+ break;
+
+ case KEY_LEFT:
+ if (bp > buf)
+ bp--;
+ break;
+
+ case KEY_RIGHT:
+ defdisp = FALSE;
+ if (bp - buf < (int)strlen(buf))
+ bp++;
+ break;
+
+ case '\t': /* TAB -- because insert
+ is broken on HPUX */
+ case KEY_IC: /* enter insert mode */
+ case KEY_EIC: /* exit insert mode */
+ defdisp = FALSE;
+ insert = !insert;
+
+ curs_set(insert ? 2 : 1);
+ break;
+
+ default:
+ if (c == erasechar()) /* backspace, ^H */
+ {
+ if (bp > buf)
+ {
+ memmove((void *)(bp - 1), (const void *)bp, strlen(bp) + 1);
+ bp--;
+ }
+ }
+ else if (c == killchar()) /* ^U */
+ {
+ bp = buf;
+ *bp = '\0';
+ }
+ else if (c == wordchar()) /* ^W */
+ {
+ tp = bp;
+
+ while ((bp > buf) && (*(bp - 1) == ' '))
+ bp--;
+ while ((bp > buf) && (*(bp - 1) != ' '))
+ bp--;
+
+ memmove((void *)bp, (const void *)tp, strlen(tp) + 1);
+ }
+ else if (isprint(c))
+ {
+ if (defdisp)
+ {
+ bp = buf;
+ *bp = '\0';
+ defdisp = FALSE;
+ }
+
+ if (insert)
+ {
+ if ((int)strlen(buf) < field - 1)
+ {
+ memmove((void *)(bp + 1), (const void *)bp,
+ strlen(bp) + 1);
+
+ *bp++ = c;
+ }
+ }
+ else if (bp - buf < field - 1)
+ {
+ /* append new string terminator */
+
+ if (!*bp)
+ bp[1] = '\0';
+
+ *bp++ = c;
+ }
+ }
+ }
+ }
+
+ curs_set(0);
+
+ wattrset(wedit, oldattr);
+ repainteditbox(wedit, bp - buf, buf);
+ delwin(wedit);
+
+ return c;
+}
+
+WINDOW *winputbox(WINDOW *win, int nlines, int ncols)
+{
+ WINDOW *winp;
+ int cury, curx, begy, begx;
+
+ getyx(win, cury, curx);
+ getbegyx(win, begy, begx);
+
+ winp = newwin(nlines, ncols, begy + cury, begx + curx);
+ colorbox(winp, INPUTBOXCOLOR, 1);
+
+ return winp;
+}
+
+int getstrings(char *desc[], char *buf[], int field)
+{
+ WINDOW *winput;
+ int oldy, oldx, maxy, maxx, nlines, ncols, i, n, l, mmax = 0;
+ int c = 0;
+ bool stop = FALSE;
+
+ for (n = 0; desc[n]; n++)
+ if ((l = strlen(desc[n])) > mmax)
+ mmax = l;
+
+ nlines = n + 2; ncols = mmax + field + 4;
+ getyx(wbody, oldy, oldx);
+ getmaxyx(wbody, maxy, maxx);
+
+ winput = mvwinputbox(wbody, (maxy - nlines) / 2, (maxx - ncols) / 2,
+ nlines, ncols);
+
+ for (i = 0; i < n; i++)
+ mvwprintw(winput, i + 1, 2, "%s", desc[i]);
+
+ i = 0;
+
+ while (!stop)
+ {
+ switch (c = mvweditstr(winput, i+1, mmax+3, buf[i], field))
+ {
+ case KEY_ESC:
+ stop = TRUE;
+ break;
+
+ case KEY_UP:
+ i = (i + n - 1) % n;
+ break;
+
+ case '\n':
+ case '\t':
+ case KEY_DOWN:
+ if (++i == n)
+ stop = TRUE; /* all passed? */
+ }
+ }
+
+ delwin(winput);
+ touchwin(wbody);
+ wmove(wbody, oldy, oldx);
+ wrefresh(wbody);
+
+ return c;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/demos/tui.h b/payloads/libpayload/curses/PDCurses-3.4/demos/tui.h
new file mode 100644
index 0000000000..b99ca6b222
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/demos/tui.h
@@ -0,0 +1,67 @@
+/*
+ * 'textual user interface'
+ *
+ * $Id: tui.h,v 1.11 2008/07/14 12:35:23 wmcbrine Exp $
+ *
+ * Author : P.J. Kunst <kunst@prl.philips.nl>
+ * Date : 25-02-93
+ */
+
+#ifndef _TUI_H_
+#define _TUI_H_
+
+#include <curses.h>
+
+#ifdef A_COLOR
+#define A_ATTR (A_ATTRIBUTES ^ A_COLOR) /* A_BLINK, A_REVERSE, A_BOLD */
+#else
+#define A_ATTR (A_ATTRIBUTES) /* standard UNIX attributes */
+#endif
+
+#define MAXSTRLEN 256
+#define KEY_ESC 0x1b /* Escape */
+
+typedef void (*FUNC)(void);
+
+typedef struct
+{
+ char *name; /* item label */
+ FUNC func; /* (pointer to) function */
+ char *desc; /* function description */
+} menu;
+
+/* ANSI C function prototypes: */
+
+void clsbody(void);
+int bodylen(void);
+WINDOW *bodywin(void);
+
+void rmerror(void);
+void rmstatus(void);
+
+void titlemsg(char *msg);
+void bodymsg(char *msg);
+void errormsg(char *msg);
+void statusmsg(char *msg);
+
+bool keypressed(void);
+int getkey(void);
+int waitforkey(void);
+
+void DoExit(void);
+void startmenu(menu *mp, char *title);
+void domenu(menu *mp);
+
+int weditstr(WINDOW *win, char *buf, int field);
+WINDOW *winputbox(WINDOW *win, int nlines, int ncols);
+int getstrings(char *desc[], char *buf[], int field);
+
+#define editstr(s,f) (weditstr(stdscr,s,f))
+#define mveditstr(y,x,s,f) (move(y,x)==ERR?ERR:editstr(s,f))
+#define mvweditstr(w,y,x,s,f) (wmove(w,y,x)==ERR?ERR:weditstr(w,s,f))
+
+#define inputbox(l,c) (winputbox(stdscr,l,c))
+#define mvinputbox(y,x,l,c) (move(y,x)==ERR?w:inputbox(l,c))
+#define mvwinputbox(w,y,x,l,c) (wmove(w,y,x)==ERR?w:winputbox(w,l,c))
+
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/demos/tuidemo.c b/payloads/libpayload/curses/PDCurses-3.4/demos/tuidemo.c
new file mode 100644
index 0000000000..a22d2a4181
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/demos/tuidemo.c
@@ -0,0 +1,233 @@
+/*
+ * $Id: tuidemo.c,v 1.22 2008/07/14 12:35:23 wmcbrine Exp $
+ *
+ * Author : P.J. Kunst <kunst@prl.philips.nl>
+ * Date : 25-02-93
+ *
+ * Purpose: This program demonstrates the use of the 'curses' library
+ * for the creation of (simple) menu-operated programs.
+ * In the PDCurses version, use is made of colors for the
+ * highlighting of subwindows (title bar, status bar etc).
+ *
+ * Acknowledgement: some ideas were borrowed from Mark Hessling's
+ * version of the 'testcurs' program.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+#include "tui.h"
+
+/* change this if source at other location */
+
+#ifdef XCURSES
+# define FNAME "../demos/tui.c"
+#else
+# define FNAME "..\\demos\\tui.c"
+#endif
+
+/**************************** strings entry box ***************************/
+
+void address(void)
+{
+ char *fieldname[6] =
+ {
+ "Name", "Street", "City", "State", "Country", (char *)0
+ };
+
+ char *fieldbuf[5];
+ WINDOW *wbody = bodywin();
+ int i, field = 50;
+
+ for (i = 0; i < 5; i++)
+ fieldbuf[i] = calloc(1, field + 1);
+
+ if (getstrings(fieldname, fieldbuf, field) != KEY_ESC)
+ {
+ for (i = 0; fieldname[i]; i++)
+ wprintw(wbody, "%10s : %s\n",
+ fieldname[i], fieldbuf[i]);
+
+ wrefresh(wbody);
+ }
+
+ for (i = 0; i < 5; i++)
+ free(fieldbuf[i]);
+}
+
+/**************************** string entry box ****************************/
+
+char *getfname(char *desc, char *fname, int field)
+{
+ char *fieldname[2];
+ char *fieldbuf[1];
+
+ fieldname[0] = desc;
+ fieldname[1] = 0;
+ fieldbuf[0] = fname;
+
+ return (getstrings(fieldname, fieldbuf, field) == KEY_ESC) ? NULL : fname;
+}
+
+/**************************** a very simple file browser ******************/
+
+void showfile(char *fname)
+{
+ int i, bh = bodylen();
+ FILE *fp;
+ char buf[MAXSTRLEN];
+ bool ateof = FALSE;
+
+ statusmsg("FileBrowser: Hit key to continue, Q to quit");
+
+ if ((fp = fopen(fname, "r")) != NULL) /* file available? */
+ {
+ while (!ateof)
+ {
+ clsbody();
+
+ for (i = 0; i < bh - 1 && !ateof; i++)
+ {
+ buf[0] = '\0';
+ fgets(buf, MAXSTRLEN, fp);
+
+ if (strlen(buf))
+ bodymsg(buf);
+ else
+ ateof = TRUE;
+ }
+
+ switch (waitforkey())
+ {
+ case 'Q':
+ case 'q':
+ case 0x1b:
+ ateof = TRUE;
+ }
+ }
+
+ fclose(fp);
+ }
+ else
+ {
+ sprintf(buf, "ERROR: file '%s' not found", fname);
+ errormsg(buf);
+ }
+}
+
+/***************************** forward declarations ***********************/
+
+void sub0(void), sub1(void), sub2(void), sub3(void);
+void func1(void), func2(void);
+void subfunc1(void), subfunc2(void);
+void subsub(void);
+
+/***************************** menus initialization ***********************/
+
+menu MainMenu[] =
+{
+ { "Asub", sub0, "Go inside first submenu" },
+ { "Bsub", sub1, "Go inside second submenu" },
+ { "Csub", sub2, "Go inside third submenu" },
+ { "Dsub", sub3, "Go inside fourth submenu" },
+ { "", (FUNC)0, "" } /* always add this as the last item! */
+};
+
+menu SubMenu0[] =
+{
+ { "Exit", DoExit, "Terminate program" },
+ { "", (FUNC)0, "" }
+};
+
+menu SubMenu1[] =
+{
+ { "OneBeep", func1, "Sound one beep" },
+ { "TwoBeeps", func2, "Sound two beeps" },
+ { "", (FUNC)0, "" }
+};
+
+menu SubMenu2[] =
+{
+ { "Browse", subfunc1, "Source file lister" },
+ { "Input", subfunc2, "Interactive file lister" },
+ { "Address", address, "Get address data" },
+ { "", (FUNC)0, "" }
+};
+
+menu SubMenu3[] =
+{
+ { "SubSub", subsub, "Go inside sub-submenu" },
+ { "", (FUNC)0, "" }
+};
+
+/***************************** main menu functions ************************/
+
+void sub0(void)
+{
+ domenu(SubMenu0);
+}
+
+void sub1(void)
+{
+ domenu(SubMenu1);
+}
+
+void sub2(void)
+{
+ domenu(SubMenu2);
+}
+
+void sub3(void)
+{
+ domenu(SubMenu3);
+}
+
+/***************************** submenu1 functions *************************/
+
+void func1(void)
+{
+ beep();
+ bodymsg("One beep! ");
+}
+
+void func2(void)
+{
+ beep();
+ bodymsg("Two beeps! ");
+ beep();
+}
+
+/***************************** submenu2 functions *************************/
+
+void subfunc1(void)
+{
+ showfile(FNAME);
+}
+
+void subfunc2(void)
+{
+ char fname[MAXSTRLEN];
+
+ strcpy(fname, FNAME);
+ if (getfname ("File to browse:", fname, 50))
+ showfile(fname);
+}
+
+/***************************** submenu3 functions *************************/
+
+void subsub(void)
+{
+ domenu(SubMenu2);
+}
+
+/***************************** start main menu ***************************/
+
+int main(int argc, char **argv)
+{
+ setlocale(LC_ALL, "");
+
+ startmenu(MainMenu, "TUI - 'textual user interface' demonstration program");
+
+ return 0;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/demos/worm.c b/payloads/libpayload/curses/PDCurses-3.4/demos/worm.c
new file mode 100644
index 0000000000..5a823f9069
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/demos/worm.c
@@ -0,0 +1,434 @@
+/****************************************************************************
+ * Copyright (c) 2005 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/*
+
+ @@@ @@@ @@@@@@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@
+ @@@ @@@ @@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@
+ @@@ @@@ @@@@ @@@@ @@@@ @@@@ @@@ @@@@
+ @@@ @@ @@@ @@@ @@@ @@@ @@@ @@@ @@@
+ @@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@
+ @@@@ @@@@ @@@@ @@@ @@@ @@@ @@@ @@@ @@@
+ @@@@@@@@@@@@ @@@@ @@@@ @@@ @@@ @@@ @@@
+ @@@@ @@@@ @@@@@@@@@@@@ @@@ @@@ @@@ @@@
+ @@ @@ @@@@@@@@@@ @@@ @@@ @@@ @@@
+
+ Eric P. Scott
+ Caltech High Energy Physics
+ October, 1980
+
+ Color by Eric S. Raymond
+ July, 1995
+
+Options:
+ -f fill screen with copies of 'WORM' at start.
+ -l <n> set worm length
+ -n <n> set number of worms
+ -t make worms leave droppings
+
+ $Id: worm.c,v 1.16 2008/07/13 16:08:17 wmcbrine Exp $
+*/
+
+#include <curses.h>
+#include <stdlib.h>
+#include <time.h>
+
+#define FLAVORS 7
+
+static chtype flavor[FLAVORS] =
+{
+ 'O', '*', '#', '$', '%', '0', '@'
+};
+
+static const short xinc[] =
+{
+ 1, 1, 1, 0, -1, -1, -1, 0
+},
+yinc[] =
+{
+ -1, 0, 1, 1, 1, 0, -1, -1
+};
+
+static struct worm
+{
+ int orientation, head;
+ short *xpos, *ypos;
+} worm[40];
+
+static const char *field;
+static int length = 16, number = 3;
+static chtype trail = ' ';
+
+static const struct options
+{
+ int nopts;
+ int opts[3];
+} normal[8] =
+{
+ { 3, { 7, 0, 1 } }, { 3, { 0, 1, 2 } }, { 3, { 1, 2, 3 } },
+ { 3, { 2, 3, 4 } }, { 3, { 3, 4, 5 } }, { 3, { 4, 5, 6 } },
+ { 3, { 5, 6, 7 } }, { 3, { 6, 7, 0 } }
+},
+upper[8] =
+{
+ { 1, { 1, 0, 0 } }, { 2, { 1, 2, 0 } }, { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } }, { 2, { 4, 5, 0 } },
+ { 1, { 5, 0, 0 } }, { 2, { 1, 5, 0 } }
+},
+left[8] =
+{
+ { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } },
+ { 2, { 2, 3, 0 } }, { 1, { 3, 0, 0 } }, { 2, { 3, 7, 0 } },
+ { 1, { 7, 0, 0 } }, { 2, { 7, 0, 0 } }
+},
+right[8] =
+{
+ { 1, { 7, 0, 0 } }, { 2, { 3, 7, 0 } }, { 1, { 3, 0, 0 } },
+ { 2, { 3, 4, 0 } }, { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } }, { 2, { 6, 7, 0 } }
+},
+lower[8] =
+{
+ { 0, { 0, 0, 0 } }, { 2, { 0, 1, 0 } }, { 1, { 1, 0, 0 } },
+ { 2, { 1, 5, 0 } }, { 1, { 5, 0, 0 } }, { 2, { 5, 6, 0 } },
+ { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } }
+},
+upleft[8] =
+{
+ { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } }, { 1, { 3, 0, 0 } },
+ { 2, { 1, 3, 0 } }, { 1, { 1, 0, 0 } }
+},
+upright[8] =
+{
+ { 2, { 3, 5, 0 } }, { 1, { 3, 0, 0 } }, { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } }, { 1, { 5, 0, 0 } }
+},
+lowleft[8] =
+{
+ { 3, { 7, 0, 1 } }, { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } },
+ { 1, { 1, 0, 0 } }, { 2, { 1, 7, 0 } }, { 1, { 7, 0, 0 } },
+ { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } }
+},
+lowright[8] =
+{
+ { 0, { 0, 0, 0 } }, { 1, { 7, 0, 0 } }, { 2, { 5, 7, 0 } },
+ { 1, { 5, 0, 0 } }, { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } },
+ { 0, { 0, 0, 0 } }, { 0, { 0, 0, 0 } }
+};
+
+static void cleanup(void)
+{
+ standend();
+ refresh();
+ curs_set(1);
+ endwin();
+}
+
+int main(int argc, char *argv[])
+{
+ const struct options *op;
+ struct worm *w;
+ short **ref, *ip;
+ int x, y, n, h, last, bottom, seed;
+
+ for (x = 1; x < argc; x++)
+ {
+ char *p = argv[x];
+
+ if (*p == '-')
+ p++;
+
+ switch (*p)
+ {
+ case 'f':
+ field = "WORM";
+ break;
+ case 'l':
+ if (++x == argc)
+ goto usage;
+
+ if ((length = atoi(argv[x])) < 2 || length > 1024)
+ {
+ fprintf(stderr, "%s: Invalid length\n", *argv);
+ return EXIT_FAILURE;
+ }
+
+ break;
+ case 'n':
+ if (++x == argc)
+ goto usage;
+
+ if ((number = atoi(argv[x])) < 1 || number > 40)
+ {
+ fprintf(stderr, "%s: Invalid number of worms\n", *argv);
+ return EXIT_FAILURE;
+ }
+
+ break;
+ case 't':
+ trail = '.';
+ break;
+ default:
+ usage:
+ fprintf(stderr, "usage: %s [-field] [-length #] "
+ "[-number #] [-trail]\n", *argv);
+ return EXIT_FAILURE;
+ }
+ }
+
+#ifdef XCURSES
+ Xinitscr(argc, argv);
+#else
+ initscr();
+#endif
+ seed = time((time_t *)0);
+ srand(seed);
+
+ noecho();
+ cbreak();
+ nonl();
+ keypad(stdscr, TRUE);
+
+ curs_set(0);
+
+ bottom = LINES - 1;
+ last = COLS - 1;
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ int bg = COLOR_BLACK;
+ start_color();
+
+# if defined(NCURSES_VERSION) || (defined(PDC_BUILD) && PDC_BUILD > 3000)
+ if (use_default_colors() == OK)
+ bg = -1;
+# endif
+
+# define SET_COLOR(num, fg) \
+ init_pair(num + 1, fg, bg); \
+ flavor[num] |= COLOR_PAIR(num + 1) | A_BOLD
+
+ SET_COLOR(0, COLOR_GREEN);
+ SET_COLOR(1, COLOR_RED);
+ SET_COLOR(2, COLOR_CYAN);
+ SET_COLOR(3, COLOR_WHITE);
+ SET_COLOR(4, COLOR_MAGENTA);
+ SET_COLOR(5, COLOR_BLUE);
+ SET_COLOR(6, COLOR_YELLOW);
+ }
+#endif
+
+ ref = malloc(sizeof(short *) * LINES);
+
+ for (y = 0; y < LINES; y++)
+ {
+ ref[y] = malloc(sizeof(short) * COLS);
+
+ for (x = 0; x < COLS; x++)
+ ref[y][x] = 0;
+ }
+
+#ifdef BADCORNER
+ /* if addressing the lower right corner doesn't work in your curses */
+
+ ref[bottom][last] = 1;
+#endif
+
+ for (n = number, w = &worm[0]; --n >= 0; w++)
+ {
+ w->orientation = w->head = 0;
+
+ if ((ip = malloc(sizeof(short) * (length + 1))) == NULL)
+ {
+ fprintf(stderr, "%s: out of memory\n", *argv);
+ return EXIT_FAILURE;
+ }
+
+ w->xpos = ip;
+
+ for (x = length; --x >= 0;)
+ *ip++ = -1;
+
+ if ((ip = malloc(sizeof(short) * (length + 1))) == NULL)
+ {
+ fprintf(stderr, "%s: out of memory\n", *argv);
+ return EXIT_FAILURE;
+ }
+
+ w->ypos = ip;
+
+ for (y = length; --y >= 0;)
+ *ip++ = -1;
+ }
+
+ if (field)
+ {
+ const char *p = field;
+
+ for (y = bottom; --y >= 0;)
+ for (x = COLS; --x >= 0;)
+ {
+ addch((chtype) (*p++));
+
+ if (!*p)
+ p = field;
+ }
+ }
+
+ napms(12);
+ refresh();
+ nodelay(stdscr, TRUE);
+
+ for (;;)
+ {
+ int ch;
+
+ if ((ch = getch()) > 0)
+ {
+#ifdef KEY_RESIZE
+ if (ch == KEY_RESIZE)
+ {
+# ifdef PDCURSES
+ resize_term(0, 0);
+ erase();
+# endif
+ if (last != COLS - 1)
+ {
+ for (y = 0; y <= bottom; y++)
+ {
+ ref[y] = realloc(ref[y], sizeof(short) * COLS);
+
+ for (x = last + 1; x < COLS; x++)
+ ref[y][x] = 0;
+ }
+
+ last = COLS - 1;
+ }
+
+ if (bottom != LINES - 1)
+ {
+ for (y = LINES; y <= bottom; y++)
+ free(ref[y]);
+
+ ref = realloc(ref, sizeof(short *) * LINES);
+
+ for (y = bottom + 1; y < LINES; y++)
+ {
+ ref[y] = malloc(sizeof(short) * COLS);
+
+ for (x = 0; x < COLS; x++)
+ ref[y][x] = 0;
+ }
+
+ bottom = LINES - 1;
+ }
+ }
+
+#endif /* KEY_RESIZE */
+
+ /* Make it simple to put this into single-step mode,
+ or resume normal operation - T. Dickey */
+
+ if (ch == 'q')
+ {
+ cleanup();
+ return EXIT_SUCCESS;
+ }
+ else if (ch == 's')
+ nodelay(stdscr, FALSE);
+ else if (ch == ' ')
+ nodelay(stdscr, TRUE);
+ }
+
+ for (n = 0, w = &worm[0]; n < number; n++, w++)
+ {
+ if ((x = w->xpos[h = w->head]) < 0)
+ {
+ move(y = w->ypos[h] = bottom, x = w->xpos[h] = 0);
+ addch(flavor[n % FLAVORS]);
+ ref[y][x]++;
+ }
+ else
+ y = w->ypos[h];
+
+ if (x > last)
+ x = last;
+
+ if (y > bottom)
+ y = bottom;
+
+ if (++h == length)
+ h = 0;
+
+ if (w->xpos[w->head = h] >= 0)
+ {
+ int x1 = w->xpos[h];
+ int y1 = w->ypos[h];
+
+ if (y1 < LINES && x1 < COLS && --ref[y1][x1] == 0)
+ {
+ move(y1, x1);
+ addch(trail);
+ }
+ }
+
+ op = &(x == 0 ? (y == 0 ? upleft :
+ (y == bottom ? lowleft : left)) :
+ (x == last ? (y == 0 ? upright :
+ (y == bottom ? lowright : right)) :
+ (y == 0 ? upper :
+ (y == bottom ? lower : normal))))
+ [w->orientation];
+
+ switch (op->nopts)
+ {
+ case 0:
+ cleanup();
+ return EXIT_SUCCESS;
+ case 1:
+ w->orientation = op->opts[0];
+ break;
+ default:
+ w->orientation = op->opts[rand() % op->nopts];
+ }
+
+ move(y += yinc[w->orientation], x += xinc[w->orientation]);
+
+ if (y < 0)
+ y = 0;
+
+ addch(flavor[n % FLAVORS]);
+ ref[w->ypos[h] = y][w->xpos[h] = x]++;
+ }
+ napms(12);
+ refresh();
+ }
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/demos/xmas.c b/payloads/libpayload/curses/PDCurses-3.4/demos/xmas.c
new file mode 100644
index 0000000000..706858a5aa
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/demos/xmas.c
@@ -0,0 +1,957 @@
+/******************************************************************************/
+/* asciixmas */
+/* December 1989 Larry Bartz Indianapolis, IN */
+/* */
+/* */
+/* I'm dreaming of an ascii character-based monochrome Christmas, */
+/* Just like the one's I used to know! */
+/* Via a full duplex communications channel, */
+/* At 9600 bits per second, */
+/* Even though it's kinda slow. */
+/* */
+/* I'm dreaming of an ascii character-based monochrome Christmas, */
+/* With ev'ry C program I write! */
+/* May your screen be merry and bright! */
+/* And may all your Christmases be amber or green, */
+/* (for reduced eyestrain and improved visibility)! */
+/* */
+/* */
+/* */
+/* IMPLEMENTATION */
+/* */
+/* Feel free to modify the defined string FROMWHO to reflect you, your */
+/* organization, your site, whatever. */
+/* */
+/* This looks a lot better if you can turn off your cursor before execution. */
+/* The cursor is distracting but it doesn't really ruin the show. */
+/* */
+/* At our site, we invoke this for our users just after login and the */
+/* determination of terminal type. */
+/* */
+/* */
+/* PORTABILITY */
+/* */
+/* I wrote this using only the very simplest curses functions so that it */
+/* might be the most portable. I was personally able to test on five */
+/* different cpu/UNIX combinations. */
+/* */
+/* */
+/* COMPILE */
+/* */
+/* usually this: */
+/* */
+/* cc -O xmas.c -lcurses -o xmas -s */
+/* */
+/******************************************************************************/
+
+/* $Id: xmas.c,v 1.29 2008/07/13 16:08:17 wmcbrine Exp $ */
+
+#include <curses.h>
+#include <signal.h>
+
+void lil(WINDOW *);
+void midtop(WINDOW *);
+void bigtop(WINDOW *);
+void bigface(WINDOW *, chtype);
+void legs1(WINDOW *);
+void legs2(WINDOW *);
+void legs3(WINDOW *);
+void legs4(WINDOW *);
+void initdeer(void);
+void boxit(void);
+void seas(void);
+void greet(void);
+void fromwho(void);
+void del_msg(void);
+void tree(void);
+void balls(void);
+void star(void);
+void strng1(void);
+void strng2(void);
+void strng3(void);
+void strng4(void);
+void strng5(void);
+void blinkit(void);
+void reindeer(void);
+
+#define FROMWHO "From Larry Bartz, Mark Hessling and William McBrine"
+
+int y_pos, x_pos;
+
+WINDOW *treescrn, *treescrn2, *treescrn3, *treescrn4, *treescrn5,
+ *treescrn6, *treescrn7, *treescrn8, *dotdeer0, *stardeer0,
+ *lildeer0, *lildeer1, *lildeer2, *lildeer3, *middeer0,
+ *middeer1, *middeer2, *middeer3, *bigdeer0, *bigdeer1,
+ *bigdeer2, *bigdeer3, *bigdeer4, *lookdeer0, *lookdeer1,
+ *lookdeer2, *lookdeer3, *lookdeer4, *w_holiday, *w_del_msg;
+
+int main(int argc, char **argv)
+{
+ int loopy;
+
+#ifdef XCURSES
+ Xinitscr(argc, argv);
+#else
+ initscr();
+#endif
+ nodelay(stdscr, TRUE);
+ noecho();
+ nonl();
+ refresh();
+
+#ifdef A_COLOR
+ if (has_colors())
+ start_color();
+#endif
+ curs_set(0);
+
+ treescrn = newwin(16, 27, 3, 53);
+ treescrn2 = newwin(16, 27, 3, 53);
+ treescrn3 = newwin(16, 27, 3, 53);
+ treescrn4 = newwin(16, 27, 3, 53);
+ treescrn5 = newwin(16, 27, 3, 53);
+ treescrn6 = newwin(16, 27, 3, 53);
+ treescrn7 = newwin(16, 27, 3, 53);
+ treescrn8 = newwin(16, 27, 3, 53);
+
+ w_holiday = newwin(1, 26, 3, 27);
+
+ w_del_msg = newwin(1, 12, 23, 60);
+
+ mvwaddstr(w_holiday, 0, 0, "H A P P Y H O L I D A Y S");
+
+ initdeer();
+
+ clear();
+ werase(treescrn);
+ touchwin(treescrn);
+ werase(treescrn2);
+ touchwin(treescrn2);
+ werase(treescrn8);
+ touchwin(treescrn8);
+ refresh();
+ napms(1000);
+
+ boxit();
+ del_msg();
+ napms(1000);
+
+ seas();
+ del_msg();
+ napms(1000);
+
+ greet();
+ del_msg();
+ napms(1000);
+
+ fromwho();
+ del_msg();
+ napms(1000);
+
+ tree();
+ napms(1000);
+
+ balls();
+ napms(1000);
+
+ star();
+ napms(1000);
+
+ strng1();
+ strng2();
+ strng3();
+ strng4();
+ strng5();
+
+ /* set up the windows for our blinking trees */
+ /* **************************************** */
+ /* treescrn3 */
+
+ overlay(treescrn, treescrn3);
+
+ /* balls */
+ mvwaddch(treescrn3, 4, 18, ' ');
+ mvwaddch(treescrn3, 7, 6, ' ');
+ mvwaddch(treescrn3, 8, 19, ' ');
+ mvwaddch(treescrn3, 11, 22, ' ');
+
+ /* star */
+ mvwaddch(treescrn3, 0, 12, '*');
+
+ /* strng1 */
+ mvwaddch(treescrn3, 3, 11, ' ');
+
+ /* strng2 */
+ mvwaddch(treescrn3, 5, 13, ' ');
+ mvwaddch(treescrn3, 6, 10, ' ');
+
+ /* strng3 */
+ mvwaddch(treescrn3, 7, 16, ' ');
+ mvwaddch(treescrn3, 7, 14, ' ');
+
+ /* strng4 */
+ mvwaddch(treescrn3, 10, 13, ' ');
+ mvwaddch(treescrn3, 10, 10, ' ');
+ mvwaddch(treescrn3, 11, 8, ' ');
+
+ /* strng5 */
+ mvwaddch(treescrn3, 11, 18, ' ');
+ mvwaddch(treescrn3, 12, 13, ' ');
+
+ /* treescrn4 */
+
+ overlay(treescrn, treescrn4);
+
+ /* balls */
+ mvwaddch(treescrn4, 3, 9, ' ');
+ mvwaddch(treescrn4, 4, 16, ' ');
+ mvwaddch(treescrn4, 7, 6, ' ');
+ mvwaddch(treescrn4, 8, 19, ' ');
+ mvwaddch(treescrn4, 11, 2, ' ');
+ mvwaddch(treescrn4, 12, 23, ' ');
+
+ /* star */
+ mvwaddch(treescrn4, 0, 12, '*' | A_STANDOUT);
+
+ /* strng1 */
+ mvwaddch(treescrn4, 3, 13, ' ');
+
+ /* strng2 */
+
+ /* strng3 */
+ mvwaddch(treescrn4, 7, 15, ' ');
+ mvwaddch(treescrn4, 8, 11, ' ');
+
+ /* strng4 */
+ mvwaddch(treescrn4, 9, 16, ' ');
+ mvwaddch(treescrn4, 10, 12, ' ');
+ mvwaddch(treescrn4, 11, 8, ' ');
+
+ /* strng5 */
+ mvwaddch(treescrn4, 11, 18, ' ');
+ mvwaddch(treescrn4, 12, 14, ' ');
+
+ /* treescrn5 */
+
+ overlay(treescrn, treescrn5);
+
+ /* balls */
+ mvwaddch(treescrn5, 3, 15, ' ');
+ mvwaddch(treescrn5, 10, 20, ' ');
+ mvwaddch(treescrn5, 12, 1, ' ');
+
+ /* star */
+ mvwaddch(treescrn5, 0, 12, '*');
+
+ /* strng1 */
+ mvwaddch(treescrn5, 3, 11, ' ');
+
+ /* strng2 */
+ mvwaddch(treescrn5, 5, 12, ' ');
+
+ /* strng3 */
+ mvwaddch(treescrn5, 7, 14, ' ');
+ mvwaddch(treescrn5, 8, 10, ' ');
+
+ /* strng4 */
+ mvwaddch(treescrn5, 9, 15, ' ');
+ mvwaddch(treescrn5, 10, 11, ' ');
+ mvwaddch(treescrn5, 11, 7, ' ');
+
+ /* strng5 */
+ mvwaddch(treescrn5, 11, 17, ' ');
+ mvwaddch(treescrn5, 12, 13, ' ');
+
+ /* treescrn6 */
+
+ overlay(treescrn, treescrn6);
+
+ /* balls */
+ mvwaddch(treescrn6, 6, 7, ' ');
+ mvwaddch(treescrn6, 7, 18, ' ');
+ mvwaddch(treescrn6, 10, 4, ' ');
+ mvwaddch(treescrn6, 11, 23, ' ');
+
+ /* star */
+ mvwaddch(treescrn6, 0, 12, '*' | A_STANDOUT);
+
+ /* strng1 */
+
+ /* strng2 */
+ mvwaddch(treescrn6, 5, 11, ' ');
+
+ /* strng3 */
+ mvwaddch(treescrn6, 7, 13, ' ');
+ mvwaddch(treescrn6, 8, 9, ' ');
+
+ /* strng4 */
+ mvwaddch(treescrn6, 9, 14, ' ');
+ mvwaddch(treescrn6, 10, 10, ' ');
+ mvwaddch(treescrn6, 11, 6, ' ');
+
+ /* strng5 */
+ mvwaddch(treescrn6, 11, 16, ' ');
+ mvwaddch(treescrn6, 12, 12, ' ');
+
+ /* treescrn7 */
+
+ overlay(treescrn, treescrn7);
+
+ /* balls */
+ mvwaddch(treescrn7, 3, 15, ' ');
+ mvwaddch(treescrn7, 6, 7, ' ');
+ mvwaddch(treescrn7, 7, 18, ' ');
+ mvwaddch(treescrn7, 10, 4, ' ');
+ mvwaddch(treescrn7, 11, 22, ' ');
+
+ /* star */
+ mvwaddch(treescrn7, 0, 12, '*');
+
+ /* strng1 */
+ mvwaddch(treescrn7, 3, 12, ' ');
+
+ /* strng2 */
+ mvwaddch(treescrn7, 5, 13, ' ');
+ mvwaddch(treescrn7, 6, 9, ' ');
+
+ /* strng3 */
+ mvwaddch(treescrn7, 7, 15, ' ');
+ mvwaddch(treescrn7, 8, 11, ' ');
+
+ /* strng4 */
+ mvwaddch(treescrn7, 9, 16, ' ');
+ mvwaddch(treescrn7, 10, 12, ' ');
+ mvwaddch(treescrn7, 11, 8, ' ');
+
+ /* strng5 */
+ mvwaddch(treescrn7, 11, 18, ' ');
+ mvwaddch(treescrn7, 12, 14, ' ');
+
+ napms(1000);
+ reindeer();
+
+ touchwin(w_holiday);
+ wrefresh(w_holiday);
+ wrefresh(w_del_msg);
+
+ napms(1000);
+
+ for (loopy = 0; loopy < 50; loopy++)
+ blinkit();
+
+ clear();
+ refresh();
+ endwin();
+
+ return 0;
+}
+
+void lil(WINDOW *win)
+{
+ mvwaddch(win, 0, 0, (chtype) 'V');
+ mvwaddch(win, 1, 0, (chtype) '@');
+ mvwaddch(win, 1, 3, (chtype) '~');
+}
+
+void midtop(WINDOW *win)
+{
+ mvwaddstr(win, 0, 2, "yy");
+ mvwaddstr(win, 1, 2, "0(=)~");
+}
+
+void bigtop(WINDOW *win)
+{
+ mvwaddstr(win, 0, 17, "\\/");
+ mvwaddstr(win, 0, 20, "\\/");
+ mvwaddch(win, 1, 18, (chtype) '\\');
+ mvwaddch(win, 1, 20, (chtype) '/');
+ mvwaddstr(win, 2, 19, "|_");
+ mvwaddstr(win, 3, 18, "/^0\\");
+ mvwaddstr(win, 4, 17, "//\\");
+ mvwaddch(win, 4, 22, (chtype) '\\');
+ mvwaddstr(win, 5, 7, "^~~~~~~~~// ~~U");
+}
+
+void bigface(WINDOW *win, chtype noseattr)
+{
+ mvwaddstr(win, 0, 16, "\\/ \\/");
+ mvwaddstr(win, 1, 17, "\\Y/ \\Y/");
+ mvwaddstr(win, 2, 19, "\\=/");
+ mvwaddstr(win, 3, 17, "^\\o o/^");
+ mvwaddstr(win, 4, 17, "//( )");
+ mvwaddstr(win, 5, 7, "^~~~~~~~~// \\");
+ waddch(win, 'O' | noseattr);
+ waddstr(win, "/");
+}
+
+void legs1(WINDOW *win)
+{
+ mvwaddstr(win, 6, 7, "( \\_____( /");
+ mvwaddstr(win, 7, 8, "( ) /");
+ mvwaddstr(win, 8, 9, "\\\\ /");
+ mvwaddstr(win, 9, 11, "\\>/>");
+}
+
+void legs2(WINDOW *win)
+{
+ mvwaddstr(win, 6, 7, "(( )____( /");
+ mvwaddstr(win, 7, 7, "( / |");
+ mvwaddstr(win, 8, 8, "\\/ |");
+ mvwaddstr(win, 9, 9, "|> |>");
+}
+
+void legs3(WINDOW *win)
+{
+ mvwaddstr(win, 6, 6, "( ()_____( /");
+ mvwaddstr(win, 7, 6, "/ / /");
+ mvwaddstr(win, 8, 5, "|/ \\");
+ mvwaddstr(win, 9, 5, "/> \\>");
+}
+
+void legs4(WINDOW *win)
+{
+ mvwaddstr(win, 6, 6, "( )______( /");
+ mvwaddstr(win, 7, 5, "(/ \\");
+ mvwaddstr(win, 8, 0, "v___= ----^");
+}
+
+void initdeer(void)
+{
+ chtype noseattr;
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(31, COLOR_RED, COLOR_BLACK);
+ noseattr = COLOR_PAIR(31);
+ }
+ else
+#endif
+ noseattr = A_NORMAL;
+
+ /* set up the windows for our various reindeer */
+
+ dotdeer0 = newwin(3, 71, 0, 8);
+ stardeer0 = newwin(4, 56, 0, 8);
+ lildeer0 = newwin(7, 54, 0, 8);
+ middeer0 = newwin(15, 42, 0, 8);
+ bigdeer0 = newwin(10, 23, 0, 0);
+ lookdeer0 = newwin(10, 25, 0, 0);
+
+ /* lildeer1 */
+ lildeer1 = newwin(2, 4, 0, 0);
+ lil(lildeer1);
+ mvwaddstr(lildeer1, 1, 1, "<>");
+
+ /* lildeer2 */
+ lildeer2 = newwin(2, 4, 0, 0);
+ lil(lildeer2);
+ mvwaddstr(lildeer2, 1, 1, "||");
+
+ /* lildeer3 */
+ lildeer3 = newwin(2, 4, 0, 0);
+ lil(lildeer3);
+ mvwaddstr(lildeer3, 1, 1, "><");
+
+ /* middeer1 */
+ middeer1 = newwin(3, 7, 0, 0);
+ midtop(middeer1);
+ mvwaddstr(middeer1, 2, 3, "\\/");
+
+ /* middeer2 */
+ middeer2 = newwin(3, 7, 0, 0);
+ midtop(middeer2);
+ mvwaddch(middeer2, 2, 3, (chtype) '|');
+ mvwaddch(middeer2, 2, 5, (chtype) '|');
+
+ /* middeer3 */
+ middeer3 = newwin(3, 7, 0, 0);
+ midtop(middeer3);
+ mvwaddch(middeer3, 2, 2, (chtype) '/');
+ mvwaddch(middeer3, 2, 6, (chtype) '\\');
+
+ /* bigdeer1 */
+ bigdeer1 = newwin(10, 23, 0, 0);
+ bigtop(bigdeer1);
+ legs1(bigdeer1);
+
+ /* bigdeer2 */
+ bigdeer2 = newwin(10, 23, 0, 0);
+ bigtop(bigdeer2);
+ legs2(bigdeer2);
+
+ /* bigdeer3 */
+ bigdeer3 = newwin(10, 23, 0, 0);
+ bigtop(bigdeer3);
+ legs3(bigdeer3);
+
+ /* bigdeer4 */
+ bigdeer4 = newwin(10, 23, 0, 0);
+ bigtop(bigdeer4);
+ legs4(bigdeer4);
+
+ /* lookdeer1 */
+ lookdeer1 = newwin(10, 25, 0, 0);
+ bigface(lookdeer1, noseattr);
+ legs1(lookdeer1);
+
+ /* lookdeer2 */
+ lookdeer2 = newwin(10, 25, 0, 0);
+ bigface(lookdeer2, noseattr);
+ legs2(lookdeer2);
+
+ /* lookdeer3 */
+ lookdeer3 = newwin(10, 25, 0, 0);
+ bigface(lookdeer3, noseattr);
+ legs3(lookdeer3);
+
+ /* lookdeer4 */
+ lookdeer4 = newwin(10, 25, 0, 0);
+ bigface(lookdeer4, noseattr);
+ legs4(lookdeer4);
+}
+
+void boxit(void)
+{
+ int x;
+
+ for (x = 0; x < 20; ++x)
+ mvaddch(x, 7, '|');
+
+ for (x = 0; x < 80; ++x)
+ {
+ if (x > 7)
+ mvaddch(19, x, '_');
+
+ mvaddch(22, x, '_');
+ }
+}
+
+void seas(void)
+{
+ mvaddch(4, 1, 'S');
+ mvaddch(6, 1, 'E');
+ mvaddch(8, 1, 'A');
+ mvaddch(10, 1, 'S');
+ mvaddch(12, 1, 'O');
+ mvaddch(14, 1, 'N');
+ mvaddch(16, 1, '`');
+ mvaddch(18, 1, 'S');
+}
+
+void greet(void)
+{
+ mvaddch(3, 5, 'G');
+ mvaddch(5, 5, 'R');
+ mvaddch(7, 5, 'E');
+ mvaddch(9, 5, 'E');
+ mvaddch(11, 5, 'T');
+ mvaddch(13, 5, 'I');
+ mvaddch(15, 5, 'N');
+ mvaddch(17, 5, 'G');
+ mvaddch(19, 5, 'S');
+}
+
+void fromwho(void)
+{
+ mvaddstr(21, 13, FROMWHO);
+}
+
+void del_msg(void)
+{
+ refresh();
+}
+
+void tree(void)
+{
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(30, COLOR_GREEN, COLOR_BLACK);
+ wattrset(treescrn, COLOR_PAIR(30));
+ }
+#endif
+ mvwaddch(treescrn, 1, 11, (chtype) '/');
+ mvwaddch(treescrn, 2, 11, (chtype) '/');
+ mvwaddch(treescrn, 3, 10, (chtype) '/');
+ mvwaddch(treescrn, 4, 9, (chtype) '/');
+ mvwaddch(treescrn, 5, 9, (chtype) '/');
+ mvwaddch(treescrn, 6, 8, (chtype) '/');
+ mvwaddch(treescrn, 7, 7, (chtype) '/');
+ mvwaddch(treescrn, 8, 6, (chtype) '/');
+ mvwaddch(treescrn, 9, 6, (chtype) '/');
+ mvwaddch(treescrn, 10, 5, (chtype) '/');
+ mvwaddch(treescrn, 11, 3, (chtype) '/');
+ mvwaddch(treescrn, 12, 2, (chtype) '/');
+
+ mvwaddch(treescrn, 1, 13, (chtype) '\\');
+ mvwaddch(treescrn, 2, 13, (chtype) '\\');
+ mvwaddch(treescrn, 3, 14, (chtype) '\\');
+ mvwaddch(treescrn, 4, 15, (chtype) '\\');
+ mvwaddch(treescrn, 5, 15, (chtype) '\\');
+ mvwaddch(treescrn, 6, 16, (chtype) '\\');
+ mvwaddch(treescrn, 7, 17, (chtype) '\\');
+ mvwaddch(treescrn, 8, 18, (chtype) '\\');
+ mvwaddch(treescrn, 9, 18, (chtype) '\\');
+ mvwaddch(treescrn, 10, 19, (chtype) '\\');
+ mvwaddch(treescrn, 11, 21, (chtype) '\\');
+ mvwaddch(treescrn, 12, 22, (chtype) '\\');
+
+ mvwaddch(treescrn, 4, 10, (chtype) '_');
+ mvwaddch(treescrn, 4, 14, (chtype) '_');
+ mvwaddch(treescrn, 8, 7, (chtype) '_');
+ mvwaddch(treescrn, 8, 17, (chtype) '_');
+
+ mvwaddstr(treescrn, 13, 0,
+ "//////////// \\\\\\\\\\\\\\\\\\\\\\\\");
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(20, COLOR_YELLOW, COLOR_BLACK);
+ wattrset(treescrn, COLOR_PAIR(20));
+ }
+#endif
+ mvwaddstr(treescrn, 14, 11, "| |");
+ mvwaddstr(treescrn, 15, 11, "|_|");
+
+ wrefresh(treescrn);
+ wrefresh(w_del_msg);
+}
+
+void balls(void)
+{
+ chtype ball1, ball2, ball3, ball4, ball5, ball6;
+
+ overlay(treescrn, treescrn2);
+
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(1, COLOR_BLUE, COLOR_BLACK);
+ init_pair(2, COLOR_RED, COLOR_BLACK);
+ init_pair(3, COLOR_MAGENTA, COLOR_BLACK);
+ init_pair(4, COLOR_CYAN, COLOR_BLACK);
+ init_pair(5, COLOR_YELLOW, COLOR_BLACK);
+ init_pair(6, COLOR_WHITE, COLOR_BLACK);
+ ball1 = COLOR_PAIR(1) | '@';
+ ball2 = COLOR_PAIR(2) | '@';
+ ball3 = COLOR_PAIR(3) | '@';
+ ball4 = COLOR_PAIR(4) | '@';
+ ball5 = COLOR_PAIR(5) | '@';
+ ball6 = COLOR_PAIR(6) | '@';
+ }
+ else
+#endif
+ ball1 = ball2 = ball3 = ball4 = ball5 = ball6 = '@';
+
+ mvwaddch(treescrn2, 3, 9, ball1);
+ mvwaddch(treescrn2, 3, 15, ball2);
+ mvwaddch(treescrn2, 4, 8, ball3);
+ mvwaddch(treescrn2, 4, 16, ball4);
+ mvwaddch(treescrn2, 5, 7, ball5);
+ mvwaddch(treescrn2, 5, 17, ball6);
+ mvwaddch(treescrn2, 7, 6, ball1 | A_BOLD);
+ mvwaddch(treescrn2, 7, 18, ball2 | A_BOLD);
+ mvwaddch(treescrn2, 8, 5, ball3 | A_BOLD);
+ mvwaddch(treescrn2, 8, 19, ball4 | A_BOLD);
+ mvwaddch(treescrn2, 10, 4, ball5 | A_BOLD);
+ mvwaddch(treescrn2, 10, 20, ball6 | A_BOLD);
+ mvwaddch(treescrn2, 11, 2, ball1);
+ mvwaddch(treescrn2, 11, 22, ball2);
+ mvwaddch(treescrn2, 12, 1, ball3);
+ mvwaddch(treescrn2, 12, 23, ball4);
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+}
+
+void star(void)
+{
+ mvwaddch(treescrn2, 0, 12, (chtype) '*' | A_STANDOUT);
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+}
+
+void strng1(void)
+{
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(10, COLOR_YELLOW, COLOR_BLACK);
+ wattrset(treescrn2, COLOR_PAIR(10) | A_BOLD);
+ }
+#endif
+ mvwaddstr(treescrn2, 3, 11, ".:'");
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+}
+
+void strng2(void)
+{
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(11, COLOR_RED, COLOR_BLACK);
+ wattrset(treescrn2, COLOR_PAIR(11) | A_BOLD);
+ }
+#endif
+ mvwaddstr(treescrn2, 5, 11, ",.:'");
+ mvwaddstr(treescrn2, 6, 9, ":'");
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+}
+
+void strng3(void)
+{
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(12, COLOR_GREEN, COLOR_BLACK);
+ wattrset(treescrn2, COLOR_PAIR(12) | A_BOLD);
+ }
+#endif
+ mvwaddstr(treescrn2, 7, 13, ",.:'");
+ mvwaddstr(treescrn2, 8, 9, ",.:'");
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+}
+
+void strng4(void)
+{
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(13, COLOR_WHITE, COLOR_BLACK);
+ wattrset(treescrn2, COLOR_PAIR(13) | A_BOLD);
+ }
+#endif
+ mvwaddstr(treescrn2, 9, 14, ",.:'");
+ mvwaddstr(treescrn2, 10, 10, ",.:'");
+ mvwaddstr(treescrn2, 11, 6, ",.:'");
+ mvwaddch(treescrn2, 12, 5, (chtype) '\'');
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+}
+
+void strng5(void)
+{
+#ifdef A_COLOR
+ if (has_colors())
+ {
+ init_pair(14, COLOR_CYAN, COLOR_BLACK);
+ wattrset(treescrn2, COLOR_PAIR(14) | A_BOLD);
+ }
+#endif
+ mvwaddstr(treescrn2, 11, 16, ",.:'");
+ mvwaddstr(treescrn2, 12, 12, ",.:'");
+
+ /* save a fully lit tree */
+ overlay(treescrn2, treescrn);
+
+ wrefresh(treescrn2);
+ wrefresh(w_del_msg);
+}
+
+void blinkit(void)
+{
+ static int cycle;
+
+ if (cycle > 4)
+ cycle = 0;
+
+ touchwin(treescrn8);
+
+ switch (cycle)
+ {
+ case 0:
+ overlay(treescrn3, treescrn8);
+ break;
+
+ case 1:
+ overlay(treescrn4, treescrn8);
+ break;
+
+ case 2:
+ overlay(treescrn5, treescrn8);
+ break;
+
+ case 3:
+ overlay(treescrn6, treescrn8);
+ break;
+
+ case 4:
+ overlay(treescrn7, treescrn8);
+ }
+
+ wrefresh(treescrn8);
+ wrefresh(w_del_msg);
+
+ napms(50);
+ touchwin(treescrn8);
+
+ /*ALL ON************************************************** */
+
+ overlay(treescrn, treescrn8);
+ wrefresh(treescrn8);
+ wrefresh(w_del_msg);
+
+ ++cycle;
+}
+
+#define TSHOW(win, pause) touchwin(win); wrefresh(win); \
+ wrefresh(w_del_msg); napms(pause)
+
+#define SHOW(win, pause) mvwin(win, y_pos, x_pos); wrefresh(win); \
+ wrefresh(w_del_msg); napms(pause)
+
+void reindeer(void)
+{
+ int looper;
+
+ y_pos = 0;
+
+ for (x_pos = 70; x_pos > 62; x_pos--)
+ {
+ if (x_pos < 62)
+ y_pos = 1;
+
+ for (looper = 0; looper < 4; looper++)
+ {
+ mvwaddch(dotdeer0, y_pos, x_pos, (chtype) '.');
+ wrefresh(dotdeer0);
+ wrefresh(w_del_msg);
+ werase(dotdeer0);
+ wrefresh(dotdeer0);
+ wrefresh(w_del_msg);
+ }
+ }
+
+ y_pos = 2;
+
+ for (; x_pos > 50; x_pos--)
+ {
+ for (looper = 0; looper < 4; looper++)
+ {
+ if (x_pos < 56)
+ {
+ y_pos = 3;
+
+ mvwaddch(stardeer0, y_pos, x_pos, (chtype) '*');
+ wrefresh(stardeer0);
+ wrefresh(w_del_msg);
+ werase(stardeer0);
+ wrefresh(stardeer0);
+ }
+ else
+ {
+ mvwaddch(dotdeer0, y_pos, x_pos, (chtype) '*');
+ wrefresh(dotdeer0);
+ wrefresh(w_del_msg);
+ werase(dotdeer0);
+ wrefresh(dotdeer0);
+ }
+ wrefresh(w_del_msg);
+ }
+ }
+
+ x_pos = 58;
+
+ for (y_pos = 2; y_pos < 5; y_pos++)
+ {
+ TSHOW(lildeer0, 50);
+
+ for (looper = 0; looper < 4; looper++)
+ {
+ SHOW(lildeer3, 50);
+ SHOW(lildeer2, 50);
+ SHOW(lildeer1, 50);
+ SHOW(lildeer2, 50);
+ SHOW(lildeer3, 50);
+
+ TSHOW(lildeer0, 50);
+
+ x_pos -= 2;
+ }
+ }
+
+ x_pos = 35;
+
+ for (y_pos = 5; y_pos < 10; y_pos++)
+ {
+ touchwin(middeer0);
+ wrefresh(middeer0);
+ wrefresh(w_del_msg);
+
+ for (looper = 0; looper < 2; looper++)
+ {
+ SHOW(middeer3, 50);
+ SHOW(middeer2, 50);
+ SHOW(middeer1, 50);
+ SHOW(middeer2, 50);
+ SHOW(middeer3, 50);
+
+ TSHOW(middeer0, 50);
+
+ x_pos -= 3;
+ }
+ }
+
+ napms(2000);
+
+ y_pos = 1;
+
+ for (x_pos = 8; x_pos < 16; x_pos++)
+ {
+ SHOW(bigdeer4, 30);
+ SHOW(bigdeer3, 30);
+ SHOW(bigdeer2, 30);
+ SHOW(bigdeer1, 30);
+ SHOW(bigdeer2, 30);
+ SHOW(bigdeer3, 30);
+ SHOW(bigdeer4, 30);
+ SHOW(bigdeer0, 30);
+ }
+
+ --x_pos;
+
+ for (looper = 0; looper < 6; looper++)
+ {
+ SHOW(lookdeer4, 40);
+ SHOW(lookdeer3, 40);
+ SHOW(lookdeer2, 40);
+ SHOW(lookdeer1, 40);
+ SHOW(lookdeer2, 40);
+ SHOW(lookdeer3, 40);
+ SHOW(lookdeer4, 40);
+ }
+
+ SHOW(lookdeer0, 40);
+
+ for (; y_pos < 10; y_pos++)
+ {
+ for (looper = 0; looper < 2; looper++)
+ {
+ SHOW(bigdeer4, 30);
+ SHOW(bigdeer3, 30);
+ SHOW(bigdeer2, 30);
+ SHOW(bigdeer1, 30);
+ SHOW(bigdeer2, 30);
+ SHOW(bigdeer3, 30);
+ SHOW(bigdeer4, 30);
+ }
+
+ SHOW(bigdeer0, 30);
+ }
+
+ --y_pos;
+
+ mvwin(lookdeer3, y_pos, x_pos);
+ wrefresh(lookdeer3);
+ wrefresh(w_del_msg);
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/doc/Makefile b/payloads/libpayload/curses/PDCurses-3.4/doc/Makefile
new file mode 100644
index 0000000000..8b5f337757
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/doc/Makefile
@@ -0,0 +1,37 @@
+# Makefile for PDCurses manext program.
+
+all: manual
+
+manual: PDCurses.txt
+
+PDCurses.txt: manext
+ cat intro.txt > PDCurses.txt
+ echo PDCurses Definitions and Variables >> PDCurses.txt
+ echo ================================== >> PDCurses.txt
+ ./manext ../curses.h >> PDCurses.txt
+ echo PDCurses Functions >> PDCurses.txt
+ echo ================== >> PDCurses.txt
+ ./manext ../pdcurses/*.c >> PDCurses.txt
+ ./manext ../x11/*.c >> PDCurses.txt
+ cat x11.txt >> PDCurses.txt
+ echo >> PDCurses.txt
+ echo >> PDCurses.txt
+ echo \
+-------------------------------------------------------------------------- \
+>> PDCurses.txt
+ echo >> PDCurses.txt
+ cat sdl.txt >> PDCurses.txt
+
+manext: manext.c
+
+install:
+ echo Does nothing at the moment
+
+clean:
+ -rm -rf *.o manext PDCurses.txt
+
+distclean: clean
+
+mostlyclean: clean
+
+realclean: distclean
diff --git a/payloads/libpayload/curses/PDCurses-3.4/doc/intro.txt b/payloads/libpayload/curses/PDCurses-3.4/doc/intro.txt
new file mode 100644
index 0000000000..a13cb7af2f
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/doc/intro.txt
@@ -0,0 +1,834 @@
+PDCurses User's Guide
+=====================
+
+Curses Overview
+---------------
+
+The X/Open Curses Interface Definition describes a set of C-Language
+functions that provide screen-handling and updating, which are
+collectively known as the curses library.
+
+The curses library permits manipulation of data structures called
+windows which may be thought of as two-dimensional arrays of
+characters representing all or part of a terminal's screen. The
+windows are manipulated using a procedural interface described
+elsewhere. The curses package maintains a record of what characters
+are on the screen. At the most basic level, manipulation is done with
+the routines move() and addch() which are used to "move" the curses
+around and add characters to the default window, stdscr, which
+represents the whole screen.
+
+An application may use these routines to add data to the window in any
+convenient order. Once all data have been added, the routine
+refresh() is called. The package then determines what changes have
+been made which affect the screen. The screen contents are then
+changed to reflect those characters now in the window, using a
+sequence of operations optimized for the type of terminal in use.
+
+At a higher level routines combining the actions of move() and addch()
+are defined, as are routines to add whole strings and to perform
+format conversions in the manner of printf().
+
+Interfaces are also defined to erase the entire window and to specify
+the attributes of individual characters in the window. Attributes
+such as inverse video, underline and blink can be used on a
+per-character basis.
+
+New windows can be created by allowing the application to build
+several images of the screen and display the appropriate one very
+quickly. New windows are created using the routine newwin(). For
+each routine that manipulates the default window, stdscr, there is a
+corresponding routine prefixed with w to manipulate the contents of a
+specified window; for example, move() and wmove(). In fact, move(...)
+is functionally equivalent to wmove( stdscr, ...). This is similar to
+the interface offered by printf(...) and fprintf(stdout, ...).
+
+Windows do not have to correspond to the entire screen. It is
+possible to create smaller windows, and also to indicate that the
+window is only partially visible on the screen. Furthermore, large
+windows or pads, which are bigger than the actual screen size, may be
+created.
+
+Interfaces are also defined to allow input character manipulation and
+to disable and enable many input attributes: character echo, single
+character input with or without signal processing (cbreak or raw
+modes), carriage returns mapping to newlines, screen scrolling, etc.
+
+
+Data Types and the <curses.h> Header
+------------------------------------
+
+The data types supported by curses are described in this section.
+
+As the library supports a procedural interface to the data types, actual
+structure contents are not described. All curses data are manipulated
+using the routines provided.
+
+
+THE <curses.h> HEADER
+
+The <curses.h> header defines various constants and declares the data
+types that are available to the application.
+
+
+DATA TYPES
+
+The following data types are declared:
+
+ WINDOW * pointer to screen representation
+ SCREEN * pointer to terminal descriptor
+ bool boolean data type
+ chtype representation of a character in a window
+ cchar_t the wide-character equivalent of chtype
+ attr_t for WA_-style attributes
+
+The actual WINDOW and SCREEN objects used to store information are
+created by the corresponding routines and a pointer to them is provided.
+All manipulation is through that pointer.
+
+
+VARIABLES
+
+The following variables are defined:
+
+ LINES number of lines on terminal screen
+ COLS number of columns on terminal screen
+ stdscr pointer to the default screen window
+ curscr pointer to the current screen image
+ SP pointer to the current SCREEN struct
+ Mouse_status status of the mouse
+ COLORS number of colors available
+ COLOR_PAIRS number of color pairs available
+ TABSIZE size of one TAB block
+ acs_map[] alternate character set map
+ ttytype[] terminal name/description
+
+
+CONSTANTS
+
+The following constants are defined:
+
+GENERAL
+
+ FALSE boolean false value
+ TRUE boolean true value
+ NULL zero pointer value
+ ERR value returned on error condition
+ OK value returned on successful completion
+
+VIDEO ATTRIBUTES
+
+Normally, attributes are a property of the character.
+
+For chtype:
+
+ A_ALTCHARSET use the alternate character set
+ A_BLINK bright background or blinking
+ A_BOLD bright foreground or bold
+ A_DIM half bright -- no effect in PDCurses
+ A_INVIS invisible
+ A_ITALIC italic
+ A_LEFTLINE line along the left edge
+ A_PROTECT protected (?) -- PDCurses renders this as a
+ combination of the *LINE attributes
+ A_REVERSE reverse video
+ A_RIGHTLINE line along the right edge
+ A_STANDOUT terminal's best highlighting mode
+ A_UNDERLINE underline
+
+ A_ATTRIBUTES bit-mask to extract attributes
+ A_CHARTEXT bit-mask to extract a character
+ A_COLOR bit-mask to extract a color-pair
+
+Not all attributes will work on all terminals. A_RIGHTLINE, A_LEFTLINE
+and A_ITALIC are specific to PDCurses. A_INVIS and A_ITALIC are given
+the same value in PDCurses.
+
+For attr_t:
+
+ WA_ALTCHARSET same as A_ALTCHARSET
+ WA_BLINK same as A_BLINK
+ WA_BOLD same as A_BOLD
+ WA_DIM same as A_DIM
+ WA_INVIS same as A_INVIS
+ WA_LEFT same as A_LEFTLINE
+ WA_PROTECT same as A_PROTECT
+ WA_REVERSE same as A_REVERSE
+ WA_RIGHT same as A_RIGHTLINE
+ WA_STANDOUT same as A_STANDOUT
+ WA_UNDERLINE same as A_UNDERLINE
+
+Note that while A_LEFTLINE and A_RIGHTLINE are PDCurses-specific,
+WA_LEFT and WA_RIGHT are standard. The following are also defined, for
+compatibility, but currently have no effect in PDCurses: WA_HORIZONTAL,
+WA_LOW, WA_TOP, WA_VERTICAL.
+
+THE ALTERNATE CHARACTER SET
+
+For use in chtypes and with related functions. These are a portable way
+to represent graphics characters on different terminals.
+
+VT100-compatible symbols -- box characters:
+
+ ACS_ULCORNER upper left box corner
+ ACS_LLCORNER lower left box corner
+ ACS_URCORNER upper right box corner
+ ACS_LRCORNER lower right box corner
+ ACS_RTEE right "T"
+ ACS_LTEE left "T"
+ ACS_BTEE bottom "T"
+ ACS_TTEE top "T"
+ ACS_HLINE horizontal line
+ ACS_VLINE vertical line
+ ACS_PLUS plus sign, cross, or four-corner piece
+
+VT100-compatible symbols -- other:
+
+ ACS_S1 scan line 1
+ ACS_S9 scan line 9
+ ACS_DIAMOND diamond
+ ACS_CKBOARD checkerboard -- 50% grey
+ ACS_DEGREE degree symbol
+ ACS_PLMINUS plus/minus sign
+ ACS_BULLET bullet
+
+Teletype 5410v1 symbols -- these are defined in SysV curses, but
+are not well-supported by most terminals. Stick to VT100 characters
+for optimum portability:
+
+ ACS_LARROW left arrow
+ ACS_RARROW right arrow
+ ACS_DARROW down arrow
+ ACS_UARROW up arrow
+ ACS_BOARD checkerboard -- lighter (less dense) than
+ ACS_CKBOARD
+ ACS_LANTERN lantern symbol
+ ACS_BLOCK solid block
+
+That goes double for these -- undocumented SysV symbols. Don't use
+them:
+
+ ACS_S3 scan line 3
+ ACS_S7 scan line 7
+ ACS_LEQUAL less than or equal
+ ACS_GEQUAL greater than or equal
+ ACS_PI pi
+ ACS_NEQUAL not equal
+ ACS_STERLING pounds sterling symbol
+
+Box character aliases:
+
+ ACS_BSSB same as ACS_ULCORNER
+ ACS_SSBB same as ACS_LLCORNER
+ ACS_BBSS same as ACS_URCORNER
+ ACS_SBBS same as ACS_LRCORNER
+ ACS_SBSS same as ACS_RTEE
+ ACS_SSSB same as ACS_LTEE
+ ACS_SSBS same as ACS_BTEE
+ ACS_BSSS same as ACS_TTEE
+ ACS_BSBS same as ACS_HLINE
+ ACS_SBSB same as ACS_VLINE
+ ACS_SSSS same as ACS_PLUS
+
+For cchar_t and wide-character functions, WACS_ equivalents are also
+defined.
+
+COLORS
+
+For use with init_pair(), color_set(), etc.:
+
+ COLOR_BLACK
+ COLOR_BLUE
+ COLOR_GREEN
+ COLOR_CYAN
+ COLOR_RED
+ COLOR_MAGENTA
+ COLOR_YELLOW
+ COLOR_WHITE
+
+Use these instead of numeric values. The definition of the colors
+depends on the implementation of curses.
+
+
+INPUT VALUES
+
+The following constants might be returned by getch() if keypad() has
+been enabled. Note that not all of these may be supported on a
+particular terminal:
+
+ KEY_BREAK break key
+ KEY_DOWN the four arrow keys
+ KEY_UP
+ KEY_LEFT
+ KEY_RIGHT
+ KEY_HOME home key (upward+left arrow)
+ KEY_BACKSPACE backspace
+ KEY_F0 function keys; space for 64 keys is reserved
+ KEY_F(n) (KEY_F0+(n))
+ KEY_DL delete line
+ KEY_IL insert line
+ KEY_DC delete character
+ KEY_IC insert character
+ KEY_EIC exit insert character mode
+ KEY_CLEAR clear screen
+ KEY_EOS clear to end of screen
+ KEY_EOL clear to end of line
+ KEY_SF scroll 1 line forwards
+ KEY_SR scroll 1 line backwards (reverse)
+ KEY_NPAGE next page
+ KEY_PPAGE previous page
+ KEY_STAB set tab
+ KEY_CTAB clear tab
+ KEY_CATAB clear all tabs
+ KEY_ENTER enter or send
+ KEY_SRESET soft (partial) reset
+ KEY_RESET reset or hard reset
+ KEY_PRINT print or copy
+ KEY_LL home down or bottom (lower left)
+ KEY_A1 upper left of virtual keypad
+ KEY_A3 upper right of virtual keypad
+ KEY_B2 center of virtual keypad
+ KEY_C1 lower left of virtual keypad
+ KEY_C3 lower right of virtual keypad
+
+ KEY_BTAB Back tab key
+ KEY_BEG Beginning key
+ KEY_CANCEL Cancel key
+ KEY_CLOSE Close key
+ KEY_COMMAND Cmd (command) key
+ KEY_COPY Copy key
+ KEY_CREATE Create key
+ KEY_END End key
+ KEY_EXIT Exit key
+ KEY_FIND Find key
+ KEY_HELP Help key
+ KEY_MARK Mark key
+ KEY_MESSAGE Message key
+ KEY_MOVE Move key
+ KEY_NEXT Next object key
+ KEY_OPEN Open key
+ KEY_OPTIONS Options key
+ KEY_PREVIOUS Previous object key
+ KEY_REDO Redo key
+ KEY_REFERENCE Reference key
+ KEY_REFRESH Refresh key
+ KEY_REPLACE Replace key
+ KEY_RESTART Restart key
+ KEY_RESUME Resume key
+ KEY_SAVE Save key
+ KEY_SBEG Shifted beginning key
+ KEY_SCANCEL Shifted cancel key
+ KEY_SCOMMAND Shifted command key
+ KEY_SCOPY Shifted copy key
+ KEY_SCREATE Shifted create key
+ KEY_SDC Shifted delete char key
+ KEY_SDL Shifted delete line key
+ KEY_SELECT Select key
+ KEY_SEND Shifted end key
+ KEY_SEOL Shifted clear line key
+ KEY_SEXIT Shifted exit key
+ KEY_SFIND Shifted find key
+ KEY_SHELP Shifted help key
+ KEY_SHOME Shifted home key
+ KEY_SIC Shifted input key
+ KEY_SLEFT Shifted left arrow key
+ KEY_SMESSAGE Shifted message key
+ KEY_SMOVE Shifted move key
+ KEY_SNEXT Shifted next key
+ KEY_SOPTIONS Shifted options key
+ KEY_SPREVIOUS Shifted prev key
+ KEY_SPRINT Shifted print key
+ KEY_SREDO Shifted redo key
+ KEY_SREPLACE Shifted replace key
+ KEY_SRIGHT Shifted right arrow
+ KEY_SRSUME Shifted resume key
+ KEY_SSAVE Shifted save key
+ KEY_SSUSPEND Shifted suspend key
+ KEY_SUNDO Shifted undo key
+ KEY_SUSPEND Suspend key
+ KEY_UNDO Undo key
+
+The virtual keypad is arranged like this:
+
+ A1 up A3
+ left B2 right
+ C1 down C3
+
+This list is incomplete -- see curses.h for the full list, and use the
+testcurs demo to see what values are actually returned. The above are
+just the keys required by X/Open. In particular, PDCurses defines many
+CTL_ and ALT_ combinations; these are not portable.
+
+
+FUNCTIONS
+
+The following table lists each curses routine and the name of the manual
+page on which it is described.
+
+Functions from the X/Open curses standard -- complete, except for
+getch() and ungetch(), which are implemented as macros for DOS
+compatibility:
+
+ Curses Function Manual Page Name
+
+ addch addch
+ addchnstr addchstr
+ addchstr addchstr
+ addnstr addstr
+ addstr addstr
+ attroff attr
+ attron attr
+ attrset attr
+ attr_get attr
+ attr_off attr
+ attr_on attr
+ attr_set attr
+ baudrate termattr
+ beep beep
+ bkgd bkgd
+ bkgdset bkgd
+ border border
+ box border
+ can_change_color color
+ cbreak inopts
+ chgat attr
+ clearok outopts
+ clear clear
+ clrtobot clear
+ clrtoeol clear
+ color_content color
+ color_set attr
+ copywin overlay
+ curs_set kernel
+ def_prog_mode kernel
+ def_shell_mode kernel
+ del_curterm terminfo
+ delay_output util
+ delch delch
+ deleteln deleteln
+ delscreen initscr
+ delwin window
+ derwin window
+ doupdate refresh
+ dupwin window
+ echochar addch
+ echo inopts
+ endwin initscr
+ erasechar termattr
+ erase clear
+ filter util
+ flash beep
+ flushinp getch
+ getbkgd bkgd
+ getnstr getstr
+ getstr getstr
+ getwin scr_dump
+ halfdelay inopts
+ has_colors color
+ has_ic termattr
+ has_il termattr
+ hline border
+ idcok outopts
+ idlok outopts
+ immedok outopts
+ inchnstr inchstr
+ inchstr inchstr
+ inch inch
+ init_color color
+ init_pair color
+ initscr initscr
+ innstr instr
+ insch insch
+ insdelln deleteln
+ insertln deleteln
+ insnstr innstr
+ insstr innstr
+ instr instr
+ intrflush inopts
+ isendwin initscr
+ is_linetouched touch
+ is_wintouched touch
+ keyname keyname
+ keypad inopts
+ killchar termattr
+ leaveok outopts
+ longname termattr
+ meta inopts
+ move move
+ mvaddch addch
+ mvaddchnstr addchstr
+ mvaddchstr addchstr
+ mvaddnstr addstr
+ mvaddstr addstr
+ mvchgat attr
+ mvcur terminfo
+ mvdelch delch
+ mvderwin window
+ mvgetch getch
+ mvgetnstr getstr
+ mvgetstr getstr
+ mvhline border
+ mvinch inch
+ mvinchnstr inchstr
+ mvinchstr inchstr
+ mvinnstr instr
+ mvinsch insch
+ mvinsnstr insstr
+ mvinsstr insstr
+ mvinstr instr
+ mvprintw printw
+ mvscanw scanw
+ mvvline border
+ mvwaddchnstr addchstr
+ mvwaddchstr addchstr
+ mvwaddch addch
+ mvwaddnstr addstr
+ mvwaddstr addstr
+ mvwchgat attr
+ mvwdelch delch
+ mvwgetch getch
+ mvwgetnstr getstr
+ mvwgetstr getstr
+ mvwhline border
+ mvwinchnstr inchstr
+ mvwinchstr inchstr
+ mvwinch inch
+ mvwinnstr instr
+ mvwinsch insch
+ mvwinsnstr insstr
+ mvwinsstr insstr
+ mvwinstr instr
+ mvwin window
+ mvwprintw printw
+ mvwscanw scanw
+ mvwvline border
+ napms kernel
+ newpad pad
+ newterm initscr
+ newwin window
+ nl inopts
+ nocbreak inopts
+ nodelay inopts
+ noecho inopts
+ nonl inopts
+ noqiflush inopts
+ noraw inopts
+ notimeout inopts
+ overlay overlay
+ overwrite overlay
+ pair_content color
+ pechochar pad
+ pnoutrefresh pad
+ prefresh pad
+ printw printw
+ putp terminfo
+ putwin scr_dump
+ qiflush inopts
+ raw inopts
+ redrawwin refresh
+ refresh refresh
+ reset_prog_mode kernel
+ reset_shell_mode kernel
+ resetty kernel
+ restartterm terminfo
+ ripoffline kernel
+ savetty kernel
+ scanw scanw
+ scr_dump scr_dump
+ scr_init scr_dump
+ scr_restore scr_dump
+ scr_set scr_dump
+ scrl scroll
+ scroll scroll
+ scrollok outopts
+ set_term initscr
+ setscrreg outopts
+ setterm terminfo
+ setupterm terminfo
+ slk_attroff slk
+ slk_attr_off slk
+ slk_attron slk
+ slk_attr_on slk
+ slk_attrset slk
+ slk_attr_set slk
+ slk_clear slk
+ slk_color slk
+ slk_init slk
+ slk_label slk
+ slk_noutrefresh slk
+ slk_refresh slk
+ slk_restore slk
+ slk_set slk
+ slk_touch slk
+ standend attr
+ standout attr
+ start_color color
+ subpad pad
+ subwin window
+ syncok window
+ termattrs termattrs
+ term_attrs termattrs
+ termname termattrs
+ tgetent termcap
+ tgetflag termcap
+ tgetnum termcap
+ tgetstr termcap
+ tgoto termcap
+ tigetflag terminfo
+ tigetnum terminfo
+ tigetstr terminfo
+ timeout inopts
+ touchline touch
+ touchwin touch
+ tparm terminfo
+ tputs terminfo
+ typeahead inopts
+ untouchwin touch
+ use_env util
+ vidattr terminfo
+ vid_attr terminfo
+ vidputs terminfo
+ vid_puts terminfo
+ vline border
+ vw_printw printw
+ vwprintw printw
+ vw_scanw scanw
+ vwscanw scanw
+ waddchnstr addchstr
+ waddchstr addchstr
+ waddch addch
+ waddnstr addstr
+ waddstr addstr
+ wattroff attr
+ wattron attr
+ wattrset attr
+ wattr_get attr
+ wattr_off attr
+ wattr_on attr
+ wattr_set attr
+ wbkgdset bkgd
+ wbkgd bkgd
+ wborder border
+ wchgat attr
+ wclear clear
+ wclrtobot clear
+ wclrtoeol clear
+ wcolor_set attr
+ wcursyncup window
+ wdelch delch
+ wdeleteln deleteln
+ wechochar addch
+ werase clear
+ wgetch getch
+ wgetnstr getstr
+ wgetstr getstr
+ whline border
+ winchnstr inchstr
+ winchstr inchstr
+ winch inch
+ winnstr instr
+ winsch insch
+ winsdelln deleteln
+ winsertln deleteln
+ winsnstr insstr
+ winsstr insstr
+ winstr instr
+ wmove move
+ wnoutrefresh refresh
+ wprintw printw
+ wredrawln refresh
+ wrefresh refresh
+ wscanw scanw
+ wscrl scroll
+ wsetscrreg outopts
+ wstandend attr
+ wstandout attr
+ wsyncdown window
+ wsyncup window
+ wtimeout inopts
+ wtouchln touch
+ wvline border
+
+Wide-character functions from the X/Open standard -- these are only
+available when PDCurses is built with PDC_WIDE defined, and the
+prototypes are only available from curses.h when PDC_WIDE is defined
+before its inclusion in your app:
+
+ addnwstr addstr
+ addwstr addstr
+ add_wch addch
+ add_wchnstr addchstr
+ add_wchstr addchstr
+ border_set border
+ box_set border
+ echo_wchar addch
+ erasewchar termattr
+ getbkgrnd bkgd
+ getcchar util
+ getn_wstr getstr
+ get_wch getch
+ get_wstr getstr
+ hline_set border
+ innwstr instr
+ ins_nwstr insstr
+ ins_wch insch
+ ins_wstr insstr
+ inwstr instr
+ in_wch inch
+ in_wchnstr inchstr
+ in_wchstr inchstr
+ key_name keyname
+ killwchar termattr
+ mvaddnwstr addstr
+ mvaddwstr addstr
+ mvadd_wch addch
+ mvadd_wchnstr addchstr
+ mvadd_wchstr addchstr
+ mvgetn_wstr getstr
+ mvget_wch getch
+ mvget_wstr getstr
+ mvhline_set border
+ mvinnwstr instr
+ mvins_nwstr insstr
+ mvins_wch insch
+ mvins_wstr insstr
+ mvinwstr instr
+ mvwaddnwstr addstr
+ mvwaddwstr addstr
+ mvwadd_wch addch
+ mvwadd_wchnstr addchstr
+ mvwadd_wchstr addchstr
+ mvwgetn_wstr getstr
+ mvwget_wch getch
+ mvwget_wstr getstr
+ mvwhline_set border
+ mvwinnwstr instr
+ mvwins_nwstr insstr
+ mvwins_wch insch
+ mvwins_wstr insstr
+ mvwin_wch inch
+ mvwin_wchnstr inchstr
+ mvwin_wchstr inchstr
+ mvwinwstr instr
+ mvwvline_set border
+ pecho_wchar pad
+ setcchar util
+ slk_wset slk
+ unget_wch getch
+ vline_set border
+ waddnwstr addstr
+ waddwstr addstr
+ wadd_wch addch
+ wadd_wchnstr addchstr
+ wadd_wchstr addchstr
+ wbkgrnd bkgd
+ wbkgrndset bkgd
+ wborder_set border
+ wecho_wchar addch
+ wgetbkgrnd bkgd
+ wgetn_wstr getstr
+ wget_wch getch
+ wget_wstr getstr
+ whline_set border
+ winnwstr instr
+ wins_nwstr insstr
+ wins_wch insch
+ wins_wstr insstr
+ winwstr instr
+ win_wch inch
+ win_wchnstr inchstr
+ win_wchstr inchstr
+ wunctrl util
+ wvline_set border
+
+Quasi-standard functions, from Sys V or BSD curses:
+
+ getattrs attr
+ getbegx getyx
+ getbegy getyx
+ getmaxx getyx
+ getmaxy getyx
+ getparx getyx
+ getparx getyx
+ traceoff debug
+ traceon debug
+ unctrl util
+
+Classic PDCurses mouse functions, based on Sys V:
+
+ mouse_set mouse
+ mouse_on mouse
+ mouse_off mouse
+ request_mouse_pos mouse
+ map_button mouse
+ wmouse_position mouse
+ getmouse mouse
+ getbmap mouse
+
+Functions from ncurses:
+
+ assume_default_colors color
+ curses_version initscr
+ has_key keyname
+ use_default_colors color
+ wresize window
+
+ mouseinterval mouse
+ mousemask mouse
+ mouse_trafo mouse
+ nc_getmouse mouse
+ ungetmouse mouse
+ wenclose mouse
+ wmouse_trafo mouse
+
+PDCurses-specific functions -- avoid these in code that's intended to be
+portable:
+
+ addrawch addch
+ insrawch insch
+ is_termresized initscr
+ mvaddrawch addch
+ mvdeleteln deleteln
+ mvinsertln deleteln
+ mvinsrawch insch
+ mvwaddrawch addch
+ mvwdeleteln deleteln
+ mvwinsertln deleteln
+ mvwinsrawch insch
+ raw_output outopts
+ resize_term initscr
+ resize_window window
+ slk_wlabel slk
+ waddrawch addch
+ winsrawch insch
+ wordchar termattr
+
+ PDC_debug debug
+ PDC_ungetch getch
+ PDC_set_blink pdcsetsc
+ PDC_set_line_color color
+ PDC_set_title pdcsetsc
+
+ PDC_clearclipboard pdcclip
+ PDC_freeclipboard pdcclip
+ PDC_getclipboard pdcclip
+ PDC_setclipboard pdcclip
+
+ PDC_get_input_fd pdckbd
+ PDC_get_key_modifiers getch
+ PDC_return_key_modifiers getch
+ PDC_save_key_modifiers getch
+
+Functions specific to the X11 port of PDCurses:
+
+ Xinitscr initscr
+ XCursesExit -
+ sb_init sb
+ sb_set_horz sb
+ sb_set_vert sb
+ sb_get_horz sb
+ sb_get_vert sb
+ sb_refresh sb
+
+--------------------------------------------------------------------------
+
diff --git a/payloads/libpayload/curses/PDCurses-3.4/doc/manext.c b/payloads/libpayload/curses/PDCurses-3.4/doc/manext.c
new file mode 100644
index 0000000000..4ce7cbf572
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/doc/manext.c
@@ -0,0 +1,119 @@
+/***********************************************************************/
+/* MANEXT - Extract manual pages from C source code. */
+/***********************************************************************/
+/*
+ * MANEXT - A program to extract manual pages from C source code.
+ * Copyright (C) 1991-1996 Mark Hessling
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * If you make modifications to this software that you feel increases
+ * it usefulness for the rest of the community, please email the
+ * changes, enhancements, bug fixes as well as any and all ideas to me.
+ * This software is going to be maintained and enhanced as deemed
+ * necessary by the community.
+ *
+ * Mark Hessling <mark@rexx.org>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define MAX_LINE 255
+
+void display_info()
+{
+ fprintf(stderr, "\nMANEXT 1.03 Copyright (C) 1991-1996 Mark Hessling\n"
+ "All rights reserved.\n"
+ "MANEXT is distributed under the terms of the GNU\n"
+ "General Public License and comes with NO WARRANTY.\n"
+ "See the file COPYING for details.\n"
+ "\nUsage: manext sourcefile [...]\n\n");
+}
+
+int main(int argc, char **argv)
+{
+ char s[MAX_LINE + 1]; /* input line */
+ int i;
+ FILE *fp;
+
+#ifdef __EMX__
+ _wildcard(&argc, &argv);
+#endif
+ if (strcmp(argv[1], "-h") == 0)
+ {
+ display_info();
+ exit(1);
+ }
+
+ for (i = 1; i < argc; i++)
+ {
+ if ((fp = fopen(argv[i], "r")) == NULL)
+ {
+ fprintf(stderr, "\nCould not open %s\n", argv[i]);
+ continue;
+ }
+
+ while (!feof(fp))
+ {
+ if (fgets(s, (int)sizeof(s), fp) == NULL)
+ {
+ if (ferror(fp) != 0)
+ {
+ fprintf(stderr, "*** Error reading %s. Exiting.\n",
+ argv[i]);
+ exit(1);
+ }
+
+ break;
+ }
+
+ /* check for manual entry marker at beginning of line */
+
+ if (strncmp(s, "/*man-start*", 12) != 0)
+ continue;
+
+ /* inner loop */
+
+ for (;;)
+ {
+ /* read next line of manual entry */
+
+ if (fgets(s, (int)sizeof(s), fp) == NULL)
+ {
+ if (ferror(fp) != 0)
+ {
+ fprintf(stderr, "*** Error reading %s. Exiting.\n",
+ argv[i]);
+ exit(1);
+ }
+
+ break;
+ }
+
+ /* check for end of entry marker */
+
+ if (strncmp(s, "**man-end", 9) == 0)
+ break;
+
+ printf("%s", s);
+ }
+
+ printf("\n\n-----------------------------------"
+ "---------------------------------------\n\n");
+ }
+
+ fclose(fp);
+ }
+
+ return 0;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/doc/sdl.txt b/payloads/libpayload/curses/PDCurses-3.4/doc/sdl.txt
new file mode 100644
index 0000000000..6a54b9b426
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/doc/sdl.txt
@@ -0,0 +1,152 @@
+SDL Considerations
+==================
+
+There are no special requirements to use PDCurses for SDL -- all
+PDCurses-compatible code should work fine. (In fact, you can even build
+against the Win32 console pdcurses.dll, and then swap in the SDL
+pdcurses.dll.) Nothing extra is needed beyond the base SDL library.
+However, there are some optional special features, described here.
+
+The principal limitation of this port is that input is currently
+restricted to ASCII (i.e., 0-127), plus the special keys like KEY_LEFT.
+(You could have Unicode input, but then the input wouldn't match the
+output, which is in Code Page 437.) Also, see the note about the
+potential for incomplete output under "PDC_update_rects()", below.
+
+
+Fonts
+-----
+
+The font is a simple BMP, 32 characters wide by 8 characters tall,
+preferably with a palette. (BMPs without palettes still work, but in
+that case, no attributes will be available, nor will the cursor work.)
+The first entry in the palette (usually black) is treated as the
+background color; the last entry (usually white) is treated as the
+foreground. These are changed or made transparent as appropriate; any
+other colors in the palette are passed through unchanged. So -- although
+a one-bit depth is sufficient for a normal font -- you could redraw some
+characters as multi-colored tiles.
+
+The font must be monospaced. The size of each character is derived by
+dividing the width of the BMP by 32 and the height by 8. There is no
+constraint on the dimensions.
+
+As provided in the default font and expected by acs_map[], the font is
+in Code Page 437 form. But you can of course use any layout if you're
+not relying on correct values for the ACS_* macros.
+
+The font can be set via the environment variable PDC_FONT. If it's not
+set, PDCurses looks for a file named "pdcfont.bmp" in the current
+directory at the time of initscr(). If neither is found, it uses the
+built-in default font encoded in deffont.h.
+
+
+Backgrounds
+-----------
+
+PDCurses for SDL supports an optional background image BMP. This is used
+whenever start_color() has not been called (see the ptest demo for an
+example), or when use_default_colors() has been called after
+start_color(), and the background color of a pair has been set to -1
+(see newdemo, worm, and rain for examples). The usage parallels that of
+ncurses in an appropriate terminal (e.g., Gnome Terminal). The image is
+tiled to cover the PDCurses window, and can be any size or depth.
+
+As with the font, you can point to a location for the background via the
+environment variable PDC_BACKGROUND; "pdcback.bmp" is the fallback.
+(There is no default background.)
+
+
+Icons
+-----
+
+The icon (used with SDL_WM_SetIcon() -- not used for the executable
+file) can be set via the environment variable PDC_ICON, and falls back
+to "pdcicon.bmp", and then to the built-in icon from deficon.h. The
+built-in icon is the PDCurses logo, as seen in ../x11/little_icon.xbm.
+The SDL docs say that the icon must be 32x32, at least for use with MS
+Windows.
+
+If pdc_screen is preinitialized (see below), PDCurses does not attempt
+to set the icon.
+
+
+Screen size
+-----------
+
+The default screen size is 80x25 characters (whatever size they may be),
+but you can override this via the environment variables PDC_COLS and/or
+PDC_LINES. (Some other ports use COLS and LINES; this is not done here
+because those values are, or should be, those of the controlling
+terminal, and PDCurses for SDL is independent of the terminal.) If
+pdc_screen is preinitialized (see below), these are ignored.
+
+
+Integration with SDL
+--------------------
+
+If you want to go further, you can mix PDCurses and SDL functions. (Of
+course this is extremely non-portable!) To aid you, there are several
+external variables and functions specific to the SDL port; you could
+include pdcsdl.h, or just add the declarations you need in your code:
+
+ PDCEX SDL_Surface *pdc_screen, *pdc_font, *pdc_icon, *pdc_back;
+ PDCEX int pdc_sheight, pdc_swidth, pdc_yoffset, pdc_xoffset;
+
+ void PDC_update_rects(void);
+ void PDC_retile(void);
+
+pdc_screen is the main surface, created by SDL_SetVideoMode(), unless
+it's preset before initscr(). You can perform normal SDL operations on
+this surface, but PDCurses won't respect them when it updates. (For
+that, see PDC_retile().) As an alternative, you can preinitialize this
+surface before calling initscr(). In that case, you can use pdc_sheight,
+pdc_swidth, pdc_yoffset and/or pdc_xoffset (q.v.) to confine PDCurses to
+only a specific area of the surface, reserving the rest for other SDL
+operations. If you preinitialize pdc_screen, you'll have to close it
+yourself; PDCurses will ignore resize events, and won't try to set the
+icon. Also note that if you preinitialize pdc_screen, it need not be the
+display surface.
+
+pdc_font, pdc_icon, and pdc_back are the SDL_surfaces for the font,
+icon, and background, respectively. You can set any or all of them
+before initscr(), and thus override any of the other ways to set them.
+But note that pdc_icon will be ignored if pdc_screen is preset.
+
+pdc_sheight and pdc_swidth are the dimensions of the area of pdc_screen
+to be used by PDCurses. You can preset them before initscr(); if either
+is not set, it defaults to the full screen size minus the x or y offset,
+as appropriate.
+
+pdc_xoffset and pdc_yoffset are the x and y offset for the area of
+pdc_screen to be used by PDCurses. See the sdltest demo for an example.
+
+PDC_retile() makes a copy of pdc_screen, then tiles it with the
+background image, if any. The resulting surface is used as the
+background for transparent character cells. PDC_retile() is called from
+initscr() and resize_term(). However, you can also use it at other
+times, to take advantage of the way it copies pdc_screen: Draw some SDL
+stuff; call PDC_retile(); do some curses stuff -- it will use whatever
+was on pdc_screen as the background. Then you can erase the curses
+screen, do some more SDL stuff, and call PDC_retile() again to make a
+new background. (If you don't erase the curses screen, it will be
+incorporated into the background when you call PDC_retile().) But this
+only works if no background image is set.
+
+PDC_update_rects() is how the screen actually gets updated. For
+performance reasons, when drawing, PDCurses for SDL maintains a table of
+rectangles that need updating, and only updates (by calling this
+function) during getch(), napms(), or when the table gets full.
+Normally, this is sufficient; but if you're pausing in some way other
+than by using napms(), and you're not doing keyboard checks, you may get
+an incomplete update. If that happens, you can call PDC_update_rects()
+manually.
+
+
+Interaction with stdio
+----------------------
+
+As with X11, it's a bad idea to mix curses and stdio calls. (In fact,
+that's true for PDCurses on any platform; but especially these two,
+which don't run under terminals.) Depending on how SDL is built, stdout
+and stderr may be redirected to files.
diff --git a/payloads/libpayload/curses/PDCurses-3.4/doc/x11.txt b/payloads/libpayload/curses/PDCurses-3.4/doc/x11.txt
new file mode 100644
index 0000000000..db05683d17
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/doc/x11.txt
@@ -0,0 +1,416 @@
+X11 Considerations
+==================
+
+PDCurses for X11 uses the System V IPC shared memory facility, along
+with sockets, to share data between the curses program and the child
+process created to manage the X stuff.
+
+When compiling your application, you need to include the <curses.h> or
+<xcurses.h> that comes with PDCurses. You also need to link your code
+with libXCurses. You may need to link with the following libraries under
+X11R5:
+ Xaw Xmu Xt X11
+
+or, under X11R6:
+ Xaw Xmu Xt X11 SM ICE Xext
+
+You can run "xcurses-config --libs" to show the link parameters for your
+system. If using dynamic linking, on some systems, "-lXCurses" suffices.
+
+By calling Xinitscr() rather than initscr(), you can pass your program
+name and resource overrides to PDCurses. The program name is used as the
+title of the X window, and for defining X resources specific to your
+program.
+
+
+Interaction with stdio
+----------------------
+
+Be aware that curses programs that expect to have a normal tty
+underneath them will be very disappointed! Output directed to stdout
+will go to the xterm that invoked the PDCurses application, or to the
+console if not invoked directly from an xterm. Similarly, stdin will
+expect its input from the same place as stdout.
+
+
+X Resources
+-----------
+
+PDCurses for X11 recognizes the following resources:
+
+ lines
+ cols
+ normalFont
+ italicFont
+ pointer
+ pointerForeColor
+ pointerBackColor
+ cursorColor
+ textCursor
+ colorBlack
+ colorRed
+ colorGreen
+ colorYellow
+ colorBlue
+ colorMagenta
+ colorCyan
+ colorWhite
+ colorBoldBlack
+ colorBoldRed
+ colorBoldGreen
+ colorBoldYellow
+ colorBoldBlue
+ colorBoldMagenta
+ colorBoldCyan
+ colorBoldWhite
+ bitmap
+ pixmap
+ translations
+ shmmin
+ borderWidth
+ borderColor
+ clickPeriod
+ doubleClickPeriod
+ composeKey
+
+lines: Specifies the number of lines the "screen" will have.
+ Directly equates to LINES.
+ There is no theoretical maximum.
+ The minimum value must be 2.
+ Default: 24
+
+cols: Specifies the number of columns the "screen" will have.
+ Directly equates to COLS.
+ There is no theoretical maximum.
+ The minimum value must be 2.
+ Default: 80
+
+normalFont: The name of a fixed width font.
+ Default: 7x13
+
+italicFont: The name of a fixed width font to be used for
+ characters with A_ITALIC attributes. Must have the
+ same cell size as normalFont.
+ Default: 7x13 (obviously not an italic font)
+
+pointer: The name of a valid pointer cursor.
+ Default: xterm
+
+pointerForeColor: The foreground color of the pointer.
+ Default: black
+
+pointerBackColor: The background color of the pointer.
+ Default: white
+
+textCursor: The alignment of the text cursor; horizontal or vertical.
+ Default: horizontal
+
+colorBlack: The color of the COLOR_BLACK attribute.
+ Default: Black
+
+colorRed: The color of the COLOR_RED attribute.
+ Default: red3
+
+colorGreen: The color of the COLOR_GREEN attribute.
+ Default: green3
+
+colorYellow: The color of the COLOR_YELLOW attribute.
+ Default: yellow3
+
+colorBlue: The color of the COLOR_BLUE attribute.
+ Default: blue3
+
+colorMagenta: The color of the COLOR_MAGENTA attribute.
+ Default: magenta3
+
+colorCyan: The color of the COLOR_CYAN attribute.
+ Default: cyan3
+
+colorWhite: The color of the COLOR_WHITE attribute.
+ Default: Grey
+
+colorBoldBlack: COLOR_BLACK combined with A_BOLD.
+ Default: grey40
+
+colorBoldRed: COLOR_RED combined with A_BOLD.
+ Default: red1
+
+colorBoldGreen: COLOR_GREEN combined with A_BOLD.
+ Default: green1
+
+colorBoldYellow: COLOR_YELLOW combined with A_BOLD.
+ Default: yellow1
+
+colorBoldBlue: COLOR_BLUE combined with A_BOLD.
+ Default: blue1
+
+colorBoldMagenta: COLOR_MAGENTA combined with A_BOLD.
+ Default: magenta1
+
+colorBoldCyan: COLOR_CYAN combined with A_BOLD.
+ Default: cyan1
+
+colorBoldWhite: COLOR_WHITE combined with A_BOLD.
+ Default: White
+
+bitmap: The name of a valid bitmap file of depth 1 (black and white)
+ used for the application's icon. The file is an X bitmap.
+ Default: a 32x32 or 64x64 pixmap depending on the
+ window manager
+
+pixmap: The name of a valid pixmap file of any depth
+ supported by the window manager (color) for the
+ application's icon, The file is an X11 pixmap. This
+ resource is only available if the libXpm package has
+ been installed (most systems have this by default).
+ This resource overrides the "bitmap" resource.
+ Default: none, uses default bitmap above
+
+translations: Translations enable the user to customize the action
+ that occurs when a key, combination of keys, or a
+ button is pressed. The translations are similar to
+ those used by xterm.
+ Defaults:
+ <Key>: XCursesKeyPress()
+ <KeyUp>: XCursesKeyPress()
+ <BtnDown>: XCursesButton()
+ <BtnUp>: XCursesButton()
+ <BtnMotion>: XCursesButton()
+
+ The most useful action for KeyPress translations is
+ string(). The argument to the string() action can be
+ either a string or a hex representation of a
+ character; e.g., string(0x1b) will send the ASCII
+ escape character to the application; string("[11~")
+ will send [ 1 1 ~ , as separate keystrokes.
+
+shmmin: On most systems, there are two Unix kernel parameters
+ that determine the allowable size of a shared memory
+ segment. These parameters are usually something like
+ SHMMIN and SHMMAX. To use shared memory, a program
+ must allocate a segment of shared memory that is
+ between these two values. Usually these values are
+ like 1 for SHMMIN and some large number for SHMMAX.
+ Sometimes the Unix kernel is configured to have a
+ value of SHMMIN that is bigger than the size of one
+ of the shared memory segments that libXCurses uses.
+ On these systems an error message like:
+
+ Cannot allocate shared memory for SCREEN: Invalid argument
+
+ will result. To overcome this problem, this resource
+ should be set to the kernel value for SHMMIN. This
+ ensures that a shared memory segment will always be
+ bigger than the kernel value for SHMMIN (and
+ hopefully less than SHMMAX!)
+
+ Default: 0
+
+borderColor: The color of the border around the screen.
+ Default: black
+
+borderWidth: The width in pixels of the border around the screen.
+ Default: 0
+
+clickPeriod: The period (in milliseconds) between a button
+ press and a button release that determines if a click
+ of a button has occurred.
+ Default: 100
+
+doubleClickPeriod: The period (in milliseconds) between two button
+ press events that determines if a double click
+ of a button has occurred.
+ Default: 200
+
+composeKey: The name of the X key that defines the "compose key",
+ which is used to enter characters in the Latin-1
+ character set above 0xA0. (See "Compose Keys for
+ Latin-1" below.) This is used only when PDCurses is
+ built without XIM support. While in compose mode, the
+ text cursor will appear as a hollow rectangle.
+ Default: Multi_key
+
+
+Using Resources
+---------------
+
+All applications have a top-level class name of "XCurses". If Xinitscr()
+is used, it sets an application's top-level widget name. (Otherwise the
+name defaults to "PDCurses".)
+
+Examples for app-defaults or .Xdefaults:
+
+!
+! resources for XCurses class of programs
+!
+XCurses*lines: 30
+XCurses*cols: 80
+XCurses*normalFont: 9x13
+XCurses*bitmap: /tmp/xcurses.xbm
+XCurses*pointer: top_left_arrow
+!
+! resources for testcurs - XCurses
+!
+testcurs.colorRed: orange
+testcurs.colorBlack: midnightblue
+testcurs.lines: 25
+*testcurs.Translations: #override \n \
+ <Key>F12: string(0x1b) string("[11~") \n
+!
+! resources for THE - XCurses
+!
+! resources with the * wildcard can be overridden by a parameter passed
+! to initscr()
+!
+the*normalFont: 9x15
+the*lines: 40
+the*cols: 86
+the*pointer: xterm
+the*pointerForeColor: white
+the*pointerBackColor: black
+!
+! resources with the . format can not be overridden by a parameter passed
+! to Xinitscr()
+!
+the.bitmap: /home/mark/the/the64.xbm
+the.pixmap: /home/mark/the/the64.xpm
+
+Resources may also be passed as parameters to the Xinitscr() function.
+Parameters are strings in the form of switches; e.g., to set the color
+"red" to "indianred", and the number of lines to 30, the string passed
+to Xinitscr would be: "-colorRed indianred -lines 30"
+
+
+Compose Keys for Latin-1
+------------------------
+
+When built without XIM support, PDCurses for X11 provides its own,
+limited compose key system for Latin-1 characters. The available
+combinations are listed here. For a given character, any of the
+combinations shown in the last column may be used. To generate a
+character, press the "compose" key followed by one of the pairs of
+keystrokes. Where no key is evident, the spacebar is used. Thus, to
+generate the NO-BREAK SPACE, press the "compose" key followed by two
+hits of the spacebar.
+
+With a typical modern X server, you can get many more compose key
+combinations by using XIM instead. Configure PDCurses with --enable-xim
+to use XIM support.
+
+This document is encoded in UTF-8.
+
++----+-----+---+---------------------------------+---------------------------+
+|Hex | Dec |Chr| Description ISO 10646-1:1993(E) | Compose key combinations |
++----+-----+---+---------------------------------+---------------------------+
+| A0 | 160 | | NO-BREAK SPACE | |
+| A1 | 161 | ¡ | INVERTED EXCLAMATION MARK | ! !! |
+| A2 | 162 | ¢ | CENT SIGN | c| |c c/ c$ C$ C| |
+| A3 | 163 | £ | POUND SIGN | L- L$ L= l- l$ l= |-|
+| A4 | 164 | ¤ | CURRENCY SIGN | xo ox XO g$ |
+| A5 | 165 | ¥ | YEN SIGN | =y y= =Y Y= Y- y$ y-|
+| A6 | 166 | ¦ | BROKEN BAR | | || vb VB |^ |
+| A7 | 167 | § | SECTION SIGN | SO SS s! S! so |
+| A8 | 168 | ¨ | DIAERESIS | " "" |
+| A9 | 169 | © | COPYRIGHT SIGN | CO co OC |
+| AA | 170 | ª | FEMININE ORDINAL INDICATOR | sa SA a_ A_ |
+| AB | 171 | « | LEFT DOUBLE ANGLE QUOTES | << |
+| AC | 172 | ¬ | NOT SIGN | -, no NO |
+| AD | 173 | ­ | SOFT HYPHEN | - -- |
+| AE | 174 | ® | REGISTERED SIGN | RO ro OR |
+| AF | 175 | ¯ | MACRON | -^ _^ __ |
+| B0 | 176 | ° | DEGREE SIGN | o 0^ 0* de DE ^0 |
+| B1 | 177 | ± | PLUS-MINUS SIGN | -+ +- |
+| B2 | 178 | ² | SUPERSCRIPT TWO | 2 2^ s2 ^2 |
+| B3 | 179 | ³ | SUPERSCRIPT THREE | 3 3^ s3 ^3 |
+| B4 | 180 | ´ | ACUTE ACCENT | ' '' |
+| B5 | 181 | µ | MICRO SIGN | u /u /U *m *M |
+| B6 | 182 | ¶ | PILCROW SIGN | p! P! pg PG |
+| B7 | 183 | · | MIDDLE DOT | . .^ .. |
+| B8 | 184 | ¸ | CEDILLA | , ,, |
+| B9 | 185 | ¹ | SUPERSCRIPT ONE | 1 1^ s1 ^1 |
+| BA | 186 | º | MASCULINE ORDINAL INDICATOR | o_ s0 S0 |
+| BB | 187 | » | RIGHT DOUBLE ANGLE QUOTES | >> |
+| BC | 188 | ¼ | VULGAR FRACTION ONE QUARTER | 14 |
+| BD | 189 | ½ | VULGAR FRACTION ONE HALF | 12 |
+| BE | 190 | ¾ | VULGAR FRACTION THREE QUARTERS | 34 |
+| BF | 191 | ¿ | INVERTED QUESTION MARK | ? ?? |
+| C0 | 192 | À | CAPITAL A WITH GRAVE ACCENT | `A A` |
+| C1 | 193 | Á | CAPITAL A WITH ACUTE ACCENT | 'A A' |
+| C2 | 194 | Â | CAPITAL A WITH CIRCUMFLEX ACCENT| ^A A^ A> |
+| C3 | 195 | Ã | CAPITAL A WITH TILDE | ~A A~ A- |
+| C4 | 196 | Ä | CAPITAL A WITH DIAERESIS | "A A" |
+| C5 | 197 | Å | CAPITAL A WITH RING ABOVE | oA Ao A* OA *A |
+| C6 | 198 | Æ | CAPITAL LIGATURE AE | AE |
+| C7 | 199 | Ç | CAPITAL C WITH CEDILLA | ,C C, |
+| C8 | 200 | È | CAPITAL E WITH GRAVE ACCENT | `E E` |
+| C9 | 201 | É | CAPITAL E WITH ACUTE ACCENT | 'E E' |
+| CA | 202 | Ê | CAPITAL E WITH CIRCUMFLEX ACCENT| ^E E^ E> |
+| CB | 203 | Ë | CAPITAL E WITH DIAERESIS | "E E" |
+| CC | 204 | Ì | CAPITAL I WITH GRAVE ACCENT | `I I` |
+| CD | 205 | Í | CAPITAL I WITH ACUTE ACCENT | 'I I' |
+| CE | 206 | Î | CAPITAL I WITH CIRCUMFLEX ACCENT| ^I I^ I> |
+| CF | 207 | Ï | CAPITAL I WITH DIAERESIS | "I I" |
+| D0 | 208 | Ð | CAPITAL ETH | D- |
+| D1 | 209 | Ñ | CAPITAL N WITH TILDE | ~N N~ N- |
+| D2 | 210 | Ò | CAPITAL O WITH GRAVE ACCENT | `O O` |
+| D3 | 211 | Ó | CAPITAL O WITH ACUTE ACCENT | 'O O' |
+| D4 | 212 | Ô | CAPITAL O WITH CIRCUMFLEX ACCENT| ^O O^ O> |
+| D5 | 213 | Õ | CAPITAL O WITH TILDE | ~O O~ O- |
+| D6 | 214 | Ö | CAPITAL O WITH DIAERESIS | "O O" |
+| D7 | 215 | × | MULTIPLICATION SIGN | x xx XX mu MU |
+| D8 | 216 | Ø | CAPITAL O WITH STROKE | /O O/ |
+| D9 | 217 | Ù | CAPITAL U WITH GRAVE ACCENT | `U U` |
+| DA | 218 | Ú | CAPITAL U WITH ACUTE ACCENT | 'U U' |
+| DB | 219 | Û | CAPITAL U WITH CIRCUMFLEX ACCENT| ^U U^ U> |
+| DC | 220 | Ü | CAPITAL U WITH DIAERESIS | "U U" |
+| DD | 221 | Ý | CAPITAL Y WITH ACUTE ACCENT | 'Y Y' |
+| DE | 222 | Þ | CAPITAL THORN | P TH |P |
+| DF | 223 | ß | SMALL SHARP S | ss |
+| E0 | 224 | à | SMALL A WITH GRAVE ACCENT | `a a` |
+| E1 | 225 | á | SMALL A WITH ACUTE ACCENT | 'a a' |
+| E2 | 226 | â | SMALL A WITH CIRCUMFLEX ACCENT | ^a a^ a> |
+| E3 | 227 | ã | SMALL A WITH TILDE | ~a a~ a- |
+| E4 | 228 | ä | SMALL A WITH DIAERESIS | "a a" |
+| E5 | 229 | å | SMALL A WITH RING ABOVE | oa ao Oa a* *a |
+| E6 | 230 | æ | SMALL LIGATURE AE | ae |
+| E7 | 231 | ç | SMALL C WITH CEDILLA | ,c c, |
+| E8 | 232 | è | SMALL E WITH GRAVE ACCENT | `e e` |
+| E9 | 233 | é | SMALL E WITH ACUTE ACCENT | 'e e' |
+| EA | 234 | ê | SMALL E WITH CIRCUMFLEX ACCENT | ^e e^ e> |
+| EB | 235 | ë | SMALL E WITH DIAERESIS | "e e" |
+| EC | 236 | ì | SMALL I WITH GRAVE ACCENT | `i i` |
+| ED | 237 | í | SMALL I WITH ACUTE ACCENT | 'i i' |
+| EE | 238 | î | SMALL I WITH CIRCUMFLEX ACCENT | ^i i^ i> |
+| EF | 239 | ï | SMALL I WITH DIAERESIS | "i i" |
+| F0 | 240 | ð | SMALL ETH | d- |
+| F1 | 241 | ñ | SMALL N WITH TILDE | ~n n~ n- |
+| F2 | 242 | ò | SMALL O WITH GRAVE ACCENT | `o o` |
+| F3 | 243 | ó | SMALL O WITH ACUTE ACCENT | 'o o' |
+| F4 | 244 | ô | SMALL O WITH CIRCUMFLEX ACCENT | ^o o^ o> |
+| F5 | 245 | õ | SMALL O WITH TILDE | ~o o~ o- |
+| F6 | 246 | ö | SMALL O WITH DIAERESIS | "o o" |
+| F7 | 247 | ÷ | DIVISION SIGN | -: :- |
+| F8 | 248 | ø | SMALL O WITH OBLIQUE BAR | /o o/ |
+| F9 | 249 | ù | SMALL U WITH GRAVE ACCENT | `u u` |
+| FA | 250 | ú | SMALL U WITH ACUTE ACCENT | 'u u' |
+| FB | 251 | û | SMALL U WITH CIRCUMFLEX ACCENT | ^u u^ u> |
+| FC | 252 | ü | SMALL U WITH DIAERESIS | "u u" |
+| FD | 253 | ý | SMALL Y WITH ACUTE ACCENT | 'y y' |
+| FE | 254 | þ | SMALL THORN | p th |p |
+| FF | 255 | ÿ | SMALL Y WITH DIAERESIS | "y y" |
++----+-----+---+---------------------------------+---------------------------+
+
+
+Deprecated
+----------
+
+XCursesProgramName is no longer used. To set the program name, you must
+use Xinitscr(), or PDC_set_title() to set just the window title.
+
+The XCursesExit() function is now called automatically via atexit().
+(Multiple calls to it are OK, so you don't need to remove it if you've
+already added it for previous versions of PDCurses.)
+
+XCURSES is no longer defined automatically, but need not be defined,
+unless you want the X11-specific prototypes. (Normal curses programs
+won't need it.)
diff --git a/payloads/libpayload/curses/PDCurses-3.4/dos/README b/payloads/libpayload/curses/PDCurses-3.4/dos/README
new file mode 100644
index 0000000000..569034bbae
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/dos/README
@@ -0,0 +1,49 @@
+PDCurses for DOS
+================
+
+This directory contains PDCurses source code files specific to DOS.
+
+
+Building
+--------
+
+. Choose the appropriate makefile for your compiler:
+
+ bccdos.mak - Borland C++ 3.0+
+ gccdos.mak - DJGPP V2
+ mscdos.mak - Microsoft C
+ wccdos16.mak - Watcom 10.6+ (16-bit)
+ wccdos4g.mak - Watcom 10.6+ (32-bit)
+
+. For 16-bit compilers, you can change the memory MODEL in the makefile.
+ (Large model is the default, and recommended.)
+
+. Optionally, you can build in a different directory than the platform
+ directory by setting PDCURSES_SRCDIR to point to the directory where
+ you unpacked PDCurses, and changing to your target directory:
+
+ set PDCURSES_SRCDIR=c:\pdcurses
+
+. Build it:
+
+ make -f makefile
+
+ (For Watcom, use "wmake" instead of "make"; for MSVC, "nmake".) You'll
+ get the libraries (pdcurses.lib or .a, depending on your compiler; and
+ panel.lib or .a), the demos (*.exe), and a lot of object files. Note
+ that the panel library is just a copy of the main library, provided
+ for convenience; both panel and curses functions are in the main
+ library.
+
+
+Distribution Status
+-------------------
+
+The files in this directory are released to the Public Domain.
+
+
+Acknowledgements
+----------------
+
+Watcom C port was provided by Pieter Kunst <kunst@prl.philips.nl>
+DJGPP 1.x port was provided by David Nugent <davidn@csource.oz.au>
diff --git a/payloads/libpayload/curses/PDCurses-3.4/dos/bccdos.lrf b/payloads/libpayload/curses/PDCurses-3.4/dos/bccdos.lrf
new file mode 100644
index 0000000000..9bd18c6b2d
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/dos/bccdos.lrf
@@ -0,0 +1,9 @@
++addch.obj +addchstr.obj +addstr.obj +attr.obj +beep.obj +bkgd.obj &
++border.obj +clear.obj +color.obj +delch.obj +deleteln.obj +deprec.obj &
++getch.obj +getstr.obj +getyx.obj +inch.obj +inchstr.obj +initscr.obj &
++inopts.obj +insch.obj +insstr.obj +instr.obj +kernel.obj +keyname.obj &
++mouse.obj +move.obj +outopts.obj +overlay.obj +pad.obj +panel.obj &
++printw.obj +refresh.obj +scanw.obj +scr_dump.obj +scroll.obj +slk.obj &
++termattr.obj +terminfo.obj +touch.obj +util.obj +window.obj +debug.obj &
++pdcclip.obj +pdcdisp.obj +pdcgetsc.obj +pdckbd.obj +pdcscrn.obj &
++pdcsetsc.obj +pdcutil.obj ,lib.map
diff --git a/payloads/libpayload/curses/PDCurses-3.4/dos/bccdos.mak b/payloads/libpayload/curses/PDCurses-3.4/dos/bccdos.mak
new file mode 100644
index 0000000000..6361a4d8b7
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/dos/bccdos.mak
@@ -0,0 +1,82 @@
+# Borland MAKE Makefile for PDCurses library - DOS BC++ 3.0+
+#
+# Usage: make -f [path\]bccdos.mak [DEBUG=] [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.lib|testcurs.exe...]
+
+# Change the memory MODEL here, if desired
+MODEL = l
+
+O = obj
+
+!ifndef PDCURSES_SRCDIR
+PDCURSES_SRCDIR = ..
+!endif
+
+!include $(PDCURSES_SRCDIR)\version.mif
+!include $(PDCURSES_SRCDIR)\libobjs.mif
+
+osdir = $(PDCURSES_SRCDIR)\dos
+
+!ifdef DEBUG
+CFLAGS = -N -v -y -DPDCDEBUG
+!else
+CFLAGS = -O
+!endif
+
+CPPFLAGS = -I$(PDCURSES_SRCDIR)
+
+BUILD = $(CC) -1- -K -G -rd -d -w-eff -w-par -c \
+-m$(MODEL) $(CFLAGS) $(CPPFLAGS)
+
+LIBEXE = tlib /C /E
+
+LIBCURSES = pdcurses.lib
+
+all: $(LIBCURSES) $(DEMOS)
+
+clean:
+ -del *.obj
+ -del *.lib
+ -del *.map
+ -del *.exe
+
+demos: $(DEMOS)
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ -del $@
+ $(LIBEXE) $@ @$(osdir)\bccdos.lrf
+ -copy $(LIBCURSES) panel.lib
+
+.autodepend
+
+{$(srcdir)\}.c.obj:
+ $(BUILD) $<
+
+{$(osdir)\}.c.obj:
+ $(BUILD) $<
+
+{$(demodir)\}.c.obj:
+ $(BUILD) $<
+
+.c.obj:
+ $(BUILD) $<
+
+.obj.exe:
+ $(CC) -m$(MODEL) -e$@ $** $(LIBCURSES)
+
+tuidemo.exe: tuidemo.obj tui.obj $(LIBCURSES)
+ $(CC) -m$(MODEL) -e$@ $**
+
+tui.obj: $(demodir)\tui.c $(demodir)\tui.h $(PDCURSES_CURSES_H)
+ $(BUILD) -I$(demodir) $(demodir)\tui.c
+
+tuidemo.obj: $(demodir)\tuidemo.c $(PDCURSES_CURSES_H)
+ $(BUILD) -I$(demodir) $(demodir)\tuidemo.c
+
+PLATFORM1 = Borland C++ 3.1
+PLATFORM2 = Borland C/C++ 3.1 for DOS
+ARCNAME = pdc$(VER)bcc
+
+!include $(PDCURSES_SRCDIR)\makedist.mif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/dos/gccdos.mak b/payloads/libpayload/curses/PDCurses-3.4/dos/gccdos.mak
new file mode 100644
index 0000000000..26a4ed3d09
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/dos/gccdos.mak
@@ -0,0 +1,87 @@
+# GNU MAKE (3.79.1) Makefile for PDCurses library - DOS DJGPP V2.0+
+#
+# Usage: make -f [path\]gccdos.mak [DEBUG=Y] [target]
+#
+# where target can be any of:
+# [all|libs|demos|dist|pdcurses.a|testcurs.exe...]
+
+O = o
+
+ifndef PDCURSES_SRCDIR
+ PDCURSES_SRCDIR = ..
+endif
+
+include $(PDCURSES_SRCDIR)/version.mif
+include $(PDCURSES_SRCDIR)/libobjs.mif
+
+osdir = $(PDCURSES_SRCDIR)/dos
+
+PDCURSES_DOS_H = $(osdir)/pdcdos.h
+
+CC = gcc
+
+ifeq ($(DEBUG),Y)
+ CFLAGS = -g -Wall -DPDCDEBUG
+ LDFLAGS = -g
+else
+ CFLAGS = -O2 -Wall
+ LDFLAGS =
+endif
+
+CFLAGS += -I$(PDCURSES_SRCDIR)
+
+LINK = gcc
+
+LIBEXE = ar
+LIBFLAGS = rcv
+
+LIBCURSES = pdcurses.a
+
+.PHONY: all libs clean demos dist
+
+all: libs demos
+
+libs: $(LIBCURSES)
+
+clean:
+ -del *.o
+ -del *.a
+ -del *.exe
+
+demos: $(DEMOS)
+ strip *.exe
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ $(LIBEXE) $(LIBFLAGS) $@ $?
+ -copy $(LIBCURSES) panel.a
+
+$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
+$(PDCOBJS) : $(PDCURSES_DOS_H)
+$(DEMOS) : $(PDCURSES_CURSES_H) $(LIBCURSES)
+panel.o : $(PANEL_HEADER)
+terminfo.o: $(TERM_HEADER)
+
+$(LIBOBJS) : %.o: $(srcdir)/%.c
+ $(CC) -c $(CFLAGS) $<
+
+$(PDCOBJS) : %.o: $(osdir)/%.c
+ $(CC) -c $(CFLAGS) $<
+
+firework.exe newdemo.exe rain.exe testcurs.exe worm.exe xmas.exe \
+ptest.exe: %.exe: $(demodir)/%.c
+ $(CC) $(CFLAGS) -o$@ $< $(LIBCURSES)
+
+tuidemo.exe: tuidemo.o tui.o
+ $(LINK) $(LDFLAGS) -o$@ tuidemo.o tui.o $(LIBCURSES)
+
+tui.o: $(demodir)/tui.c $(demodir)/tui.h $(PDCURSES_CURSES_H)
+ $(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<
+
+tuidemo.o: $(demodir)/tuidemo.c $(PDCURSES_CURSES_H)
+ $(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<
+
+PLATFORM1 = DJGPP 2.03
+PLATFORM2 = DJGPP 2.03 for DOS
+ARCNAME = pdc$(VER)djg
+
+include $(PDCURSES_SRCDIR)/makedist.mif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/dos/mscdos.lrf b/payloads/libpayload/curses/PDCurses-3.4/dos/mscdos.lrf
new file mode 100644
index 0000000000..b1fdf37e99
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/dos/mscdos.lrf
@@ -0,0 +1,50 @@
+-+addch.obj &
+-+addchstr.obj &
+-+addstr.obj &
+-+attr.obj &
+-+beep.obj &
+-+bkgd.obj &
+-+border.obj &
+-+clear.obj &
+-+color.obj &
+-+delch.obj &
+-+deleteln.obj &
+-+deprec.obj &
+-+getch.obj &
+-+getstr.obj &
+-+getyx.obj &
+-+inch.obj &
+-+inchstr.obj &
+-+initscr.obj &
+-+inopts.obj &
+-+insch.obj &
+-+insstr.obj &
+-+instr.obj &
+-+kernel.obj &
+-+keyname.obj &
+-+mouse.obj &
+-+move.obj &
+-+outopts.obj &
+-+overlay.obj &
+-+pad.obj &
+-+panel.obj &
+-+printw.obj &
+-+refresh.obj &
+-+scanw.obj &
+-+scr_dump.obj &
+-+scroll.obj &
+-+slk.obj &
+-+termattr.obj &
+-+terminfo.obj &
+-+touch.obj &
+-+util.obj &
+-+window.obj &
+-+debug.obj &
+-+pdcclip.obj &
+-+pdcdisp.obj &
+-+pdcgetsc.obj &
+-+pdckbd.obj &
+-+pdcscrn.obj &
+-+pdcsetsc.obj &
+-+pdcutil.obj &
+,lib.map;
diff --git a/payloads/libpayload/curses/PDCurses-3.4/dos/mscdos.mak b/payloads/libpayload/curses/PDCurses-3.4/dos/mscdos.mak
new file mode 100644
index 0000000000..7aa6c5f715
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/dos/mscdos.mak
@@ -0,0 +1,114 @@
+# NMAKE Makefile for PDCurses library - Microsoft C for DOS
+#
+# Usage: nmake -f [path\]dosmsc.mak [DEBUG=] [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.lib|testcurs.exe...]
+
+# Change the memory MODEL here, if desired
+MODEL = L # one of L, S, M, T, H, C
+SIZE = LARGE # one of LARGE, SMALL, MEDIUM, TINY, HUGE, COMPACT
+
+O = obj
+
+!ifndef PDCURSES_SRCDIR
+PDCURSES_SRCDIR = ..
+!endif
+
+!include $(PDCURSES_SRCDIR)\version.mif
+!include $(PDCURSES_SRCDIR)\libobjs.mif
+
+osdir = $(PDCURSES_SRCDIR)\dos
+
+PDCURSES_DOS_H = $(osdir)\pdcdos.h
+
+CC = cl
+
+!ifdef DEBUG
+CFLAGS = /Od /Zi /DPDCDEBUG
+LDFLAGS = /CO /NOE /SE:160
+!else
+CFLAGS = /Ox
+LDFLAGS = /NOE /SE:160
+!endif
+
+CPPFLAGS = -I$(PDCURSES_SRCDIR)
+
+BUILD = $(CC) /J /nologo /c /D$(SIZE) /A$(MODEL) $(CFLAGS) $(CPPFLAGS)
+
+LINK = link
+
+CCLIBS =
+
+LIBEXE = lib
+
+LIBCURSES = pdcurses.lib
+
+all: $(LIBCURSES) $(DEMOS)
+
+clean:
+ -del *.obj
+ -del *.lib
+ -del *.exe
+
+demos: $(DEMOS)
+
+DEMOOBJS = $(DEMOS:.exe=.obj) tui.obj
+
+$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
+$(DEMOOBJS) : $(PDCURSES_CURSES_H)
+$(DEMOS) : $(LIBCURSES)
+panel.obj : $(PANEL_HEADER)
+terminfo.obj: $(TERM_HEADER)
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ $(LIBEXE) $@ @$(osdir)\mscdos.lrf
+ -copy $(LIBCURSES) panel.lib
+
+{$(srcdir)\}.c{}.obj:
+ $(BUILD) $<
+
+{$(osdir)\}.c{}.obj:
+ $(BUILD) $<
+
+{$(demodir)\}.c{}.obj:
+ $(BUILD) $<
+
+firework.exe: firework.obj
+ $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
+
+newdemo.exe: newdemo.obj
+ $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
+
+ptest.exe: ptest.obj
+ $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
+
+rain.exe: rain.obj
+ $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
+
+testcurs.exe: testcurs.obj
+ $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
+
+tuidemo.exe: tuidemo.obj tui.obj
+ $(LINK) $(LDFLAGS) $*.obj+tui.obj,$*,,$(LIBCURSES);
+
+worm.exe: worm.obj
+ $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
+
+xmas.exe: xmas.obj
+ $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
+
+ptest.obj: $(demodir)\ptest.c $(PANEL_HEADER)
+ $(BUILD) $(demodir)\ptest.c
+
+tui.obj: $(demodir)\tui.c $(demodir)\tui.h
+ $(BUILD) -I$(demodir) $(demodir)\tui.c
+
+tuidemo.obj: $(demodir)\tuidemo.c
+ $(BUILD) -I$(demodir) $(demodir)\tuidemo.c
+
+PLATFORM1 = Microsoft C
+PLATFORM2 = Microsoft C for DOS
+ARCNAME = pdc$(VER)msc
+
+!include $(PDCURSES_SRCDIR)\makedist.mif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/dos/pdcclip.c b/payloads/libpayload/curses/PDCurses-3.4/dos/pdcclip.c
new file mode 100644
index 0000000000..74607aa0bc
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/dos/pdcclip.c
@@ -0,0 +1,129 @@
+/* Public Domain Curses */
+
+#include "pdcdos.h"
+
+RCSID("$Id: pdcclip.c,v 1.33 2008/07/13 16:08:17 wmcbrine Exp $")
+
+#include <stdlib.h>
+
+/*man-start**************************************************************
+
+ Name: clipboard
+
+ Synopsis:
+ int PDC_getclipboard(char **contents, long *length);
+ int PDC_setclipboard(const char *contents, long length);
+ int PDC_freeclipboard(char *contents);
+ int PDC_clearclipboard(void);
+
+ Description:
+ PDC_getclipboard() gets the textual contents of the system's
+ clipboard. This function returns the contents of the clipboard
+ in the contents argument. It is the responsibilitiy of the
+ caller to free the memory returned, via PDC_freeclipboard().
+ The length of the clipboard contents is returned in the length
+ argument.
+
+ PDC_setclipboard copies the supplied text into the system's
+ clipboard, emptying the clipboard prior to the copy.
+
+ PDC_clearclipboard() clears the internal clipboard.
+
+ Return Values:
+ indicator of success/failure of call.
+ PDC_CLIP_SUCCESS the call was successful
+ PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for
+ the clipboard contents
+ PDC_CLIP_EMPTY the clipboard contains no text
+ PDC_CLIP_ACCESS_ERROR no clipboard support
+
+ Portability X/Open BSD SYS V
+ PDC_getclipboard - - -
+ PDC_setclipboard - - -
+ PDC_freeclipboard - - -
+ PDC_clearclipboard - - -
+
+**man-end****************************************************************/
+
+/* global clipboard contents, should be NULL if none set */
+
+static char *pdc_DOS_clipboard = NULL;
+
+int PDC_getclipboard(char **contents, long *length)
+{
+ int len;
+
+ PDC_LOG(("PDC_getclipboard() - called\n"));
+
+ if (!pdc_DOS_clipboard)
+ return PDC_CLIP_EMPTY;
+
+ len = strlen(pdc_DOS_clipboard);
+ if ((*contents = malloc(len + 1)) == NULL)
+ return PDC_CLIP_MEMORY_ERROR;
+
+ strcpy(*contents, pdc_DOS_clipboard);
+ *length = len;
+
+ return PDC_CLIP_SUCCESS;
+}
+
+int PDC_setclipboard(const char *contents, long length)
+{
+ PDC_LOG(("PDC_setclipboard() - called\n"));
+
+ if (pdc_DOS_clipboard)
+ {
+ free(pdc_DOS_clipboard);
+ pdc_DOS_clipboard = NULL;
+ }
+
+ if (contents)
+ {
+ if ((pdc_DOS_clipboard = malloc(length + 1)) == NULL)
+ return PDC_CLIP_MEMORY_ERROR;
+
+ strcpy(pdc_DOS_clipboard, contents);
+ }
+
+ return PDC_CLIP_SUCCESS;
+}
+
+int PDC_freeclipboard(char *contents)
+{
+ PDC_LOG(("PDC_freeclipboard() - called\n"));
+
+ /* should we also free empty the system clipboard? probably not */
+
+ if (contents)
+ {
+
+ /* NOTE: We free the memory, but we can not set caller's pointer
+ to NULL, so if caller calls again then will try to access
+ free'd memory. We 1st overwrite memory with a string so if
+ caller tries to use free memory they won't get what they
+ expect & hopefully notice. */
+
+ /* memset(contents, 0xFD, strlen(contents)); */
+
+ if (strlen(contents) >= strlen("PDCURSES"))
+ strcpy(contents, "PDCURSES");
+
+ free(contents);
+ }
+
+ return PDC_CLIP_SUCCESS;
+}
+
+int PDC_clearclipboard(void)
+{
+ PDC_LOG(("PDC_clearclipboard() - called\n"));
+
+ if (pdc_DOS_clipboard)
+ {
+ free(pdc_DOS_clipboard);
+ pdc_DOS_clipboard = NULL;
+ }
+
+ return PDC_CLIP_SUCCESS;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/dos/pdcdisp.c b/payloads/libpayload/curses/PDCurses-3.4/dos/pdcdisp.c
new file mode 100644
index 0000000000..aae9bfb56d
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/dos/pdcdisp.c
@@ -0,0 +1,158 @@
+/* Public Domain Curses */
+
+#include "pdcdos.h"
+
+RCSID("$Id: pdcdisp.c,v 1.65 2008/07/13 16:08:17 wmcbrine Exp $")
+
+/* ACS definitions originally by jshumate@wrdis01.robins.af.mil -- these
+ match code page 437 and compatible pages (CP850, CP852, etc.) */
+
+#ifdef CHTYPE_LONG
+
+# define A(x) ((chtype)x | A_ALTCHARSET)
+
+chtype acs_map[128] =
+{
+ A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9), A(10),
+ A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18), A(19),
+ A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27), A(28),
+ A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&', '\'', '(',
+ ')', '*',
+
+ A(0x1a), A(0x1b), A(0x18), A(0x19),
+
+ '/',
+
+ 0xdb,
+
+ '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
+ '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
+ 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
+
+ A(0x04), 0xb1,
+
+ 'b', 'c', 'd', 'e',
+
+ 0xf8, 0xf1, 0xb0, A(0x0f), 0xd9, 0xbf, 0xda, 0xc0, 0xc5, 0x2d, 0x2d,
+ 0xc4, 0x2d, 0x5f, 0xc3, 0xb4, 0xc1, 0xc2, 0xb3, 0xf3, 0xf2, 0xe3,
+ 0xd8, 0x9c, 0xf9,
+
+ A(127)
+};
+
+# undef A
+
+#endif
+
+#ifdef __PACIFIC__
+void movedata(unsigned sseg, unsigned soff, unsigned dseg,
+ unsigned doff, unsigned n)
+{
+ far char *src = MK_FP(sseg, soff);
+ far char *dst = MK_FP(dseg, doff);
+
+ while (n--)
+ *dst++ = *src++;
+}
+#endif
+
+/* position hardware cursor at (y, x) */
+
+void PDC_gotoyx(int row, int col)
+{
+ PDCREGS regs;
+
+ PDC_LOG(("PDC_gotoyx() - called: row %d col %d\n", row, col));
+
+ regs.h.ah = 0x02;
+ regs.h.bh = 0;
+ regs.h.dh = (unsigned char) row;
+ regs.h.dl = (unsigned char) col;
+ PDCINT(0x10, regs);
+}
+
+/* update the given physical line to look like the corresponding line in
+ curscr */
+
+void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
+{
+ int j;
+
+ PDC_LOG(("PDC_transform_line() - called: line %d\n", lineno));
+
+ if (pdc_direct_video)
+ {
+#if SMALL || MEDIUM
+# ifndef __PACIFIC__
+ struct SREGS segregs;
+# endif
+ int ds;
+#endif
+ /* this should be enough for the maximum width of a screen */
+
+ struct {unsigned char text, attr;} temp_line[256];
+
+ /* replace the attribute part of the chtype with the actual
+ color value for each chtype in the line */
+
+ for (j = 0; j < len; j++)
+ {
+ chtype ch = srcp[j];
+
+ temp_line[j].attr = pdc_atrtab[ch >> PDC_ATTR_SHIFT];
+#ifdef CHTYPE_LONG
+ if (ch & A_ALTCHARSET && !(ch & 0xff80))
+ ch = acs_map[ch & 0x7f];
+#endif
+ temp_line[j].text = ch & 0xff;
+ }
+
+#ifdef __DJGPP__
+ dosmemput(temp_line, len * 2,
+ (unsigned long)_FAR_POINTER(pdc_video_seg,
+ pdc_video_ofs + (lineno * curscr->_maxx + x) * 2));
+#else
+# if SMALL || MEDIUM
+# ifdef __PACIFIC__
+ ds = FP_SEG((void far *) temp_line);
+# else
+ segread(&segregs);
+ ds = segregs.ds;
+# endif
+ movedata(ds, (int)temp_line, pdc_video_seg,
+ pdc_video_ofs + (lineno * curscr->_maxx + x) * 2, len * 2);
+# else
+ memcpy((void *)_FAR_POINTER(pdc_video_seg,
+ pdc_video_ofs + (lineno * curscr->_maxx + x) * 2),
+ temp_line, len * 2);
+# endif
+#endif
+
+ }
+ else
+ for (j = 0; j < len;)
+ {
+ PDCREGS regs;
+ unsigned short count = 1;
+ chtype ch = srcp[j];
+
+ while ((j + count < len) && (ch == srcp[j + count]))
+ count++;
+
+ PDC_gotoyx(lineno, j + x);
+
+ regs.h.ah = 0x09;
+ regs.W.bx = pdc_atrtab[ch >> PDC_ATTR_SHIFT];
+ regs.W.cx = count;
+#ifdef CHTYPE_LONG
+ if (ch & A_ALTCHARSET && !(ch & 0xff80))
+ ch = acs_map[ch & 0x7f];
+#endif
+ regs.h.al = (unsigned char) (ch & 0xff);
+
+ PDCINT(0x10, regs);
+
+ j += count;
+ }
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/dos/pdcdos.h b/payloads/libpayload/curses/PDCurses-3.4/dos/pdcdos.h
new file mode 100644
index 0000000000..436699de2f
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/dos/pdcdos.h
@@ -0,0 +1,186 @@
+/* Public Domain Curses */
+
+/* $Id: pdcdos.h,v 1.30 2008/07/13 16:08:17 wmcbrine Exp $ */
+
+#include <curspriv.h>
+#include <string.h>
+
+#if defined(_MSC_VER) || defined(_QC)
+# define MSC 1
+#endif
+
+#if defined(__PACIFIC__) && !defined(__SMALL__)
+# define __SMALL__
+#endif
+
+#if defined(__HIGHC__) || MSC
+# include <bios.h>
+#endif
+
+/*----------------------------------------------------------------------
+ * MEMORY MODEL SUPPORT:
+ *
+ * MODELS
+ * TINY cs,ds,ss all in 1 segment (not enough memory!)
+ * SMALL cs:1 segment, ds:1 segment
+ * MEDIUM cs:many segments, ds:1 segment
+ * COMPACT cs:1 segment, ds:many segments
+ * LARGE cs:many segments, ds:many segments
+ * HUGE cs:many segments, ds:segments > 64K
+ */
+
+#ifdef __TINY__
+# define SMALL 1
+#endif
+#ifdef __SMALL__
+# define SMALL 1
+#endif
+#ifdef __MEDIUM__
+# define MEDIUM 1
+#endif
+#ifdef __COMPACT__
+# define COMPACT 1
+#endif
+#ifdef __LARGE__
+# define LARGE 1
+#endif
+#ifdef __HUGE__
+# define HUGE 1
+#endif
+
+#include <dos.h>
+
+extern unsigned char *pdc_atrtab;
+extern int pdc_adapter;
+extern int pdc_scrnmode;
+extern int pdc_font;
+extern bool pdc_direct_video;
+extern bool pdc_bogus_adapter;
+extern unsigned pdc_video_seg;
+extern unsigned pdc_video_ofs;
+
+#ifdef __DJGPP__ /* Note: works only in plain DOS... */
+# if DJGPP == 2
+# define _FAR_POINTER(s,o) ((((int)(s)) << 4) + ((int)(o)))
+# else
+# define _FAR_POINTER(s,o) (0xe0000000 + (((int)(s)) << 4) + ((int)(o)))
+# endif
+# define _FP_SEGMENT(p) (unsigned short)((((long)p) >> 4) & 0xffff)
+#else
+# ifdef __TURBOC__
+# define _FAR_POINTER(s,o) MK_FP(s,o)
+# else
+# if defined(__WATCOMC__) && defined(__FLAT__)
+# define _FAR_POINTER(s,o) ((((int)(s)) << 4) + ((int)(o)))
+# else
+# define _FAR_POINTER(s,o) (((long)s << 16) | (long)o)
+# endif
+# endif
+# define _FP_SEGMENT(p) (unsigned short)(((long)p) >> 4)
+#endif
+#define _FP_OFFSET(p) ((unsigned short)p & 0x000f)
+
+#ifdef __DJGPP__
+# include <sys/movedata.h>
+unsigned char getdosmembyte(int offs);
+unsigned short getdosmemword(int offs);
+unsigned long getdosmemdword(int offs);
+void setdosmembyte(int offs, unsigned char b);
+void setdosmemword(int offs, unsigned short w);
+#else
+# if SMALL || MEDIUM || MSC
+# define PDC_FAR far
+# else
+# define PDC_FAR
+# endif
+# define getdosmembyte(offs) \
+ (*((unsigned char PDC_FAR *) _FAR_POINTER(0,offs)))
+# define getdosmemword(offs) \
+ (*((unsigned short PDC_FAR *) _FAR_POINTER(0,offs)))
+# define getdosmemdword(offs) \
+ (*((unsigned long PDC_FAR *) _FAR_POINTER(0,offs)))
+# define setdosmembyte(offs,x) \
+ (*((unsigned char PDC_FAR *) _FAR_POINTER(0,offs)) = (x))
+# define setdosmemword(offs,x) \
+ (*((unsigned short PDC_FAR *) _FAR_POINTER(0,offs)) = (x))
+#endif
+
+#if defined(__WATCOMC__) && defined(__386__)
+
+typedef union
+{
+ struct
+ {
+ unsigned long edi, esi, ebp, res, ebx, edx, ecx, eax;
+ } d;
+
+ struct
+ {
+ unsigned short di, di_hi, si, si_hi, bp, bp_hi, res, res_hi,
+ bx, bx_hi, dx, dx_hi, cx, cx_hi, ax, ax_hi,
+ flags, es, ds, fs, gs, ip, cs, sp, ss;
+ } w;
+
+ struct
+ {
+ unsigned char edi[4], esi[4], ebp[4], res[4],
+ bl, bh, ebx_b2, ebx_b3, dl, dh, edx_b2, edx_b3,
+ cl, ch, ecx_b2, ecx_b3, al, ah, eax_b2, eax_b3;
+ } h;
+} pdc_dpmi_regs;
+
+void PDC_dpmi_int(int, pdc_dpmi_regs *);
+
+#endif
+
+#ifdef __DJGPP__
+# include <dpmi.h>
+# define PDCREGS __dpmi_regs
+# define PDCINT(vector, regs) __dpmi_int(vector, &regs)
+#else
+# ifdef __WATCOMC__
+# ifdef __386__
+# define PDCREGS pdc_dpmi_regs
+# define PDCINT(vector, regs) PDC_dpmi_int(vector, &regs)
+# else
+# define PDCREGS union REGPACK
+# define PDCINT(vector, regs) intr(vector, &regs)
+# endif
+# else
+# define PDCREGS union REGS
+# define PDCINT(vector, regs) int86(vector, &regs, &regs)
+# endif
+#endif
+
+/* Wide registers in REGS: w or x? */
+
+#ifdef __WATCOMC__
+# define W w
+#else
+# define W x
+#endif
+
+/* Monitor (terminal) type information */
+
+enum
+{
+ _NONE, _MDA, _CGA,
+ _EGACOLOR = 0x04, _EGAMONO,
+ _VGACOLOR = 0x07, _VGAMONO,
+ _MCGACOLOR = 0x0a, _MCGAMONO,
+ _MDS_GENIUS = 0x30
+};
+
+/* Text-mode font size information */
+
+enum
+{
+ _FONT8 = 8,
+ _FONT14 = 14,
+ _FONT15, /* GENIUS */
+ _FONT16
+};
+
+#ifdef __PACIFIC__
+void movedata(unsigned, unsigned, unsigned, unsigned, unsigned);
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/dos/pdcgetsc.c b/payloads/libpayload/curses/PDCurses-3.4/dos/pdcgetsc.c
new file mode 100644
index 0000000000..290db5a3c7
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/dos/pdcgetsc.c
@@ -0,0 +1,100 @@
+/* Public Domain Curses */
+
+#include "pdcdos.h"
+
+RCSID("$Id: pdcgetsc.c,v 1.42 2008/07/13 16:08:17 wmcbrine Exp $")
+
+#include <stdlib.h>
+
+/* return width of screen/viewport */
+
+int PDC_get_columns(void)
+{
+ PDCREGS regs;
+ int cols;
+ const char *env_cols;
+
+ PDC_LOG(("PDC_get_columns() - called\n"));
+
+ /* use the value from COLS environment variable, if set. MH 10-Jun-92 */
+ /* and use the minimum of COLS and return from int10h MH 18-Jun-92 */
+
+ regs.h.ah = 0x0f;
+ PDCINT(0x10, regs);
+ cols = (int)regs.h.ah;
+
+ env_cols = getenv("COLS");
+
+ if (env_cols)
+ cols = min(atoi(env_cols), cols);
+
+ PDC_LOG(("PDC_get_columns() - returned: cols %d\n", cols));
+
+ return cols;
+}
+
+/* get the cursor size/shape */
+
+int PDC_get_cursor_mode(void)
+{
+ PDC_LOG(("PDC_get_cursor_mode() - called\n"));
+
+ return getdosmemword(0x460);
+}
+
+/* return number of screen rows */
+
+int PDC_get_rows(void)
+{
+ const char *env_rows;
+ int rows;
+
+ PDC_LOG(("PDC_get_rows() - called\n"));
+
+ /* use the value from LINES environment variable, if set. MH 10-Jun-92 */
+ /* and use the minimum of LINES and *ROWS. MH 18-Jun-92 */
+
+ rows = getdosmembyte(0x484) + 1;
+ env_rows = getenv("LINES");
+
+ if (env_rows)
+ rows = min(atoi(env_rows), rows);
+
+ if (rows == 1 && pdc_adapter == _MDS_GENIUS)
+ rows = 66;
+ if (rows == 1 && pdc_adapter == _MDA)
+ rows = 25;
+
+ if (rows == 1)
+ {
+ rows = 25;
+ pdc_direct_video = FALSE;
+ }
+
+ switch (pdc_adapter)
+ {
+ case _EGACOLOR:
+ case _EGAMONO:
+ switch (rows)
+ {
+ case 25:
+ case 43:
+ break;
+ default:
+ rows = 25;
+ }
+ break;
+
+ case _VGACOLOR:
+ case _VGAMONO:
+ break;
+
+ default:
+ rows = 25;
+ break;
+ }
+
+ PDC_LOG(("PDC_get_rows() - returned: rows %d\n", rows));
+
+ return rows;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/dos/pdckbd.c b/payloads/libpayload/curses/PDCurses-3.4/dos/pdckbd.c
new file mode 100644
index 0000000000..652cb0cba7
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/dos/pdckbd.c
@@ -0,0 +1,511 @@
+/* Public Domain Curses */
+
+/* MS C doesn't return flags from int86() */
+#ifdef MSC
+# define USE_KBHIT
+#endif
+
+#ifdef USE_KBHIT
+# include <conio.h>
+#endif
+
+#include "pdcdos.h"
+
+RCSID("$Id: pdckbd.c,v 1.87 2008/07/13 16:08:17 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: pdckbd
+
+ Synopsis:
+ unsigned long PDC_get_input_fd(void);
+
+ Description:
+ PDC_get_input_fd() returns the file descriptor that PDCurses
+ reads its input from. It can be used for select().
+
+ Portability X/Open BSD SYS V
+ PDC_get_input_fd - - -
+
+**man-end****************************************************************/
+
+#ifdef __DJGPP__
+# include <fcntl.h>
+# include <io.h>
+# include <signal.h>
+#endif
+
+/************************************************************************
+ * Table for key code translation of function keys in keypad mode *
+ * These values are for strict IBM keyboard compatibles only *
+ ************************************************************************/
+
+static short key_table[] =
+{
+ -1, ALT_ESC, -1, 0,
+ -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ -1, -1, ALT_BKSP, KEY_BTAB,
+ ALT_Q, ALT_W, ALT_E, ALT_R,
+ ALT_T, ALT_Y, ALT_U, ALT_I,
+ ALT_O, ALT_P, ALT_LBRACKET, ALT_RBRACKET,
+ ALT_ENTER, -1, ALT_A, ALT_S,
+ ALT_D, ALT_F, ALT_G, ALT_H,
+ ALT_J, ALT_K, ALT_L, ALT_SEMICOLON,
+ ALT_FQUOTE, ALT_BQUOTE, -1, ALT_BSLASH,
+ ALT_Z, ALT_X, ALT_C, ALT_V,
+ ALT_B, ALT_N, ALT_M, ALT_COMMA,
+ ALT_STOP, ALT_FSLASH, -1, ALT_PADSTAR,
+ -1, -1, -1, KEY_F(1),
+ KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5),
+ KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9),
+ KEY_F(10), -1, -1, KEY_HOME,
+ KEY_UP, KEY_PPAGE, ALT_PADMINUS, KEY_LEFT,
+ KEY_B2, KEY_RIGHT, ALT_PADPLUS, KEY_END,
+ KEY_DOWN, KEY_NPAGE, KEY_IC, KEY_DC,
+ KEY_F(13), KEY_F(14), KEY_F(15), KEY_F(16),
+ KEY_F(17), KEY_F(18), KEY_F(19), KEY_F(20),
+ KEY_F(21), KEY_F(22), KEY_F(25), KEY_F(26),
+ KEY_F(27), KEY_F(28), KEY_F(29), KEY_F(30),
+ KEY_F(31), KEY_F(32), KEY_F(33), KEY_F(34),
+ KEY_F(37), KEY_F(38), KEY_F(39), KEY_F(40),
+ KEY_F(41), KEY_F(42), KEY_F(43), KEY_F(44),
+ KEY_F(45), KEY_F(46), -1, CTL_LEFT,
+ CTL_RIGHT, CTL_END, CTL_PGDN, CTL_HOME,
+ ALT_1, ALT_2, ALT_3, ALT_4,
+ ALT_5, ALT_6, ALT_7, ALT_8,
+ ALT_9, ALT_0, ALT_MINUS, ALT_EQUAL,
+ CTL_PGUP, KEY_F(11), KEY_F(12), KEY_F(23),
+ KEY_F(24), KEY_F(35), KEY_F(36), KEY_F(47),
+ KEY_F(48), CTL_UP, CTL_PADMINUS, CTL_PADCENTER,
+ CTL_PADPLUS, CTL_DOWN, CTL_INS, CTL_DEL,
+ CTL_TAB, CTL_PADSLASH, CTL_PADSTAR, ALT_HOME,
+ ALT_UP, ALT_PGUP, -1, ALT_LEFT,
+ -1, ALT_RIGHT, -1, ALT_END,
+ ALT_DOWN, ALT_PGDN, ALT_INS, ALT_DEL,
+ ALT_PADSLASH, ALT_TAB, ALT_PADENTER, -1
+};
+
+unsigned long pdc_key_modifiers = 0L;
+
+static struct {unsigned short pressed, released;} button[3];
+
+static bool mouse_avail = FALSE, mouse_vis = FALSE, mouse_moved = FALSE,
+ mouse_button = FALSE, key_pressed = FALSE;
+
+static unsigned char mouse_scroll = 0;
+static PDCREGS ms_regs, old_ms;
+static unsigned short shift_status, old_shift = 0;
+static unsigned char keyboard_function = 0xff, shift_function = 0xff,
+ check_function = 0xff;
+
+static const unsigned short button_map[3] = {0, 2, 1};
+
+unsigned long PDC_get_input_fd(void)
+{
+ PDC_LOG(("PDC_get_input_fd() - called\n"));
+
+ return (unsigned long)fileno(stdin);
+}
+
+void PDC_set_keyboard_binary(bool on)
+{
+ PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
+
+#ifdef __DJGPP__
+ setmode(fileno(stdin), on ? O_BINARY : O_TEXT);
+ signal(SIGINT, on ? SIG_IGN : SIG_DFL);
+#endif
+}
+
+/* check if a key or mouse event is waiting */
+
+bool PDC_check_key(void)
+{
+ PDCREGS regs;
+
+ if (shift_function == 0xff)
+ {
+ int scan;
+
+ /* get shift status for all keyboards */
+
+ regs.h.ah = 0x02;
+ PDCINT(0x16, regs);
+ scan = regs.h.al;
+
+ /* get shift status for enhanced keyboards */
+
+ regs.h.ah = 0x12;
+ PDCINT(0x16, regs);
+
+ if (scan == regs.h.al && getdosmembyte(0x496) == 0x10)
+ {
+ keyboard_function = 0x10;
+ check_function = 0x11;
+ shift_function = 0x12;
+ }
+ else
+ {
+ keyboard_function = 0;
+ check_function = 1;
+ shift_function = 2;
+ }
+ }
+
+ regs.h.ah = shift_function;
+ PDCINT(0x16, regs);
+
+ shift_status = regs.W.ax;
+
+ if (mouse_vis)
+ {
+ unsigned short i;
+
+ ms_regs.W.ax = 3;
+ PDCINT(0x33, ms_regs);
+
+ mouse_button = FALSE;
+
+ for (i = 0; i < 3; i++)
+ {
+ regs.W.ax = 6;
+ regs.W.bx = button_map[i];
+ PDCINT(0x33, regs);
+ button[i].released = regs.W.bx;
+ if (regs.W.bx)
+ {
+ ms_regs.W.cx = regs.W.cx;
+ ms_regs.W.dx = regs.W.dx;
+ mouse_button = TRUE;
+ }
+
+ regs.W.ax = 5;
+ regs.W.bx = button_map[i];
+ PDCINT(0x33, regs);
+ button[i].pressed = regs.W.bx;
+ if (regs.W.bx)
+ {
+ ms_regs.W.cx = regs.W.cx;
+ ms_regs.W.dx = regs.W.dx;
+ mouse_button = TRUE;
+ }
+ }
+
+ mouse_scroll = ms_regs.h.bh;
+
+ mouse_moved = !mouse_button && ms_regs.h.bl &&
+ ms_regs.h.bl == old_ms.h.bl &&
+ (((ms_regs.W.cx ^ old_ms.W.cx) >> 3) ||
+ ((ms_regs.W.dx ^ old_ms.W.dx) >> 3));
+
+ if (mouse_scroll || mouse_button || mouse_moved)
+ return TRUE;
+ }
+
+ if (old_shift && !shift_status) /* modifier released */
+ {
+ if (!key_pressed && SP->return_key_modifiers)
+ return TRUE;
+ }
+ else if (!old_shift && shift_status) /* modifier pressed */
+ key_pressed = FALSE;
+
+ old_shift = shift_status;
+
+#ifndef USE_KBHIT
+ regs.h.ah = check_function;
+ PDCINT(0x16, regs);
+
+ return !(regs.W.flags & 64);
+#else
+ return kbhit();
+#endif
+}
+
+static int _process_mouse_events(void)
+{
+ int i;
+ short shift_flags = 0;
+
+ memset(&pdc_mouse_status, 0, sizeof(pdc_mouse_status));
+
+ key_pressed = TRUE;
+ old_shift = shift_status;
+ SP->key_code = TRUE;
+
+ /* Set shift modifiers */
+
+ if (shift_status & 3)
+ shift_flags |= BUTTON_SHIFT;
+
+ if (shift_status & 4)
+ shift_flags |= BUTTON_CONTROL;
+
+ if (shift_status & 8)
+ shift_flags |= BUTTON_ALT;
+
+ /* Scroll wheel support for CuteMouse */
+
+ if (mouse_scroll)
+ {
+ pdc_mouse_status.changes = mouse_scroll & 0x80 ?
+ PDC_MOUSE_WHEEL_UP : PDC_MOUSE_WHEEL_DOWN;
+
+ pdc_mouse_status.x = -1;
+ pdc_mouse_status.y = -1;
+
+ return KEY_MOUSE;
+ }
+
+ if (mouse_moved)
+ {
+ pdc_mouse_status.changes = PDC_MOUSE_MOVED;
+
+ for (i = 0; i < 3; i++)
+ {
+ if (ms_regs.h.bl & (1 << button_map[i]))
+ {
+ pdc_mouse_status.button[i] = BUTTON_MOVED | shift_flags;
+ pdc_mouse_status.changes |= (1 << i);
+ }
+ }
+ }
+ else /* button event */
+ {
+ for (i = 0; i < 3; i++)
+ {
+ if (button[i].pressed)
+ {
+ /* Check for a click -- a PRESS followed
+ immediately by a release */
+
+ if (!button[i].released)
+ {
+ if (SP->mouse_wait)
+ {
+ PDCREGS regs;
+
+ napms(SP->mouse_wait);
+
+ regs.W.ax = 6;
+ regs.W.bx = button_map[i];
+ PDCINT(0x33, regs);
+
+ pdc_mouse_status.button[i] = regs.W.bx ?
+ BUTTON_CLICKED : BUTTON_PRESSED;
+ }
+ else
+ pdc_mouse_status.button[i] = BUTTON_PRESSED;
+ }
+ else
+ pdc_mouse_status.button[i] = BUTTON_CLICKED;
+ }
+
+ if (button[i].pressed || button[i].released)
+ {
+ pdc_mouse_status.button[i] |= shift_flags;
+ pdc_mouse_status.changes |= (1 << i);
+ }
+ }
+ }
+
+ pdc_mouse_status.x = ms_regs.W.cx >> 3;
+ pdc_mouse_status.y = ms_regs.W.dx >> 3;
+
+ old_ms = ms_regs;
+
+ return KEY_MOUSE;
+}
+
+/* return the next available key or mouse event */
+
+int PDC_get_key(void)
+{
+ PDCREGS regs;
+ int key, scan;
+
+ pdc_key_modifiers = 0;
+
+ if (mouse_vis && (mouse_scroll || mouse_button || mouse_moved))
+ return _process_mouse_events();
+
+ /* Return modifiers as keys? */
+
+ if (old_shift && !shift_status)
+ {
+ key = -1;
+
+ if (old_shift & 1)
+ key = KEY_SHIFT_R;
+
+ if (old_shift & 2)
+ key = KEY_SHIFT_L;
+
+ if (shift_function == 0x12)
+ {
+ if (old_shift & 0x400)
+ key = KEY_CONTROL_R;
+
+ if (old_shift & 0x100)
+ key = KEY_CONTROL_L;
+
+ if (old_shift & 0x800)
+ key = KEY_ALT_R;
+
+ if (old_shift & 0x200)
+ key = KEY_ALT_L;
+ }
+ else
+ {
+ if (old_shift & 4)
+ key = KEY_CONTROL_R;
+
+ if (old_shift & 8)
+ key = KEY_ALT_R;
+ }
+
+ key_pressed = FALSE;
+ old_shift = shift_status;
+
+ SP->key_code = TRUE;
+ return key;
+ }
+
+ regs.h.ah = keyboard_function;
+ PDCINT(0x16, regs);
+ key = regs.h.al;
+ scan = regs.h.ah;
+
+ if (SP->save_key_modifiers)
+ {
+ if (shift_status & 3)
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
+
+ if (shift_status & 4)
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
+
+ if (shift_status & 8)
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT;
+
+ if (shift_status & 0x20)
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
+ }
+
+ if (scan == 0x1c && key == 0x0a) /* ^Enter */
+ key = CTL_ENTER;
+ else if (scan == 0xe0 && key == 0x0d) /* PadEnter */
+ key = PADENTER;
+ else if (scan == 0xe0 && key == 0x0a) /* ^PadEnter */
+ key = CTL_PADENTER;
+ else if (scan == 0x37 && key == 0x2a) /* Star */
+ key = PADSTAR;
+ else if (scan == 0x4a && key == 0x2d) /* Minus */
+ key = PADMINUS;
+ else if (scan == 0x4e && key == 0x2b) /* Plus */
+ key = PADPLUS;
+ else if (scan == 0xe0 && key == 0x2f) /* Slash */
+ key = PADSLASH;
+ else if (key == 0x00 || (key == 0xe0 && scan > 53 && scan != 86))
+ key = (scan > 0xa7) ? -1 : key_table[scan];
+
+ if (shift_status & 3)
+ {
+ switch (key)
+ {
+ case KEY_HOME: /* Shift Home */
+ key = KEY_SHOME;
+ break;
+ case KEY_UP: /* Shift Up */
+ key = KEY_SUP;
+ break;
+ case KEY_PPAGE: /* Shift PgUp */
+ key = KEY_SPREVIOUS;
+ break;
+ case KEY_LEFT: /* Shift Left */
+ key = KEY_SLEFT;
+ break;
+ case KEY_RIGHT: /* Shift Right */
+ key = KEY_SRIGHT;
+ break;
+ case KEY_END: /* Shift End */
+ key = KEY_SEND;
+ break;
+ case KEY_DOWN: /* Shift Down */
+ key = KEY_SDOWN;
+ break;
+ case KEY_NPAGE: /* Shift PgDn */
+ key = KEY_SNEXT;
+ break;
+ case KEY_IC: /* Shift Ins */
+ key = KEY_SIC;
+ break;
+ case KEY_DC: /* Shift Del */
+ key = KEY_SDC;
+ }
+ }
+
+ key_pressed = TRUE;
+ SP->key_code = ((unsigned)key >= 256);
+
+ return key;
+}
+
+/* discard any pending keyboard or mouse input -- this is the core
+ routine for flushinp() */
+
+void PDC_flushinp(void)
+{
+ PDC_LOG(("PDC_flushinp() - called\n"));
+
+ /* Force the BIOS keyboard buffer head and tail pointers to be
+ the same... Real nasty trick... */
+
+ setdosmemword(0x41a, getdosmemword(0x41c));
+}
+
+int PDC_mouse_set(void)
+{
+ PDCREGS regs;
+ unsigned long mbe = SP->_trap_mbe;
+
+ if (mbe && !mouse_avail)
+ {
+ regs.W.ax = 0;
+ PDCINT(0x33, regs);
+
+ mouse_avail = !!(regs.W.ax);
+ }
+
+ if (mbe)
+ {
+ if (mouse_avail && !mouse_vis)
+ {
+ memset(&old_ms, 0, sizeof(old_ms));
+
+ regs.W.ax = 1;
+ PDCINT(0x33, regs);
+
+ mouse_vis = TRUE;
+ }
+ }
+ else
+ {
+ if (mouse_avail && mouse_vis)
+ {
+ regs.W.ax = 2;
+ PDCINT(0x33, regs);
+
+ mouse_vis = FALSE;
+ }
+ }
+
+ return (mouse_avail || !mbe) ? OK : ERR;
+}
+
+int PDC_modifiers_set(void)
+{
+ key_pressed = FALSE;
+
+ return OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/dos/pdcscrn.c b/payloads/libpayload/curses/PDCurses-3.4/dos/pdcscrn.c
new file mode 100644
index 0000000000..ddfb095677
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/dos/pdcscrn.c
@@ -0,0 +1,757 @@
+/* Public Domain Curses */
+
+#include "pdcdos.h"
+
+RCSID("$Id: pdcscrn.c,v 1.89 2008/07/13 16:08:17 wmcbrine Exp $")
+
+#include <stdlib.h>
+
+#ifdef CHTYPE_LONG
+# define PDC_OFFSET 32
+#else
+# define PDC_OFFSET 8
+#endif
+
+/* COLOR_PAIR to attribute encoding table. */
+
+unsigned char *pdc_atrtab = (unsigned char *)NULL;
+
+int pdc_adapter; /* screen type */
+int pdc_scrnmode; /* default screen mode */
+int pdc_font; /* default font size */
+bool pdc_direct_video; /* allow direct screen memory writes */
+bool pdc_bogus_adapter; /* TRUE if adapter has insane values */
+unsigned pdc_video_seg; /* video base segment */
+unsigned pdc_video_ofs; /* video base offset */
+
+static short curstoreal[16], realtocurs[16] =
+{
+ COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, COLOR_RED,
+ COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE, COLOR_BLACK + 8,
+ COLOR_BLUE + 8, COLOR_GREEN + 8, COLOR_CYAN + 8, COLOR_RED + 8,
+ COLOR_MAGENTA + 8, COLOR_YELLOW + 8, COLOR_WHITE + 8
+};
+
+static bool sizeable = FALSE; /* TRUE if adapter is resizeable */
+
+static unsigned short *saved_screen = NULL;
+static int saved_lines = 0;
+static int saved_cols = 0;
+
+static int saved_scrnmode[3];
+static int saved_font[3];
+
+/* Thanks to Jeff Duntemann, K16RA for providing the impetus
+ (through the Dr. Dobbs Journal, March 1989 issue) for getting
+ the routines below merged into Bjorn Larsson's PDCurses 1.3...
+ -- frotz@dri.com 900730 */
+
+/* _get_font() - Get the current font size */
+
+static int _get_font(void)
+{
+ int retval;
+
+ retval = getdosmemword(0x485);
+
+ /* Assume the MDS Genius is in 66 line mode. */
+
+ if ((retval == 0) && (pdc_adapter == _MDS_GENIUS))
+ retval = _FONT15;
+
+ switch (pdc_adapter)
+ {
+ case _MDA:
+ retval = 10; /* POINTS is not certain on MDA/Hercules */
+ break;
+
+ case _EGACOLOR:
+ case _EGAMONO:
+ switch (retval)
+ {
+ case _FONT8:
+ case _FONT14:
+ break;
+ default:
+ retval = _FONT14;
+ }
+ break;
+
+ case _CGA:
+ retval = _FONT8;
+ }
+
+ return retval;
+}
+
+/* _set_font() - Sets the current font size, if the adapter allows such a
+ change. It is an error to attempt to change the font size on a
+ "bogus" adapter. The reason for this is that we have a known video
+ adapter identity problem. e.g. Two adapters report the same identifying
+ characteristics. */
+
+static void _set_font(int size)
+{
+ PDCREGS regs;
+
+ if (pdc_bogus_adapter)
+ return;
+
+ switch (pdc_adapter)
+ {
+ case _CGA:
+ case _MDA:
+ case _MCGACOLOR:
+ case _MCGAMONO:
+ case _MDS_GENIUS:
+ break;
+
+ case _EGACOLOR:
+ case _EGAMONO:
+ if (sizeable && (pdc_font != size))
+ {
+ switch (size)
+ {
+ case _FONT8:
+ regs.W.ax = 0x1112;
+ regs.h.bl = 0x00;
+ PDCINT(0x10, regs);
+ break;
+ case _FONT14:
+ regs.W.ax = 0x1111;
+ regs.h.bl = 0x00;
+ PDCINT(0x10, regs);
+ }
+ }
+ break;
+
+ case _VGACOLOR:
+ case _VGAMONO:
+ if (sizeable && (pdc_font != size))
+ {
+ switch (size)
+ {
+ case _FONT8:
+ regs.W.ax = 0x1112;
+ regs.h.bl = 0x00;
+ PDCINT(0x10, regs);
+ break;
+ case _FONT14:
+ regs.W.ax = 0x1111;
+ regs.h.bl = 0x00;
+ PDCINT(0x10, regs);
+ break;
+ case _FONT16:
+ regs.W.ax = 0x1114;
+ regs.h.bl = 0x00;
+ PDCINT(0x10, regs);
+ }
+ }
+ }
+
+ curs_set(SP->visibility);
+
+ pdc_font = _get_font();
+}
+
+/* _set_80x25() - force a known screen state: 80x25 text mode. Forces the
+ appropriate 80x25 alpha mode given the display adapter. */
+
+static void _set_80x25(void)
+{
+ PDCREGS regs;
+
+ switch (pdc_adapter)
+ {
+ case _CGA:
+ case _EGACOLOR:
+ case _EGAMONO:
+ case _VGACOLOR:
+ case _VGAMONO:
+ case _MCGACOLOR:
+ case _MCGAMONO:
+ regs.h.ah = 0x00;
+ regs.h.al = 0x03;
+ PDCINT(0x10, regs);
+ break;
+ case _MDA:
+ regs.h.ah = 0x00;
+ regs.h.al = 0x07;
+ PDCINT(0x10, regs);
+ }
+}
+
+/* _get_scrn_mode() - Return the current BIOS video mode */
+
+static int _get_scrn_mode(void)
+{
+ PDCREGS regs;
+
+ regs.h.ah = 0x0f;
+ PDCINT(0x10, regs);
+
+ return (int)regs.h.al;
+}
+
+/* _set_scrn_mode() - Sets the BIOS Video Mode Number only if it is
+ different from the current video mode. */
+
+static void _set_scrn_mode(int new_mode)
+{
+ PDCREGS regs;
+
+ if (_get_scrn_mode() != new_mode)
+ {
+ regs.h.ah = 0;
+ regs.h.al = (unsigned char) new_mode;
+ PDCINT(0x10, regs);
+ }
+
+ pdc_font = _get_font();
+ pdc_scrnmode = new_mode;
+ LINES = PDC_get_rows();
+ COLS = PDC_get_columns();
+}
+
+/* _sanity_check() - A video adapter identification sanity check. This
+ routine will force sane values for various control flags. */
+
+static int _sanity_check(int adapter)
+{
+ int fontsize = _get_font();
+ int rows = PDC_get_rows();
+
+ PDC_LOG(("_sanity_check() - called: Adapter %d\n", adapter));
+
+ switch (adapter)
+ {
+ case _EGACOLOR:
+ case _EGAMONO:
+ switch (rows)
+ {
+ case 25:
+ case 43:
+ break;
+ default:
+ pdc_bogus_adapter = TRUE;
+ }
+
+ switch (fontsize)
+ {
+ case _FONT8:
+ case _FONT14:
+ break;
+ default:
+ pdc_bogus_adapter = TRUE;
+ }
+ break;
+
+ case _VGACOLOR:
+ case _VGAMONO:
+ break;
+
+ case _CGA:
+ case _MDA:
+ case _MCGACOLOR:
+ case _MCGAMONO:
+ switch (rows)
+ {
+ case 25:
+ break;
+ default:
+ pdc_bogus_adapter = TRUE;
+ }
+ break;
+
+ default:
+ pdc_bogus_adapter = TRUE;
+ }
+
+ if (pdc_bogus_adapter)
+ {
+ sizeable = FALSE;
+ pdc_direct_video = FALSE;
+ }
+
+ return adapter;
+}
+
+/* _query_adapter_type() - Determine PC video adapter type. */
+
+static int _query_adapter_type(void)
+{
+ PDCREGS regs;
+ int retval = _NONE;
+
+ /* thanks to paganini@ax.apc.org for the GO32 fix */
+
+#if !defined(__DJGPP__) && !defined(__WATCOMC__)
+ struct SREGS segs;
+#endif
+ short video_base = getdosmemword(0x463);
+
+ PDC_LOG(("_query_adapter_type() - called\n"));
+
+ /* attempt to call VGA Identify Adapter Function */
+
+ regs.W.ax = 0x1a00;
+ PDCINT(0x10, regs);
+
+ if ((regs.h.al == 0x1a) && (retval == _NONE))
+ {
+ /* We know that the PS/2 video BIOS is alive and well. */
+
+ switch (regs.h.al)
+ {
+ case 0:
+ retval = _NONE;
+ break;
+ case 1:
+ retval = _MDA;
+ break;
+ case 2:
+ retval = _CGA;
+ break;
+ case 4:
+ retval = _EGACOLOR;
+ sizeable = TRUE;
+ break;
+ case 5:
+ retval = _EGAMONO;
+ break;
+ case 26: /* ...alt. VGA BIOS... */
+ case 7:
+ retval = _VGACOLOR;
+ sizeable = TRUE;
+ break;
+ case 8:
+ retval = _VGAMONO;
+ break;
+ case 10:
+ case 13:
+ retval = _MCGACOLOR;
+ break;
+ case 12:
+ retval = _MCGAMONO;
+ break;
+ default:
+ retval = _CGA;
+ }
+ }
+ else
+ {
+ /* No VGA BIOS, check for an EGA BIOS by selecting an
+ Alternate Function Service...
+
+ bx == 0x0010 --> return EGA information */
+
+ regs.h.ah = 0x12;
+ regs.W.bx = 0x10;
+ PDCINT(0x10, regs);
+
+ if ((regs.h.bl != 0x10) && (retval == _NONE))
+ {
+ /* An EGA BIOS exists */
+
+ regs.h.ah = 0x12;
+ regs.h.bl = 0x10;
+ PDCINT(0x10, regs);
+
+ if (regs.h.bh == 0)
+ retval = _EGACOLOR;
+ else
+ retval = _EGAMONO;
+ }
+ else if (retval == _NONE)
+ {
+ /* Now we know we only have CGA or MDA */
+
+ PDCINT(0x11, regs);
+
+ switch (regs.h.al & 0x30)
+ {
+ case 0x10:
+ case 0x20:
+ retval = _CGA;
+ break;
+ case 0x30:
+ retval = _MDA;
+ break;
+ default:
+ retval = _NONE;
+ }
+ }
+ }
+
+ if (video_base == 0x3d4)
+ {
+ pdc_video_seg = 0xb800;
+ switch (retval)
+ {
+ case _EGAMONO:
+ retval = _EGACOLOR;
+ break;
+ case _VGAMONO:
+ retval = _VGACOLOR;
+ }
+ }
+
+ if (video_base == 0x3b4)
+ {
+ pdc_video_seg = 0xb000;
+ switch (retval)
+ {
+ case _EGACOLOR:
+ retval = _EGAMONO;
+ break;
+ case _VGACOLOR:
+ retval = _VGAMONO;
+ }
+ }
+
+ if ((retval == _NONE)
+#ifndef CGA_DIRECT
+ || (retval == _CGA)
+#endif
+ )
+ pdc_direct_video = FALSE;
+
+ if ((unsigned)pdc_video_seg == 0xb000)
+ SP->mono = TRUE;
+ else
+ SP->mono = FALSE;
+
+ /* Check for DESQview shadow buffer
+ thanks to paganini@ax.apc.org for the GO32 fix */
+
+#ifndef __WATCOMC__
+ regs.h.ah = 0xfe;
+ regs.h.al = 0;
+ regs.x.di = pdc_video_ofs;
+# ifdef __DJGPP__
+ regs.x.es = pdc_video_seg;
+ __dpmi_int(0x10, &regs);
+ pdc_video_seg = regs.x.es;
+# else
+ segs.es = pdc_video_seg;
+ int86x(0x10, &regs, &regs, &segs);
+ pdc_video_seg = segs.es;
+# endif
+ pdc_video_ofs = regs.x.di;
+#endif
+ if (!pdc_adapter)
+ pdc_adapter = retval;
+
+ return _sanity_check(retval);
+}
+
+/* close the physical screen -- may restore the screen to its state
+ before PDC_scr_open(); miscellaneous cleanup */
+
+void PDC_scr_close(void)
+{
+#if SMALL || MEDIUM
+# ifndef __PACIFIC__
+ struct SREGS segregs;
+# endif
+ int ds;
+#endif
+ PDC_LOG(("PDC_scr_close() - called\n"));
+
+ if (getenv("PDC_RESTORE_SCREEN") && saved_screen)
+ {
+#ifdef __DJGPP__
+ dosmemput(saved_screen, saved_lines * saved_cols * 2,
+ (unsigned long)_FAR_POINTER(pdc_video_seg,
+ pdc_video_ofs));
+#else
+# if (SMALL || MEDIUM)
+# ifdef __PACIFIC__
+ ds = FP_SEG((void far *)saved_screen);
+# else
+ segread(&segregs);
+ ds = segregs.ds;
+# endif
+ movedata(ds, (int)saved_screen, pdc_video_seg, pdc_video_ofs,
+ (saved_lines * saved_cols * 2));
+# else
+ memcpy((void *)_FAR_POINTER(pdc_video_seg, pdc_video_ofs),
+ (void *)saved_screen, (saved_lines * saved_cols * 2));
+# endif
+#endif
+ free(saved_screen);
+ saved_screen = NULL;
+ }
+
+ reset_shell_mode();
+
+ if (SP->visibility != 1)
+ curs_set(1);
+
+ /* Position cursor to the bottom left of the screen. */
+
+ PDC_gotoyx(PDC_get_rows() - 2, 0);
+}
+
+void PDC_scr_free(void)
+{
+ if (SP)
+ free(SP);
+ if (pdc_atrtab)
+ free(pdc_atrtab);
+
+ pdc_atrtab = (unsigned char *)NULL;
+}
+
+/* open the physical screen -- allocate SP, miscellaneous intialization,
+ and may save the existing screen for later restoration */
+
+int PDC_scr_open(int argc, char **argv)
+{
+#if SMALL || MEDIUM
+# ifndef __PACIFIC__
+ struct SREGS segregs;
+# endif
+ int ds;
+#endif
+ int i;
+
+ PDC_LOG(("PDC_scr_open() - called\n"));
+
+ SP = calloc(1, sizeof(SCREEN));
+ pdc_atrtab = calloc(PDC_COLOR_PAIRS * PDC_OFFSET, 1);
+
+ if (!SP || !pdc_atrtab)
+ return ERR;
+
+ for (i = 0; i < 16; i++)
+ curstoreal[realtocurs[i]] = i;
+
+ SP->orig_attr = FALSE;
+
+ pdc_direct_video = TRUE; /* Assume that we can */
+ pdc_video_seg = 0xb000; /* Base screen segment addr */
+ pdc_video_ofs = 0x0; /* Base screen segment ofs */
+
+ pdc_adapter = _query_adapter_type();
+ pdc_scrnmode = _get_scrn_mode();
+ pdc_font = _get_font();
+
+ SP->lines = PDC_get_rows();
+ SP->cols = PDC_get_columns();
+
+ SP->mouse_wait = PDC_CLICK_PERIOD;
+ SP->audible = TRUE;
+
+ /* If the environment variable PDCURSES_BIOS is set, the DOS int10()
+ BIOS calls are used in place of direct video memory access. */
+
+ if (getenv("PDCURSES_BIOS"))
+ pdc_direct_video = FALSE;
+
+ /* This code for preserving the current screen. */
+
+ if (getenv("PDC_RESTORE_SCREEN"))
+ {
+ saved_lines = SP->lines;
+ saved_cols = SP->cols;
+
+ saved_screen = malloc(saved_lines * saved_cols * 2);
+
+ if (!saved_screen)
+ {
+ SP->_preserve = FALSE;
+ return OK;
+ }
+#ifdef __DJGPP__
+ dosmemget((unsigned long)_FAR_POINTER(pdc_video_seg, pdc_video_ofs),
+ saved_lines * saved_cols * 2, saved_screen);
+#else
+# if SMALL || MEDIUM
+# ifdef __PACIFIC__
+ ds = FP_SEG((void far *) saved_screen);
+# else
+ segread(&segregs);
+ ds = segregs.ds;
+# endif
+ movedata(pdc_video_seg, pdc_video_ofs, ds, (int)saved_screen,
+ (saved_lines * saved_cols * 2));
+# else
+ memcpy((void *)saved_screen,
+ (void *)_FAR_POINTER(pdc_video_seg, pdc_video_ofs),
+ (saved_lines * saved_cols * 2));
+# endif
+#endif
+ }
+
+ SP->_preserve = (getenv("PDC_PRESERVE_SCREEN") != NULL);
+
+ return OK;
+}
+
+/* the core of resize_term() */
+
+int PDC_resize_screen(int nlines, int ncols)
+{
+ PDC_LOG(("PDC_resize_screen() - called. Lines: %d Cols: %d\n",
+ nlines, ncols));
+
+ /* Trash the stored value of orig_cursor -- it's only good if the
+ video mode doesn't change */
+
+ SP->orig_cursor = 0x0607;
+
+ switch (pdc_adapter)
+ {
+ case _EGACOLOR:
+ if (nlines >= 43)
+ _set_font(_FONT8);
+ else
+ _set_80x25();
+ break;
+
+ case _VGACOLOR:
+ if (nlines > 28)
+ _set_font(_FONT8);
+ else
+ if (nlines > 25)
+ _set_font(_FONT14);
+ else
+ _set_80x25();
+ }
+
+ PDC_set_blink(COLORS == 8);
+
+ return OK;
+}
+
+void PDC_reset_prog_mode(void)
+{
+ PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
+}
+
+void PDC_reset_shell_mode(void)
+{
+ PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
+}
+
+void PDC_restore_screen_mode(int i)
+{
+ if (i >= 0 && i <= 2)
+ {
+ pdc_font = _get_font();
+ _set_font(saved_font[i]);
+
+ if (_get_scrn_mode() != saved_scrnmode[i])
+ _set_scrn_mode(saved_scrnmode[i]);
+ }
+}
+
+void PDC_save_screen_mode(int i)
+{
+ if (i >= 0 && i <= 2)
+ {
+ saved_font[i] = pdc_font;
+ saved_scrnmode[i] = pdc_scrnmode;
+ }
+}
+
+void PDC_init_pair(short pair, short fg, short bg)
+{
+ unsigned char att, temp_bg;
+ chtype i;
+
+ fg = curstoreal[fg];
+ bg = curstoreal[bg];
+
+ for (i = 0; i < PDC_OFFSET; i++)
+ {
+ att = fg | (bg << 4);
+
+ if (i & (A_REVERSE >> PDC_ATTR_SHIFT))
+ att = bg | (fg << 4);
+ if (i & (A_UNDERLINE >> PDC_ATTR_SHIFT))
+ att = 1;
+ if (i & (A_INVIS >> PDC_ATTR_SHIFT))
+ {
+ temp_bg = att >> 4;
+ att = temp_bg << 4 | temp_bg;
+ }
+ if (i & (A_BOLD >> PDC_ATTR_SHIFT))
+ att |= 8;
+ if (i & (A_BLINK >> PDC_ATTR_SHIFT))
+ att |= 128;
+
+ pdc_atrtab[pair * PDC_OFFSET + i] = att;
+ }
+}
+
+int PDC_pair_content(short pair, short *fg, short *bg)
+{
+ *fg = realtocurs[pdc_atrtab[pair * PDC_OFFSET] & 0x0F];
+ *bg = realtocurs[(pdc_atrtab[pair * PDC_OFFSET] & 0xF0) >> 4];
+
+ return OK;
+}
+
+/* _egapal() - Find the EGA palette value (0-63) for the color (0-15).
+ On VGA, this is an index into the DAC. */
+
+static short _egapal(short color)
+{
+ PDCREGS regs;
+
+ regs.W.ax = 0x1007;
+ regs.h.bl = curstoreal[color];
+
+ PDCINT(0x10, regs);
+
+ return regs.h.bh;
+}
+
+bool PDC_can_change_color(void)
+{
+ return (pdc_adapter == _VGACOLOR);
+}
+
+/* These are only valid when pdc_adapter == _VGACOLOR */
+
+int PDC_color_content(short color, short *red, short *green, short *blue)
+{
+ PDCREGS regs;
+
+ /* Read single DAC register */
+
+ regs.W.ax = 0x1015;
+ regs.h.bl = _egapal(color);
+
+ PDCINT(0x10, regs);
+
+ /* Scale and store */
+
+ *red = DIVROUND((unsigned)(regs.h.dh) * 1000, 63);
+ *green = DIVROUND((unsigned)(regs.h.ch) * 1000, 63);
+ *blue = DIVROUND((unsigned)(regs.h.cl) * 1000, 63);
+
+ return OK;
+}
+
+int PDC_init_color(short color, short red, short green, short blue)
+{
+ PDCREGS regs;
+
+ /* Scale */
+
+ regs.h.dh = DIVROUND((unsigned)red * 63, 1000);
+ regs.h.ch = DIVROUND((unsigned)green * 63, 1000);
+ regs.h.cl = DIVROUND((unsigned)blue * 63, 1000);
+
+ /* Set single DAC register */
+
+ regs.W.ax = 0x1010;
+ regs.W.bx = _egapal(color);
+
+ PDCINT(0x10, regs);
+
+ return OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/dos/pdcsetsc.c b/payloads/libpayload/curses/PDCurses-3.4/dos/pdcsetsc.c
new file mode 100644
index 0000000000..2180ef486c
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/dos/pdcsetsc.c
@@ -0,0 +1,99 @@
+/* Public Domain Curses */
+
+#include "pdcdos.h"
+
+RCSID("$Id: pdcsetsc.c,v 1.39 2008/07/13 16:08:17 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: pdcsetsc
+
+ Synopsis:
+ int PDC_set_blink(bool blinkon);
+ void PDC_set_title(const char *title);
+
+ Description:
+ PDC_set_blink() toggles whether the A_BLINK attribute sets an
+ actual blink mode (TRUE), or sets the background color to high
+ intensity (FALSE). The default is platform-dependent (FALSE in
+ most cases). It returns OK if it could set the state to match
+ the given parameter, ERR otherwise. Current platforms also
+ adjust the value of COLORS according to this function -- 16 for
+ FALSE, and 8 for TRUE.
+
+ PDC_set_title() sets the title of the window in which the curses
+ program is running. This function may not do anything on some
+ platforms. (Currently it only works in Win32 and X11.)
+
+ Portability X/Open BSD SYS V
+ PDC_set_blink - - -
+ PDC_set_title - - -
+
+**man-end****************************************************************/
+
+int PDC_curs_set(int visibility)
+{
+ PDCREGS regs;
+ int ret_vis, start, end;
+
+ PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
+
+ ret_vis = SP->visibility;
+ SP->visibility = visibility;
+
+ switch (visibility)
+ {
+ case 0: /* invisible */
+ start = 32;
+ end = 0; /* was 32 */
+ break;
+ case 2: /* highly visible */
+ start = 0; /* full-height block */
+ end = 7;
+ break;
+ default: /* normal visibility */
+ start = (SP->orig_cursor >> 8) & 0xff;
+ end = SP->orig_cursor & 0xff;
+ }
+
+ /* if scrnmode is not set, some BIOSes hang */
+
+ regs.h.ah = 0x01;
+ regs.h.al = (unsigned char)pdc_scrnmode;
+ regs.h.ch = (unsigned char)start;
+ regs.h.cl = (unsigned char)end;
+ PDCINT(0x10, regs);
+
+ return ret_vis;
+}
+
+void PDC_set_title(const char *title)
+{
+ PDC_LOG(("PDC_set_title() - called: <%s>\n", title));
+}
+
+int PDC_set_blink(bool blinkon)
+{
+ PDCREGS regs;
+
+ switch (pdc_adapter)
+ {
+ case _EGACOLOR:
+ case _EGAMONO:
+ case _VGACOLOR:
+ case _VGAMONO:
+ regs.W.ax = 0x1003;
+ regs.W.bx = blinkon;
+
+ PDCINT(0x10, regs);
+
+ if (pdc_color_started)
+ COLORS = blinkon ? 8 : 16;
+
+ break;
+ default:
+ COLORS = 8;
+ }
+
+ return (COLORS - (blinkon * 8) != 8) ? OK : ERR;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/dos/pdcutil.c b/payloads/libpayload/curses/PDCurses-3.4/dos/pdcutil.c
new file mode 100644
index 0000000000..b209352a39
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/dos/pdcutil.c
@@ -0,0 +1,105 @@
+/* Public Domain Curses */
+
+#include "pdcdos.h"
+
+RCSID("$Id: pdcutil.c,v 1.24 2008/07/13 16:08:17 wmcbrine Exp $")
+
+void PDC_beep(void)
+{
+ PDCREGS regs;
+
+ PDC_LOG(("PDC_beep() - called\n"));
+
+ regs.W.ax = 0x0e07; /* Write ^G in TTY fashion */
+ regs.W.bx = 0;
+ PDCINT(0x10, regs);
+}
+
+void PDC_napms(int ms)
+{
+ PDCREGS regs;
+ long goal, start, current;
+
+ PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
+
+ goal = DIVROUND((long)ms, 50);
+ if (!goal)
+ goal++;
+
+ start = getdosmemdword(0x46c);
+
+ goal += start;
+
+ while (goal > (current = getdosmemdword(0x46c)))
+ {
+ if (current < start) /* in case of midnight reset */
+ return;
+
+ regs.W.ax = 0x1680;
+ PDCINT(0x2f, regs);
+ PDCINT(0x28, regs);
+ }
+}
+
+const char *PDC_sysname(void)
+{
+ return "DOS";
+}
+
+#ifdef __DJGPP__
+
+unsigned char getdosmembyte(int offset)
+{
+ unsigned char b;
+
+ dosmemget(offset, sizeof(unsigned char), &b);
+ return b;
+}
+
+unsigned short getdosmemword(int offset)
+{
+ unsigned short w;
+
+ dosmemget(offset, sizeof(unsigned short), &w);
+ return w;
+}
+
+unsigned long getdosmemdword(int offset)
+{
+ unsigned long dw;
+
+ dosmemget(offset, sizeof(unsigned long), &dw);
+ return dw;
+}
+
+void setdosmembyte(int offset, unsigned char b)
+{
+ dosmemput(&b, sizeof(unsigned char), offset);
+}
+
+void setdosmemword(int offset, unsigned short w)
+{
+ dosmemput(&w, sizeof(unsigned short), offset);
+}
+
+#endif
+
+#if defined(__WATCOMC__) && defined(__386__)
+
+void PDC_dpmi_int(int vector, pdc_dpmi_regs *rmregs)
+{
+ union REGPACK regs = {0};
+
+ rmregs->w.ss = 0;
+ rmregs->w.sp = 0;
+ rmregs->w.flags = 0;
+
+ regs.w.ax = 0x300;
+ regs.h.bl = vector;
+ regs.x.edi = FP_OFF(rmregs);
+ regs.x.es = FP_SEG(rmregs);
+
+ intr(0x31, &regs);
+}
+
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/dos/wccdos16.mak b/payloads/libpayload/curses/PDCurses-3.4/dos/wccdos16.mak
new file mode 100644
index 0000000000..a0cbb22327
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/dos/wccdos16.mak
@@ -0,0 +1,48 @@
+# Watcom WMAKE Makefile for PDCurses library - DOS (16 bit) Watcom C/C++ 10.6+
+#
+# Usage: wmake -f [path\]wccdos16.mak [DEBUG=Y] [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.lib|testcurs.exe...]
+
+# Change the memory MODEL here, if desired
+MODEL = l
+
+!ifdef %PDCURSES_SRCDIR
+PDCURSES_SRCDIR = $(%PDCURSES_SRCDIR)
+!else
+PDCURSES_SRCDIR = ..
+!endif
+
+!include $(PDCURSES_SRCDIR)\version.mif
+
+osdir = $(PDCURSES_SRCDIR)\dos
+
+CC = wcc
+TARGET = dos
+
+CFLAGS = /bt=$(TARGET) /zq /wx /m$(MODEL) /i=$(PDCURSES_SRCDIR)
+
+!ifeq DEBUG Y
+CFLAGS += /d2 /DPDCDEBUG
+LDFLAGS = D W A op q sys $(TARGET)
+!else
+CFLAGS += /oneatx
+LDFLAGS = op q sys $(TARGET)
+!endif
+
+LIBEXE = wlib /q /n /t
+
+!include $(PDCURSES_SRCDIR)\watcom.mif
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ %write wccdos.lrf $(LIBOBJS) $(PDCOBJS)
+ $(LIBEXE) $@ @wccdos.lrf
+ -del wccdos.lrf
+ -copy $(LIBCURSES) panel.lib
+
+PLATFORM1 = Watcom C++ 16-bit DOS
+PLATFORM2 = Open Watcom 1.6 for 16-bit DOS
+ARCNAME = pdc$(VER)16w
+
+!include $(PDCURSES_SRCDIR)\makedist.mif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/dos/wccdos4g.mak b/payloads/libpayload/curses/PDCurses-3.4/dos/wccdos4g.mak
new file mode 100644
index 0000000000..e1ba1cdeca
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/dos/wccdos4g.mak
@@ -0,0 +1,45 @@
+# Watcom WMAKE Makefile for PDCurses library - DOS/4GW Watcom C/C++ 10.6+
+#
+# Usage: wmake -f [path\]wccdos4g.mak [DEBUG=Y] [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.lib|testcurs.exe...]
+
+!ifdef %PDCURSES_SRCDIR
+PDCURSES_SRCDIR = $(%PDCURSES_SRCDIR)
+!else
+PDCURSES_SRCDIR = ..
+!endif
+
+!include $(PDCURSES_SRCDIR)\version.mif
+
+osdir = $(PDCURSES_SRCDIR)\dos
+
+CC = wcc386
+TARGET = dos4g
+
+CFLAGS = /bt=$(TARGET) /zq /wx /mf /i=$(PDCURSES_SRCDIR)
+
+!ifeq DEBUG Y
+CFLAGS += /d2 /DPDCDEBUG
+LDFLAGS = D W A op q sys $(TARGET)
+!else
+CFLAGS += /oneatx
+LDFLAGS = op q sys $(TARGET)
+!endif
+
+LIBEXE = wlib /q /n /t
+
+!include $(PDCURSES_SRCDIR)\watcom.mif
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ %write wccdos.lrf $(LIBOBJS) $(PDCOBJS)
+ $(LIBEXE) $@ @wccdos.lrf
+ -del wccdos.lrf
+ -copy $(LIBCURSES) panel.lib
+
+PLATFORM1 = Watcom C++ 32-bit DOS
+PLATFORM2 = Open Watcom 1.6 for 32-bit DOS
+ARCNAME = pdc$(VER)32w
+
+!include $(PDCURSES_SRCDIR)\makedist.mif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/exp-base.def b/payloads/libpayload/curses/PDCurses-3.4/exp-base.def
new file mode 100644
index 0000000000..222b1339ec
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/exp-base.def
@@ -0,0 +1,374 @@
+LINES
+COLS
+stdscr
+curscr
+SP
+Mouse_status
+COLORS
+COLOR_PAIRS
+TABSIZE
+acs_map
+ttytype
+addch
+addchnstr
+addchstr
+addnstr
+addstr
+attroff
+attron
+attrset
+attr_get
+attr_off
+attr_on
+attr_set
+baudrate
+beep
+bkgd
+bkgdset
+border
+box
+can_change_color
+cbreak
+chgat
+clearok
+clear
+clrtobot
+clrtoeol
+color_content
+color_set
+copywin
+curs_set
+def_prog_mode
+def_shell_mode
+delay_output
+delch
+deleteln
+delscreen
+delwin
+derwin
+doupdate
+dupwin
+echochar
+echo
+endwin
+erasechar
+erase
+filter
+flash
+flushinp
+getbkgd
+getnstr
+getstr
+getwin
+halfdelay
+has_colors
+has_ic
+has_il
+hline
+idcok
+idlok
+immedok
+inchnstr
+inchstr
+inch
+init_color
+init_pair
+initscr
+innstr
+insch
+insdelln
+insertln
+insnstr
+insstr
+instr
+intrflush
+isendwin
+is_linetouched
+is_wintouched
+keyname
+keypad
+killchar
+leaveok
+longname
+meta
+move
+mvaddch
+mvaddchnstr
+mvaddchstr
+mvaddnstr
+mvaddstr
+mvchgat
+mvcur
+mvdelch
+mvderwin
+mvgetch
+mvgetnstr
+mvgetstr
+mvhline
+mvinch
+mvinchnstr
+mvinchstr
+mvinnstr
+mvinsch
+mvinsnstr
+mvinsstr
+mvinstr
+mvprintw
+mvscanw
+mvvline
+mvwaddchnstr
+mvwaddchstr
+mvwaddch
+mvwaddnstr
+mvwaddstr
+mvwchgat
+mvwdelch
+mvwgetch
+mvwgetnstr
+mvwgetstr
+mvwhline
+mvwinchnstr
+mvwinchstr
+mvwinch
+mvwinnstr
+mvwinsch
+mvwinsnstr
+mvwinsstr
+mvwinstr
+mvwin
+mvwprintw
+mvwscanw
+mvwvline
+napms
+newpad
+newterm
+newwin
+nl
+nocbreak
+nodelay
+noecho
+nonl
+noqiflush
+noraw
+notimeout
+overlay
+overwrite
+pair_content
+pechochar
+pnoutrefresh
+prefresh
+printw
+putwin
+qiflush
+raw
+redrawwin
+refresh
+reset_prog_mode
+reset_shell_mode
+resetty
+ripoffline
+savetty
+scanw
+scr_dump
+scr_init
+scrl
+scrollok
+scroll
+scr_restore
+scr_set
+setscrreg
+setsyx
+set_term
+slk_attroff
+slk_attr_off
+slk_attron
+slk_attr_on
+slk_attrset
+slk_attr_set
+slk_clear
+slk_color
+slk_init
+slk_label
+slk_noutrefresh
+slk_refresh
+slk_restore
+slk_set
+slk_touch
+standend
+standout
+start_color
+subpad
+subwin
+syncok
+termattrs
+term_attrs
+termname
+timeout
+touchline
+touchwin
+typeahead
+untouchwin
+use_env
+vidattr
+vid_attr
+vidputs
+vid_puts
+vline
+vw_printw
+vwprintw
+vw_scanw
+vwscanw
+waddchnstr
+waddchstr
+waddch
+waddnstr
+waddstr
+wattroff
+wattron
+wattrset
+wattr_get
+wattr_off
+wattr_on
+wattr_set
+wbkgdset
+wbkgd
+wborder
+wchgat
+wclear
+wclrtobot
+wclrtoeol
+wcolor_set
+wcursyncup
+wdelch
+wdeleteln
+wechochar
+werase
+wgetch
+wgetnstr
+wgetstr
+whline
+winchnstr
+winchstr
+winch
+winnstr
+winsch
+winsdelln
+winsertln
+winsnstr
+winsstr
+winstr
+wmove
+wnoutrefresh
+wprintw
+wredrawln
+wrefresh
+wscanw
+wscrl
+wsetscrreg
+wstandend
+wstandout
+wsyncdown
+wsyncup
+wtimeout
+wtouchln
+wvline
+getattrs
+getbegx
+getbegy
+getmaxx
+getmaxy
+getparx
+getpary
+getcurx
+getcury
+traceoff
+traceon
+unctrl
+crmode
+nocrmode
+draino
+resetterm
+fixterm
+saveterm
+mouse_set
+mouse_on
+mouse_off
+request_mouse_pos
+map_button
+wmouse_position
+getmouse
+getbmap
+assume_default_colors
+curses_version
+has_key
+use_default_colors
+wresize
+mouseinterval
+mousemask
+mouse_trafo
+nc_getmouse
+ungetmouse
+wenclose
+wmouse_trafo
+addrawch
+insrawch
+is_termresized
+mvaddrawch
+mvdeleteln
+mvinsertln
+mvinsrawch
+mvwaddrawch
+mvwdeleteln
+mvwinsertln
+mvwinsrawch
+raw_output
+resize_term
+resize_window
+waddrawch
+winsrawch
+wordchar
+bottom_panel
+del_panel
+hide_panel
+move_panel
+new_panel
+panel_above
+panel_below
+panel_hidden
+panel_userptr
+panel_window
+replace_panel
+set_panel_userptr
+show_panel
+top_panel
+update_panels
+PDC_debug
+PDC_ungetch
+PDC_set_blink
+PDC_set_line_color
+PDC_set_title
+PDC_clearclipboard
+PDC_freeclipboard
+PDC_getclipboard
+PDC_setclipboard
+PDC_get_input_fd
+PDC_get_key_modifiers
+PDC_save_key_modifiers
+PDC_return_key_modifiers
+cur_term
+del_curterm
+putp
+restartterm
+set_curterm
+setterm
+setupterm
+tgetent
+tgetflag
+tgetnum
+tgetstr
+tgoto
+tigetflag
+tigetnum
+tigetstr
+tparm
+tputs
diff --git a/payloads/libpayload/curses/PDCurses-3.4/exp-wide.def b/payloads/libpayload/curses/PDCurses-3.4/exp-wide.def
new file mode 100644
index 0000000000..ebf6bc2011
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/exp-wide.def
@@ -0,0 +1,90 @@
+addnwstr
+addwstr
+add_wch
+add_wchnstr
+add_wchstr
+border_set
+box_set
+echo_wchar
+erasewchar
+getbkgrnd
+getcchar
+getn_wstr
+get_wch
+get_wstr
+hline_set
+innwstr
+ins_nwstr
+ins_wch
+ins_wstr
+inwstr
+in_wch
+in_wchnstr
+in_wchstr
+key_name
+killwchar
+mvaddnwstr
+mvaddwstr
+mvadd_wch
+mvadd_wchnstr
+mvadd_wchstr
+mvgetn_wstr
+mvget_wch
+mvget_wstr
+mvhline_set
+mvinnwstr
+mvins_nwstr
+mvins_wch
+mvins_wstr
+mvinwstr
+mvin_wch
+mvin_wchnstr
+mvin_wchstr
+mvvline_set
+mvwaddnwstr
+mvwaddwstr
+mvwadd_wch
+mvwadd_wchnstr
+mvwadd_wchstr
+mvwgetn_wstr
+mvwget_wch
+mvwget_wstr
+mvwhline_set
+mvwinnwstr
+mvwins_nwstr
+mvwins_wch
+mvwins_wstr
+mvwin_wch
+mvwin_wchnstr
+mvwin_wchstr
+mvwinwstr
+mvwvline_set
+pecho_wchar
+setcchar
+slk_wset
+unget_wch
+vline_set
+waddnwstr
+waddwstr
+wadd_wch
+wadd_wchnstr
+wadd_wchstr
+wbkgrnd
+wbkgrndset
+wborder_set
+wecho_wchar
+wgetbkgrnd
+wgetn_wstr
+wget_wch
+wget_wstr
+whline_set
+winnwstr
+wins_nwstr
+wins_wch
+wins_wstr
+winwstr
+win_wch
+win_wchnstr
+win_wchstr
+wunctrl
+wvline_set
diff --git a/payloads/libpayload/curses/PDCurses-3.4/install-sh b/payloads/libpayload/curses/PDCurses-3.4/install-sh
new file mode 100755
index 0000000000..fb9e848a7b
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/install-sh
@@ -0,0 +1,253 @@
+#! /bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission. M.I.T. makes no representations about the
+# suitability of this software for any purpose. It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch. It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+#
+# Modified 1 Feb 2000 MHES to cater for mkdir -p
+#
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+mkdircmd="$mkdirprog -p"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "install: no input file specified"
+ exit 1
+else
+ true
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d $dst ]; then
+ instcmd=:
+ else
+ instcmd=mkdir
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f $src -o -d $src ]
+ then
+ true
+ else
+ echo "install: $src does not exist"
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "install: no destination specified"
+ exit 1
+ else
+ true
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d $dst ]
+ then
+ dst="$dst"/`basename $src`
+ else
+ true
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp="${pathcomp}${1}"
+ shift
+
+ if [ ! -d "${pathcomp}" ] ;
+ then
+ $mkdircmd "${pathcomp}"
+ else
+ true
+ fi
+
+ pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd $dst &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ dstfile=`basename $dst $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ true
+ fi
+
+# Make a temp file name in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd $src $dsttmp &&
+
+ trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+ $doit $rmcmd -f $dstdir/$dstfile &&
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
+
+fi &&
+
+exit 0
diff --git a/payloads/libpayload/curses/PDCurses-3.4/libobjs.mif b/payloads/libpayload/curses/PDCurses-3.4/libobjs.mif
new file mode 100644
index 0000000000..6705323523
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/libobjs.mif
@@ -0,0 +1,26 @@
+# Common elements for most of the DOS, OS/2 and Win32
+# makefiles (not Watcom or LCC)
+
+PDCURSES_CURSES_H = $(PDCURSES_SRCDIR)/curses.h
+PDCURSES_CURSPRIV_H = $(PDCURSES_SRCDIR)/curspriv.h
+PDCURSES_HEADERS = $(PDCURSES_CURSES_H) $(PDCURSES_CURSPRIV_H)
+PANEL_HEADER = $(PDCURSES_SRCDIR)/panel.h
+TERM_HEADER = $(PDCURSES_SRCDIR)/term.h
+
+srcdir = $(PDCURSES_SRCDIR)/pdcurses
+demodir = $(PDCURSES_SRCDIR)/demos
+
+LIBOBJS = addch.$(O) addchstr.$(O) addstr.$(O) attr.$(O) beep.$(O) \
+bkgd.$(O) border.$(O) clear.$(O) color.$(O) delch.$(O) deleteln.$(O) \
+deprec.$(O) getch.$(O) getstr.$(O) getyx.$(O) inch.$(O) inchstr.$(O) \
+initscr.$(O) inopts.$(O) insch.$(O) insstr.$(O) instr.$(O) kernel.$(O) \
+keyname.$(O) mouse.$(O) move.$(O) outopts.$(O) overlay.$(O) pad.$(O) \
+panel.$(O) printw.$(O) refresh.$(O) scanw.$(O) scr_dump.$(O) scroll.$(O) \
+slk.$(O) termattr.$(O) terminfo.$(O) touch.$(O) util.$(O) window.$(O) \
+debug.$(O)
+
+PDCOBJS = pdcclip.$(O) pdcdisp.$(O) pdcgetsc.$(O) pdckbd.$(O) pdcscrn.$(O) \
+pdcsetsc.$(O) pdcutil.$(O)
+
+DEMOS = testcurs.exe newdemo.exe xmas.exe tuidemo.exe firework.exe \
+ptest.exe rain.exe worm.exe
diff --git a/payloads/libpayload/curses/PDCurses-3.4/makedist.mif b/payloads/libpayload/curses/PDCurses-3.4/makedist.mif
new file mode 100644
index 0000000000..e7495a50d3
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/makedist.mif
@@ -0,0 +1,20 @@
+# Makefile include: build a binary archive with Info-ZIP
+# under DOS, OS/2 or Win32
+
+dist: $(PDCLIBS)
+ echo PDCurses $(VERDOT) for $(PLATFORM1) > file_id.diz
+ echo ------------------------------------------ >> file_id.diz
+ echo Public Domain Curses library for >> file_id.diz
+ echo $(PLATFORM2). >> file_id.diz
+ echo Source available in PDCURS$(VER).ZIP >> file_id.diz
+ echo Public Domain. >> file_id.diz
+ echo $(PDCURSES_SRCDIR)\README > flist
+ echo $(PDCURSES_SRCDIR)\HISTORY >> flist
+ echo $(PDCURSES_SRCDIR)\curses.h >> flist
+ echo $(PDCURSES_SRCDIR)\panel.h >> flist
+ echo $(PDCURSES_SRCDIR)\term.h >> flist
+ echo $(LIBCURSES) >> flist
+ echo file_id.diz >> flist
+ zip -9jX $(ARCNAME) -@ <flist
+ del flist
+ del file_id.diz
diff --git a/payloads/libpayload/curses/PDCurses-3.4/os2/README b/payloads/libpayload/curses/PDCurses-3.4/os2/README
new file mode 100644
index 0000000000..7fde884e08
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/os2/README
@@ -0,0 +1,43 @@
+PDCurses for OS/2
+=================
+
+This directory contains PDCurses source code files specific to OS/2.
+
+
+Building
+--------
+
+. Choose the appropriate makefile for your compiler:
+
+ bccos2.mak - Borland C++ 2.0
+ gccos2.mak - EMX 0.9b+
+ iccos2.mak - C Set/2
+ wccos2.mak - Watcom 10.6+ (32-bit)
+
+. Optionally, you can build in a different directory than the platform
+ directory by setting PDCURSES_SRCDIR to point to the directory where
+ you unpacked PDCurses, and changing to your target directory:
+
+ set PDCURSES_SRCDIR=c:\pdcurses
+
+. Build it:
+
+ make -f makefilename
+
+ (For Watcom, use "wmake" instead of "make"; for MSVC or C Set/2,
+ "nmake".) You'll get the libraries (pdcurses.lib or .a, depending on
+ your compiler; and panel.lib or .a), the demos (*.exe), and a lot of
+ object files. Note that the panel library is just a copy of the main
+ library, provided for convenience; both panel and curses functions are
+ in the main library.
+
+ You can also use the optional parameter "DLL=Y" with EMX, to build the
+ library as a DLL:
+
+ make -f gccos2.mak DLL=Y
+
+
+Distribution Status
+-------------------
+
+The files in this directory are released to the Public Domain.
diff --git a/payloads/libpayload/curses/PDCurses-3.4/os2/bccos2.mak b/payloads/libpayload/curses/PDCurses-3.4/os2/bccos2.mak
new file mode 100644
index 0000000000..1c7d77a3fe
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/os2/bccos2.mak
@@ -0,0 +1,90 @@
+# Borland MAKE Makefile for PDCurses library - OS/2 BC++ 1.0+
+#
+# Usage: make -f [path\]bccos2.mak [DEBUG=] [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.lib|testcurs.exe...]
+
+O = obj
+
+!ifndef PDCURSES_SRCDIR
+PDCURSES_SRCDIR = ..
+!endif
+
+!include $(PDCURSES_SRCDIR)\version.mif
+!include $(PDCURSES_SRCDIR)\libobjs.mif
+
+osdir = $(PDCURSES_SRCDIR)\os2
+
+CC = bcc
+
+!ifdef DEBUG
+CFLAGS = -N -v -y -DPDCDEBUG
+!else
+CFLAGS = -O
+!endif
+
+CPPFLAGS = -I$(PDCURSES_SRCDIR)
+
+BUILD = $(CC) -c $(CFLAGS) $(CPPFLAGS)
+
+LINK = tlink
+
+LIBEXE = tlib /C /E
+
+LIBCURSES = pdcurses.lib
+
+all: $(LIBCURSES) $(DEMOS)
+
+clean:
+ -del *.obj
+ -del *.lib
+ -del *.exe
+
+demos: $(DEMOS)
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ -del $@
+ $(LIBEXE) $@ \
++addch.obj +addchstr.obj +addstr.obj +attr.obj +beep.obj +bkgd.obj \
++border.obj +clear.obj +color.obj +delch.obj +deleteln.obj +deprec.obj \
++getch.obj +getstr.obj +getyx.obj +inch.obj +inchstr.obj +initscr.obj \
++inopts.obj +insch.obj +insstr.obj +instr.obj +kernel.obj +keyname.obj \
++mouse.obj +move.obj +outopts.obj +overlay.obj +pad.obj +panel.obj \
++printw.obj +refresh.obj +scanw.obj +scr_dump.obj +scroll.obj +slk.obj \
++termattr.obj +terminfo.obj +touch.obj +util.obj +window.obj +debug.obj \
++pdcclip.obj +pdcdisp.obj +pdcgetsc.obj +pdckbd.obj +pdcscrn.obj \
++pdcsetsc.obj +pdcutil.obj ,lib.map
+ -copy $(LIBCURSES) panel.lib
+
+.autodepend
+
+{$(srcdir)\}.c.obj:
+ $(BUILD) $<
+
+{$(osdir)\}.c.obj:
+ $(BUILD) $<
+
+{$(demodir)\}.c.obj:
+ $(BUILD) $<
+
+.c.obj:
+ $(BUILD) $<
+
+.obj.exe:
+ $(CC) -e$@ $** $(LIBCURSES)
+
+tuidemo.exe: tuidemo.obj tui.obj $(LIBCURSES)
+ $(CC) -e$@ $**
+
+tui.obj: $(demodir)\tui.c $(demodir)\tui.h $(PDCURSES_CURSES_H)
+ $(BUILD) -I$(demodir) $(demodir)\tui.c
+
+tuidemo.obj: $(demodir)\tuidemo.c $(PDCURSES_CURSES_H)
+ $(BUILD) -I$(demodir) $(demodir)\tuidemo.c
+
+PLATFORM1 = Borland C++ OS/2 1.0
+PLATFORM2 = Borland C/C++ OS/2 1.0
+ARCNAME = pdc$(VER)bcos2
+
+!include $(PDCURSES_SRCDIR)\makedist.mif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/os2/gccos2.mak b/payloads/libpayload/curses/PDCurses-3.4/os2/gccos2.mak
new file mode 100644
index 0000000000..07d4dca411
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/os2/gccos2.mak
@@ -0,0 +1,148 @@
+# GNU MAKE Makefile for PDCurses library - OS/2 emx 0.9c+
+#
+# Usage: make -f [path\]gccos2.mak [DEBUG=Y] [EMXVIDEO=Y] [DLL=Y] [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.a|testcurs.exe...]
+#
+# The EMXVIDEO option compiles with the emx video library, which
+# enables a PDCurses program to run under OS/2 and DOS.
+
+O = o
+
+ifndef PDCURSES_SRCDIR
+ PDCURSES_SRCDIR = ..
+endif
+
+include $(PDCURSES_SRCDIR)/version.mif
+include $(PDCURSES_SRCDIR)/libobjs.mif
+
+osdir = $(PDCURSES_SRCDIR)/os2
+
+PDCURSES_OS2_H = $(osdir)/pdcos2.h
+
+CC = gcc
+
+CFLAGS = -I$(PDCURSES_SRCDIR) -c -Wall
+
+ifeq ($(EMXVIDEO),Y)
+ CFLAGS += -DEMXVIDEO
+ CCLIBS = -lvideo
+ BINDFLAGS = -acm
+else
+ CCLIBS =
+ BINDFLAGS =
+endif
+
+ifeq ($(DEBUG),Y)
+ CFLAGS += -g -DPDCDEBUG
+ LDFLAGS = -g
+else
+ CFLAGS += -O2
+ LDFLAGS =
+endif
+
+BASEDEF = $(PDCURSES_SRCDIR)\exp-base.def
+
+DEFDEPS = $(BASEDEF)
+
+DEFFILE = pdcurses.def
+
+DLLTARGET = pdcurses.dll
+DLLFLAGS = -Zdll -Zcrtdll -Zomf
+
+LINK = gcc
+EMXBIND = emxbind
+EMXOMF = emxomf
+
+LIBEXE = ar
+LIBFLAGS = rcv
+
+ifeq ($(DLL),Y)
+ CFLAGS += -Zdll -Zcrtdll -Zomf
+ LDFLAGS += -Zlinker /PM:VIO -Zomf -Zcrtdll
+ LIBCURSES = pdcurses.lib
+ LIBDEPS = $(LIBOBJS) $(PDCOBJS) $(DEFFILE)
+ PDCLIBS = $(DLLTARGET)
+ EXEPOST =
+ TUIPOST =
+ CLEAN = *.dll *.lib $(DEFFILE)
+else
+ LIBCURSES = pdcurses.a
+ LIBDEPS = $(LIBOBJS) $(PDCOBJS)
+ PDCLIBS = $(LIBCURSES)
+ EXEPOST = $(EMXBIND) $* $(BINDFLAGS)
+ TUIPOST = $(EMXBIND) tuidemo $(BINDFLAGS)
+ CLEAN = *.a testcurs newdemo xmas tuidemo firework ptest rain worm
+endif
+
+.PHONY: all libs clean demos dist
+
+all: libs demos
+
+libs: $(PDCLIBS)
+
+clean:
+ -del *.o
+ -del *.exe
+ -del $(CLEAN)
+
+demos: $(DEMOS)
+
+DEMOOBJS = testcurs.o newdemo.o xmas.o tui.o tuidemo.o firework.o \
+ptest.o rain.o worm.o
+
+$(DEFFILE) : $(DEFDEPS)
+ echo LIBRARY PDCURSES > $@
+ echo DESCRIPTION 'PDCurses 3.4 Dynamic Linking library' >> $@
+ echo PROTMODE >>$@
+ echo DATA MULTIPLE READWRITE LOADONCALL >> $@
+ echo CODE LOADONCALL >> $@
+ echo EXPORTS >> $@
+ type $(BASEDEF) >> $@
+
+$(LIBCURSES) : $(LIBDEPS)
+ $(LIBEXE) $(LIBFLAGS) $@ $?
+ -copy $(LIBCURSES) panel.a
+
+$(DLLTARGET) : $(LIBDEPS)
+ $(LINK) $(DLLFLAGS) -o $(DLLTARGET) $? $(DEFFILE)
+# lxlite $(DLLTARGET)
+ emximp -o $(LIBCURSES) $(DEFFILE)
+
+$(LIBOBJS) $(PDCOBJS) $(DEMOOBJS) : $(PDCURSES_HEADERS)
+$(PDCOBJS) : $(PDCURSES_OS2_H)
+$(DEMOS) : $(LIBCURSES)
+panel.o ptest.o: $(PANEL_HEADER)
+terminfo.o: $(TERM_HEADER)
+
+$(LIBOBJS) : %.o: $(srcdir)/%.c
+ $(CC) -c $(CFLAGS) -o$@ $<
+
+$(PDCOBJS) : %.o: $(osdir)/%.c
+ $(CC) -c $(CFLAGS) -o$@ $<
+
+firework.exe newdemo.exe rain.exe testcurs.exe worm.exe xmas.exe \
+ptest.exe: %.exe: %.o
+ $(LINK) $(LDFLAGS) -o $* $< $(LIBCURSES) $(CCLIBS)
+ $(EXEPOST)
+
+tuidemo.exe: tuidemo.o tui.o
+ $(LINK) $(LDFLAGS) -o tuidemo tuidemo.o tui.o $(LIBCURSES) $(CCLIBS)
+ $(TUIPOST)
+
+firework.o newdemo.o ptest.o rain.o testcurs.o worm.o xmas.o: %.o: \
+$(demodir)/%.c
+ $(CC) $(CFLAGS) -o$@ $<
+
+tui.o: $(demodir)\tui.c $(demodir)\tui.h
+ $(CC) $(CFLAGS) -I$(demodir) -o $@ $<
+
+tuidemo.o: $(demodir)\tuidemo.c
+ $(CC) $(CFLAGS) -I$(demodir) -o $@ $<
+
+PLATFORM1 = EMX OS/2
+PLATFORM2 = EMX 0.9d for OS/2
+ARCNAME = pdc$(VER)_emx_os2
+
+include $(PDCURSES_SRCDIR)/makedist.mif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/os2/iccos2.lrf b/payloads/libpayload/curses/PDCurses-3.4/os2/iccos2.lrf
new file mode 100644
index 0000000000..b1fdf37e99
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/os2/iccos2.lrf
@@ -0,0 +1,50 @@
+-+addch.obj &
+-+addchstr.obj &
+-+addstr.obj &
+-+attr.obj &
+-+beep.obj &
+-+bkgd.obj &
+-+border.obj &
+-+clear.obj &
+-+color.obj &
+-+delch.obj &
+-+deleteln.obj &
+-+deprec.obj &
+-+getch.obj &
+-+getstr.obj &
+-+getyx.obj &
+-+inch.obj &
+-+inchstr.obj &
+-+initscr.obj &
+-+inopts.obj &
+-+insch.obj &
+-+insstr.obj &
+-+instr.obj &
+-+kernel.obj &
+-+keyname.obj &
+-+mouse.obj &
+-+move.obj &
+-+outopts.obj &
+-+overlay.obj &
+-+pad.obj &
+-+panel.obj &
+-+printw.obj &
+-+refresh.obj &
+-+scanw.obj &
+-+scr_dump.obj &
+-+scroll.obj &
+-+slk.obj &
+-+termattr.obj &
+-+terminfo.obj &
+-+touch.obj &
+-+util.obj &
+-+window.obj &
+-+debug.obj &
+-+pdcclip.obj &
+-+pdcdisp.obj &
+-+pdcgetsc.obj &
+-+pdckbd.obj &
+-+pdcscrn.obj &
+-+pdcsetsc.obj &
+-+pdcutil.obj &
+,lib.map;
diff --git a/payloads/libpayload/curses/PDCurses-3.4/os2/iccos2.mak b/payloads/libpayload/curses/PDCurses-3.4/os2/iccos2.mak
new file mode 100644
index 0000000000..06a2c1fe8d
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/os2/iccos2.mak
@@ -0,0 +1,256 @@
+# NMAKE Makefile for PDCurses library - OS/2 C Set/2
+#
+# Usage: nmake -f [path\]iccos2.mak [DEBUG=] [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.lib|testcurs.exe...]
+
+O = obj
+
+!ifndef PDCURSES_SRCDIR
+PDCURSES_SRCDIR = ..
+!endif
+
+!include $(PDCURSES_SRCDIR)\version.mif
+!include $(PDCURSES_SRCDIR)\libobjs.mif
+
+osdir = $(PDCURSES_SRCDIR)\os2
+
+PDCURSES_OS2_H = $(osdir)\pdcos2.h
+
+CC = icc
+
+!ifdef DEBUG
+CFLAGS = /Sm /Ti+ /O- /Q+ /dPDCDEBUG
+LDFLAGS = /NOLOGO /NOE /SE:160 /DEBUG /PMTYPE:VIO
+!else
+CFLAGS = /Sm /Ti- /O+ /Q+
+LDFLAGS = /NOLOGO /NOE /EXEPACK /PACKCODE /PACKDATA /PMTYPE:VIO
+!endif
+
+CPPFLAGS = -I$(PDCURSES_SRCDIR)
+
+BUILD = $(CC) -c $(CFLAGS) $(CPPFLAGS)
+
+LINK = link386
+
+LIBEXE = lib
+
+LIBCURSES = pdcurses.lib
+
+all: $(LIBCURSES) $(DEMOS)
+
+clean:
+ -del *.obj
+ -del *.lib
+ -del *.exe
+
+demos: $(DEMOS)
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ $(LIBEXE) $@ @$(osdir)\iccos2.lrf
+ -copy $(LIBCURSES) panel.lib
+
+addch.obj: $(srcdir)\addch.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\addch.c
+
+addchstr.obj: $(srcdir)\addchstr.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\addchstr.c
+
+addstr.obj: $(srcdir)\addstr.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\addstr.c
+
+attr.obj: $(srcdir)\attr.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\attr.c
+
+beep.obj: $(srcdir)\beep.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\beep.c
+
+bkgd.obj: $(srcdir)\bkgd.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\bkgd.c
+
+border.obj: $(srcdir)\border.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\border.c
+
+clear.obj: $(srcdir)\clear.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\clear.c
+
+color.obj: $(srcdir)\color.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\color.c
+
+delch.obj: $(srcdir)\delch.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\delch.c
+
+deleteln.obj: $(srcdir)\deleteln.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\deleteln.c
+
+deprec.obj: $(srcdir)\deprec.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\deprec.c
+
+getch.obj: $(srcdir)\getch.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\getch.c
+
+getstr.obj: $(srcdir)\getstr.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\getstr.c
+
+getyx.obj: $(srcdir)\getyx.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\getyx.c
+
+inch.obj: $(srcdir)\inch.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\inch.c
+
+inchstr.obj: $(srcdir)\inchstr.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\inchstr.c
+
+initscr.obj: $(srcdir)\initscr.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\initscr.c
+
+inopts.obj: $(srcdir)\inopts.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\inopts.c
+
+insch.obj: $(srcdir)\insch.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\insch.c
+
+insstr.obj: $(srcdir)\insstr.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\insstr.c
+
+instr.obj: $(srcdir)\instr.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\instr.c
+
+kernel.obj: $(srcdir)\kernel.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\kernel.c
+
+keyname.obj: $(srcdir)\keyname.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\keyname.c
+
+mouse.obj: $(srcdir)\mouse.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\mouse.c
+
+move.obj: $(srcdir)\move.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\move.c
+
+outopts.obj: $(srcdir)\outopts.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\outopts.c
+
+overlay.obj: $(srcdir)\overlay.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\overlay.c
+
+pad.obj: $(srcdir)\pad.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\pad.c
+
+panel.obj: $(srcdir)\panel.c $(PDCURSES_HEADERS) $(PANEL_HEADER)
+ $(BUILD) $(srcdir)\panel.c
+
+printw.obj: $(srcdir)\printw.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\printw.c
+
+refresh.obj: $(srcdir)\refresh.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\refresh.c
+
+scanw.obj: $(srcdir)\scanw.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\scanw.c
+
+scr_dump.obj: $(srcdir)\scr_dump.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\scr_dump.c
+
+scroll.obj: $(srcdir)\scroll.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\scroll.c
+
+slk.obj: $(srcdir)\slk.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\slk.c
+
+termattr.obj: $(srcdir)\termattr.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\termattr.c
+
+terminfo.obj: $(srcdir)\terminfo.c $(PDCURSES_HEADERS) $(TERM_HEADER)
+ $(BUILD) $(srcdir)\terminfo.c
+
+touch.obj: $(srcdir)\touch.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\touch.c
+
+util.obj: $(srcdir)\util.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\util.c
+
+window.obj: $(srcdir)\window.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\window.c
+
+debug.obj: $(srcdir)\debug.c $(PDCURSES_HEADERS)
+ $(BUILD) $(srcdir)\debug.c
+
+pdcclip.obj: $(osdir)\pdcclip.c $(PDCURSES_HEADERS) $(PDCURSES_OS2_H)
+ $(BUILD) $(osdir)\pdcclip.c
+
+pdcdisp.obj: $(osdir)\pdcdisp.c $(PDCURSES_HEADERS) $(PDCURSES_OS2_H)
+ $(BUILD) $(osdir)\pdcdisp.c
+
+pdcgetsc.obj: $(osdir)\pdcgetsc.c $(PDCURSES_HEADERS) $(PDCURSES_OS2_H)
+ $(BUILD) $(osdir)\pdcgetsc.c
+
+pdckbd.obj: $(osdir)\pdckbd.c $(PDCURSES_HEADERS) $(PDCURSES_OS2_H)
+ $(BUILD) $(osdir)\pdckbd.c
+
+pdcscrn.obj: $(osdir)\pdcscrn.c $(PDCURSES_HEADERS) $(PDCURSES_OS2_H)
+ $(BUILD) $(osdir)\pdcscrn.c
+
+pdcsetsc.obj: $(osdir)\pdcsetsc.c $(PDCURSES_HEADERS) $(PDCURSES_OS2_H)
+ $(BUILD) $(osdir)\pdcsetsc.c
+
+pdcutil.obj: $(osdir)\pdcutil.c $(PDCURSES_HEADERS) $(PDCURSES_OS2_H)
+ $(BUILD) $(osdir)\pdcutil.c
+
+firework.exe: firework.obj $(LIBCURSES)
+ $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
+
+newdemo.exe: newdemo.obj $(LIBCURSES)
+ $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
+
+ptest.exe: ptest.obj $(LIBCURSES)
+ $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
+
+rain.exe: rain.obj $(LIBCURSES)
+ $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
+
+testcurs.exe: testcurs.obj $(LIBCURSES)
+ $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
+
+tuidemo.exe: tuidemo.obj tui.obj $(LIBCURSES)
+ $(LINK) $(LDFLAGS) $*.obj+tui.obj,$*,,$(LIBCURSES);
+
+worm.exe: worm.obj $(LIBCURSES)
+ $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
+
+xmas.exe: xmas.obj $(LIBCURSES)
+ $(LINK) $(LDFLAGS) $*.obj,$*,,$(LIBCURSES);
+
+firework.obj: $(demodir)\firework.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(demodir)\firework.c
+
+newdemo.obj: $(demodir)\newdemo.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(demodir)\newdemo.c
+
+ptest.obj: $(demodir)\ptest.c $(PANEL_HEADER) $(PDCURSES_CURSES_H)
+ $(BUILD) $(demodir)\ptest.c
+
+rain.obj: $(demodir)\rain.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(demodir)\rain.c
+
+testcurs.obj: $(demodir)\testcurs.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(demodir)\testcurs.c
+
+tui.obj: $(demodir)\tui.c $(demodir)\tui.h $(PDCURSES_CURSES_H)
+ $(BUILD) $(demodir)\tui.c
+
+tuidemo.obj: $(demodir)\tuidemo.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(demodir)\tuidemo.c
+
+worm.obj: $(demodir)\worm.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(demodir)\worm.c
+
+xmas.obj: $(demodir)\xmas.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(demodir)\xmas.c
+
+PLATFORM1 = C Set/2 OS/2
+PLATFORM2 = C Set/2 for OS/2
+ARCNAME = pdc$(VER)_icc_os2
+
+!include $(PDCURSES_SRCDIR)\makedist.mif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/os2/pdcclip.c b/payloads/libpayload/curses/PDCurses-3.4/os2/pdcclip.c
new file mode 100644
index 0000000000..ddc61d9029
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/os2/pdcclip.c
@@ -0,0 +1,185 @@
+/* Public Domain Curses */
+
+#include "pdcos2.h"
+
+RCSID("$Id: pdcclip.c,v 1.33 2008/07/14 04:24:51 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: clipboard
+
+ Synopsis:
+ int PDC_getclipboard(char **contents, long *length);
+ int PDC_setclipboard(const char *contents, long length);
+ int PDC_freeclipboard(char *contents);
+ int PDC_clearclipboard(void);
+
+ Description:
+ PDC_getclipboard() gets the textual contents of the system's
+ clipboard. This function returns the contents of the clipboard
+ in the contents argument. It is the responsibilitiy of the
+ caller to free the memory returned, via PDC_freeclipboard().
+ The length of the clipboard contents is returned in the length
+ argument.
+
+ PDC_setclipboard copies the supplied text into the system's
+ clipboard, emptying the clipboard prior to the copy.
+
+ PDC_clearclipboard() clears the internal clipboard.
+
+ Return Values:
+ indicator of success/failure of call.
+ PDC_CLIP_SUCCESS the call was successful
+ PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for
+ the clipboard contents
+ PDC_CLIP_EMPTY the clipboard contains no text
+ PDC_CLIP_ACCESS_ERROR no clipboard support
+
+ Portability X/Open BSD SYS V
+ PDC_getclipboard - - -
+ PDC_setclipboard - - -
+ PDC_freeclipboard - - -
+ PDC_clearclipboard - - -
+
+**man-end****************************************************************/
+
+int PDC_getclipboard(char **contents, long *length)
+{
+#ifndef EMXVIDEO
+ HMQ hmq;
+ HAB hab;
+ PTIB ptib;
+ PPIB ppib;
+ ULONG ulRet;
+ long len;
+ int rc;
+#endif
+ PDC_LOG(("PDC_getclipboard() - called\n"));
+
+#ifndef EMXVIDEO
+ DosGetInfoBlocks(&ptib, &ppib);
+ ppib->pib_ultype = 3;
+ hab = WinInitialize(0);
+ hmq = WinCreateMsgQueue(hab, 0);
+
+ if (!WinOpenClipbrd(hab))
+ {
+ WinDestroyMsgQueue(hmq);
+ WinTerminate(hab);
+ return PDC_CLIP_ACCESS_ERROR;
+ }
+
+ rc = PDC_CLIP_EMPTY;
+
+ ulRet = WinQueryClipbrdData(hab, CF_TEXT);
+
+ if (ulRet)
+ {
+ len = strlen((char *)ulRet);
+ *contents = malloc(len + 1);
+
+ if (!*contents)
+ rc = PDC_CLIP_MEMORY_ERROR;
+ else
+ {
+ strcpy((char *)*contents, (char *)ulRet);
+ *length = len;
+ rc = PDC_CLIP_SUCCESS;
+ }
+ }
+
+ WinCloseClipbrd(hab);
+ WinDestroyMsgQueue(hmq);
+ WinTerminate(hab);
+
+ return rc;
+#else
+ return PDC_CLIP_ACCESS_ERROR;
+#endif
+}
+
+int PDC_setclipboard(const char *contents, long length)
+{
+#ifndef EMXVIDEO
+ HAB hab;
+ PTIB ptib;
+ PPIB ppib;
+ ULONG ulRC;
+ PSZ szTextOut = NULL;
+ int rc;
+#endif
+ PDC_LOG(("PDC_setclipboard() - called\n"));
+
+#ifndef EMXVIDEO
+ DosGetInfoBlocks(&ptib, &ppib);
+ ppib->pib_ultype = 3;
+ hab = WinInitialize(0);
+
+ if (!WinOpenClipbrd(hab))
+ {
+ WinTerminate(hab);
+ return PDC_CLIP_ACCESS_ERROR;
+ }
+
+ rc = PDC_CLIP_MEMORY_ERROR;
+
+ ulRC = DosAllocSharedMem((PVOID)&szTextOut, NULL, length + 1,
+ PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE);
+
+ if (ulRC == 0)
+ {
+ strcpy(szTextOut, contents);
+ WinEmptyClipbrd(hab);
+
+ if (WinSetClipbrdData(hab, (ULONG)szTextOut, CF_TEXT, CFI_POINTER))
+ rc = PDC_CLIP_SUCCESS;
+ else
+ {
+ DosFreeMem(szTextOut);
+ rc = PDC_CLIP_ACCESS_ERROR;
+ }
+ }
+
+ WinCloseClipbrd(hab);
+ WinTerminate(hab);
+
+ return rc;
+#else
+ return PDC_CLIP_ACCESS_ERROR;
+#endif
+}
+
+int PDC_freeclipboard(char *contents)
+{
+ PDC_LOG(("PDC_freeclipboard() - called\n"));
+
+ if (contents)
+ free(contents);
+
+ return PDC_CLIP_SUCCESS;
+}
+
+int PDC_clearclipboard(void)
+{
+#ifndef EMXVIDEO
+ HAB hab;
+ PTIB ptib;
+ PPIB ppib;
+#endif
+ PDC_LOG(("PDC_clearclipboard() - called\n"));
+
+#ifndef EMXVIDEO
+ DosGetInfoBlocks(&ptib, &ppib);
+ ppib->pib_ultype = 3;
+ hab = WinInitialize(0);
+
+ WinEmptyClipbrd(hab);
+
+ WinCloseClipbrd(hab);
+ WinTerminate(hab);
+
+ return PDC_CLIP_SUCCESS;
+#else
+ return PDC_CLIP_ACCESS_ERROR;
+#endif
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/os2/pdcdisp.c b/payloads/libpayload/curses/PDCurses-3.4/os2/pdcdisp.c
new file mode 100644
index 0000000000..3c1b86e7a2
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/os2/pdcdisp.c
@@ -0,0 +1,95 @@
+/* Public Domain Curses */
+
+#include "pdcos2.h"
+
+RCSID("$Id: pdcdisp.c,v 1.49 2008/07/14 04:24:51 wmcbrine Exp $")
+
+/* ACS definitions originally by jshumate@wrdis01.robins.af.mil -- these
+ match code page 437 and compatible pages (CP850, CP852, etc.) */
+
+#ifdef CHTYPE_LONG
+
+# define A(x) ((chtype)x | A_ALTCHARSET)
+
+chtype acs_map[128] =
+{
+ A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9),
+ A(10), A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18),
+ A(19), A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27),
+ A(28), A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&',
+ '\'', '(', ')', '*',
+
+ A(0x1a), A(0x1b), A(0x18), A(0x19),
+
+ '/',
+
+ 0xdb,
+
+ '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
+ '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
+ 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
+
+ A(0x04), 0xb1,
+
+ 'b', 'c', 'd', 'e',
+
+ 0xf8, 0xf1, 0xb0, A(0x0f), 0xd9, 0xbf, 0xda, 0xc0, 0xc5, 0x2d,
+ 0x2d, 0xc4, 0x2d, 0x5f, 0xc3, 0xb4, 0xc1, 0xc2, 0xb3, 0xf3,
+ 0xf2, 0xe3, 0xd8, 0x9c, 0xf9,
+
+ A(127)
+};
+
+# undef A
+
+#endif
+
+/* position hardware cursor at (y, x) */
+
+void PDC_gotoyx(int row, int col)
+{
+ PDC_LOG(("PDC_gotoyx() - called: row %d col %d\n", row, col));
+
+#ifdef EMXVIDEO
+ v_gotoxy(col, row);
+#else
+ VioSetCurPos(row, col, 0);
+#endif
+}
+
+/* update the given physical line to look like the corresponding line in
+ curscr */
+
+void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
+{
+ /* this should be enough for the maximum width of a screen. */
+
+ struct {unsigned char text, attr;} temp_line[256];
+ int j;
+
+ PDC_LOG(("PDC_transform_line() - called: line %d\n", lineno));
+
+ /* replace the attribute part of the chtype with the
+ actual color value for each chtype in the line */
+
+ for (j = 0; j < len; j++)
+ {
+ chtype ch = srcp[j];
+
+ temp_line[j].attr = pdc_atrtab[ch >> PDC_ATTR_SHIFT];
+
+#ifdef CHTYPE_LONG
+ if (ch & A_ALTCHARSET && !(ch & 0xff80))
+ ch = acs_map[ch & 0x7f];
+#endif
+ temp_line[j].text = ch & 0xff;
+ }
+
+#ifdef EMXVIDEO
+ v_putline((char *)temp_line, x, lineno, len);
+#else
+ VioWrtCellStr((PCH)temp_line, (USHORT)(len * sizeof(unsigned short)),
+ (USHORT)lineno, (USHORT)x, 0);
+#endif
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/os2/pdcgetsc.c b/payloads/libpayload/curses/PDCurses-3.4/os2/pdcgetsc.c
new file mode 100644
index 0000000000..d712dadfa8
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/os2/pdcgetsc.c
@@ -0,0 +1,91 @@
+/* Public Domain Curses */
+
+#include "pdcos2.h"
+
+RCSID("$Id: pdcgetsc.c,v 1.39 2008/07/14 04:24:51 wmcbrine Exp $")
+
+/* return width of screen/viewport */
+
+int PDC_get_columns(void)
+{
+#ifdef EMXVIDEO
+ int rows = 0;
+#else
+ VIOMODEINFO modeInfo = {0};
+#endif
+ int cols = 0;
+ const char *env_cols;
+
+ PDC_LOG(("PDC_get_columns() - called\n"));
+
+#ifdef EMXVIDEO
+ v_dimen(&cols, &rows);
+#else
+ modeInfo.cb = sizeof(modeInfo);
+ VioGetMode(&modeInfo, 0);
+ cols = modeInfo.col;
+#endif
+ env_cols = getenv("COLS");
+
+ if (env_cols)
+ cols = min(atoi(env_cols), cols);
+
+ PDC_LOG(("PDC_get_columns() - returned: cols %d\n", cols));
+
+ return cols;
+}
+
+/* get the cursor size/shape */
+
+int PDC_get_cursor_mode(void)
+{
+#ifdef EMXVIDEO
+ int curstart = 0, curend = 0;
+#else
+ VIOCURSORINFO cursorInfo;
+#endif
+ PDC_LOG(("PDC_get_cursor_mode() - called\n"));
+
+#ifdef EMXVIDEO
+ v_getctype(&curstart, &curend);
+ return (curstart << 8) | curend;
+#else
+ VioGetCurType (&cursorInfo, 0);
+
+ return (cursorInfo.yStart << 8) | cursorInfo.cEnd;
+#endif
+}
+
+/* return number of screen rows */
+
+int PDC_get_rows(void)
+{
+#ifdef EMXVIDEO
+ int cols = 0;
+#else
+ VIOMODEINFO modeInfo = {0};
+#endif
+ int rows = 0;
+ const char *env_rows;
+
+ PDC_LOG(("PDC_get_rows() - called\n"));
+
+ /* use the value from LINES environment variable, if set. MH 10-Jun-92 */
+ /* and use the minimum of LINES and *ROWS. MH 18-Jun-92 */
+
+#ifdef EMXVIDEO
+ v_dimen(&cols, &rows);
+#else
+ modeInfo.cb = sizeof(modeInfo);
+ VioGetMode(&modeInfo, 0);
+ rows = modeInfo.row;
+#endif
+ env_rows = getenv("LINES");
+
+ if (env_rows)
+ rows = min(atoi(env_rows), rows);
+
+ PDC_LOG(("PDC_get_rows() - returned: rows %d\n", rows));
+
+ return rows;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/os2/pdckbd.c b/payloads/libpayload/curses/PDCurses-3.4/os2/pdckbd.c
new file mode 100644
index 0000000000..42c24ccd05
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/os2/pdckbd.c
@@ -0,0 +1,519 @@
+/* Public Domain Curses */
+
+#if defined(__EMX__) || defined(__WATCOMC__) || defined(__IBMC__) || \
+defined(__TURBOC__)
+# define HAVE_SIGNAL
+# include <signal.h>
+#endif
+
+#include "pdcos2.h"
+
+RCSID("$Id: pdckbd.c,v 1.89 2008/07/14 04:24:51 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: pdckbd
+
+ Synopsis:
+ unsigned long PDC_get_input_fd(void);
+
+ Description:
+ PDC_get_input_fd() returns the file descriptor that PDCurses
+ reads its input from. It can be used for select().
+
+ Portability X/Open BSD SYS V
+ PDC_get_input_fd - - -
+
+**man-end****************************************************************/
+
+#ifdef EMXVIDEO
+# include <termios.h>
+static int tahead = -1;
+#else
+static KBDINFO kbdinfo; /* default keyboard mode */
+static HMOU mouse_handle = 0;
+static MOUSE_STATUS old_mouse_status;
+static USHORT old_shift = 0;
+static bool key_pressed = FALSE;
+static int mouse_events = 0;
+#endif
+
+/************************************************************************
+ * Table for key code translation of function keys in keypad mode *
+ * These values are for strict IBM keyboard compatibles only *
+ ************************************************************************/
+
+static short key_table[] =
+{
+ -1, ALT_ESC, -1, 0,
+ -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ -1, -1, ALT_BKSP, KEY_BTAB,
+ ALT_Q, ALT_W, ALT_E, ALT_R,
+ ALT_T, ALT_Y, ALT_U, ALT_I,
+ ALT_O, ALT_P, ALT_LBRACKET, ALT_RBRACKET,
+ ALT_ENTER, -1, ALT_A, ALT_S,
+ ALT_D, ALT_F, ALT_G, ALT_H,
+ ALT_J, ALT_K, ALT_L, ALT_SEMICOLON,
+ ALT_FQUOTE, ALT_BQUOTE, -1, ALT_BSLASH,
+ ALT_Z, ALT_X, ALT_C, ALT_V,
+ ALT_B, ALT_N, ALT_M, ALT_COMMA,
+ ALT_STOP, ALT_FSLASH, -1, ALT_PADSTAR,
+ -1, -1, -1, KEY_F(1),
+ KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5),
+ KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9),
+ KEY_F(10), -1, -1, KEY_HOME,
+ KEY_UP, KEY_PPAGE, ALT_PADMINUS, KEY_LEFT,
+ KEY_B2, KEY_RIGHT, ALT_PADPLUS, KEY_END,
+ KEY_DOWN, KEY_NPAGE, KEY_IC, KEY_DC,
+ KEY_F(13), KEY_F(14), KEY_F(15), KEY_F(16),
+ KEY_F(17), KEY_F(18), KEY_F(19), KEY_F(20),
+ KEY_F(21), KEY_F(22), KEY_F(25), KEY_F(26),
+ KEY_F(27), KEY_F(28), KEY_F(29), KEY_F(30),
+ KEY_F(31), KEY_F(32), KEY_F(33), KEY_F(34),
+ KEY_F(37), KEY_F(38), KEY_F(39), KEY_F(40),
+ KEY_F(41), KEY_F(42), KEY_F(43), KEY_F(44),
+ KEY_F(45), KEY_F(46), -1, CTL_LEFT,
+ CTL_RIGHT, CTL_END, CTL_PGDN, CTL_HOME,
+ ALT_1, ALT_2, ALT_3, ALT_4,
+ ALT_5, ALT_6, ALT_7, ALT_8,
+ ALT_9, ALT_0, ALT_MINUS, ALT_EQUAL,
+ CTL_PGUP, KEY_F(11), KEY_F(12), KEY_F(23),
+ KEY_F(24), KEY_F(35), KEY_F(36), KEY_F(47),
+ KEY_F(48), CTL_UP, CTL_PADMINUS, CTL_PADCENTER,
+ CTL_PADPLUS, CTL_DOWN, CTL_INS, CTL_DEL,
+ CTL_TAB, CTL_PADSLASH, CTL_PADSTAR, ALT_HOME,
+ ALT_UP, ALT_PGUP, -1, ALT_LEFT,
+ -1, ALT_RIGHT, -1, ALT_END,
+ ALT_DOWN, ALT_PGDN, ALT_INS, ALT_DEL,
+ ALT_PADSLASH, ALT_TAB, ALT_PADENTER, -1
+};
+
+unsigned long pdc_key_modifiers = 0L;
+
+unsigned long PDC_get_input_fd(void)
+{
+ PDC_LOG(("PDC_get_input_fd() - called\n"));
+
+ return (unsigned long)fileno(stdin);
+}
+
+#ifndef EMXVIDEO
+
+void PDC_get_keyboard_info(void)
+{
+ kbdinfo.cb = sizeof(kbdinfo);
+ KbdGetStatus(&kbdinfo, 0);
+}
+
+void PDC_set_keyboard_default(void)
+{
+ KbdSetStatus(&kbdinfo, 0);
+}
+
+#endif /* ifndef EMXVIDEO */
+
+void PDC_set_keyboard_binary(bool on)
+{
+ PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
+
+#ifndef EMXVIDEO
+ if (on)
+ {
+ kbdinfo.fsMask &= ~(KEYBOARD_ASCII_MODE);
+ kbdinfo.fsMask |= KEYBOARD_BINARY_MODE;
+ }
+ else
+ {
+ kbdinfo.fsMask &= ~(KEYBOARD_BINARY_MODE);
+ kbdinfo.fsMask |= KEYBOARD_ASCII_MODE;
+ }
+
+ KbdSetStatus(&kbdinfo, 0);
+#endif
+
+#ifdef HAVE_SIGNAL
+ signal(SIGBREAK, on ? SIG_IGN : SIG_DFL);
+#endif
+}
+
+/* check if a key or mouse event is waiting */
+
+bool PDC_check_key(void)
+{
+#if !defined(_MSC_VER) && !defined(EMXVIDEO)
+ KBDKEYINFO keyInfo = {0};
+#endif
+
+#ifdef EMXVIDEO
+ if (tahead == -1) /* Nothing typed yet */
+ {
+ tahead = _read_kbd(0, 0, 0);
+
+ /* Read additional */
+
+ if (tahead == 0)
+ tahead = _read_kbd(0, 1, 0) << 8;
+ }
+
+ return (tahead != -1);
+#else
+# ifndef _MSC_VER
+
+ KbdGetStatus(&kbdinfo, 0);
+
+ if (mouse_handle)
+ {
+ MOUQUEINFO queue;
+
+ MouGetNumQueEl(&queue, mouse_handle);
+ mouse_events = queue.cEvents;
+
+ if (mouse_events)
+ return TRUE;
+ }
+
+ if (old_shift && !kbdinfo.fsState) /* modifier released */
+ {
+ if (!key_pressed && SP->return_key_modifiers)
+ return TRUE;
+ }
+ else if (!old_shift && kbdinfo.fsState) /* modifier pressed */
+ key_pressed = FALSE;
+
+ old_shift = kbdinfo.fsState;
+
+ KbdPeek(&keyInfo, 0); /* peek at keyboard */
+ return (keyInfo.fbStatus != 0);
+# else
+ return kbhit();
+# endif
+#endif
+}
+
+#ifndef EMXVIDEO
+
+static int _process_mouse_events(void)
+{
+ MOUEVENTINFO event;
+ static const USHORT button_mask[] = {6, 96, 24},
+ move_mask[] = {2, 32, 8},
+ press_mask[] = {4, 64, 16};
+ USHORT count = 1;
+ short shift_flags = 0;
+ int i;
+
+ MouReadEventQue(&event, &count, mouse_handle);
+ mouse_events--;
+
+ for (i = 0; i < 3; i++)
+ {
+ pdc_mouse_status.button[i] =
+ ((event.fs & move_mask[i]) ? BUTTON_MOVED : 0) |
+ ((event.fs & press_mask[i]) ? BUTTON_PRESSED : 0);
+
+ /* PRESS events are sometimes mistakenly reported as MOVE
+ events. A MOVE should always follow a PRESS, so treat a MOVE
+ immediately after a RELEASE as a PRESS. */
+
+ if ((pdc_mouse_status.button[i] == BUTTON_MOVED) &&
+ (old_mouse_status.button[i] == BUTTON_RELEASED))
+ {
+ pdc_mouse_status.button[i] = BUTTON_PRESSED;
+ }
+
+ if (pdc_mouse_status.button[i] == BUTTON_PRESSED && SP->mouse_wait)
+ {
+ /* Check for a click -- a PRESS followed immediately by a
+ release */
+
+ if (!mouse_events)
+ {
+ MOUQUEINFO queue;
+
+ napms(SP->mouse_wait);
+
+ MouGetNumQueEl(&queue, mouse_handle);
+ mouse_events = queue.cEvents;
+ }
+
+ if (mouse_events)
+ {
+ MouReadEventQue(&event, &count, mouse_handle);
+
+ if (!(event.fs & button_mask[i]))
+ pdc_mouse_status.button[i] = BUTTON_CLICKED;
+ }
+ }
+ }
+
+ pdc_mouse_status.x = event.col;
+ pdc_mouse_status.y = event.row;
+
+ pdc_mouse_status.changes = 0;
+
+ for (i = 0; i < 3; i++)
+ {
+ if (old_mouse_status.button[i] != pdc_mouse_status.button[i])
+ pdc_mouse_status.changes |= (1 << i);
+
+ if (pdc_mouse_status.button[i] == BUTTON_MOVED)
+ {
+ /* Discard non-moved "moves" */
+
+ if (pdc_mouse_status.x == old_mouse_status.x &&
+ pdc_mouse_status.y == old_mouse_status.y)
+ return -1;
+
+ /* Motion events always flag the button as changed */
+
+ pdc_mouse_status.changes |= (1 << i);
+ pdc_mouse_status.changes |= PDC_MOUSE_MOVED;
+ break;
+ }
+ }
+
+ old_mouse_status = pdc_mouse_status;
+
+ /* Treat click events as release events for comparison purposes */
+
+ for (i = 0; i < 3; i++)
+ {
+ if (old_mouse_status.button[i] == BUTTON_CLICKED)
+ old_mouse_status.button[i] = BUTTON_RELEASED;
+ }
+
+ /* Check for SHIFT/CONTROL/ALT */
+
+ if (kbdinfo.fsState & KBDSTF_ALT)
+ shift_flags |= BUTTON_ALT;
+
+ if (kbdinfo.fsState & KBDSTF_CONTROL)
+ shift_flags |= BUTTON_CONTROL;
+
+ if (kbdinfo.fsState & (KBDSTF_LEFTSHIFT|KBDSTF_RIGHTSHIFT))
+ shift_flags |= BUTTON_SHIFT;
+
+ if (shift_flags)
+ {
+ for (i = 0; i < 3; i++)
+ {
+ if (pdc_mouse_status.changes & (1 << i))
+ pdc_mouse_status.button[i] |= shift_flags;
+ }
+ }
+
+ old_shift = kbdinfo.fsState;
+ key_pressed = TRUE;
+
+ SP->key_code = TRUE;
+ return KEY_MOUSE;
+}
+
+#endif
+
+/* return the next available key or mouse event */
+
+int PDC_get_key(void)
+{
+ int key, scan;
+#ifndef EMXVIDEO
+ KBDKEYINFO keyInfo = {0};
+#endif
+
+#ifdef EMXVIDEO
+ if (tahead == -1)
+ {
+ tahead = _read_kbd(0, 1, 0);
+
+ /* Read additional */
+
+ if (tahead == 0)
+ tahead = _read_kbd(0, 1, 0) << 8;
+ }
+
+ key = tahead & 0xff;
+ scan = tahead >> 8;
+ pdc_key_modifiers = 0L;
+
+ tahead = -1;
+#else
+ pdc_key_modifiers = 0L;
+
+ if (mouse_handle && mouse_events)
+ return _process_mouse_events();
+
+ if (old_shift && !kbdinfo.fsState)
+ {
+ key = -1;
+
+ if (old_shift & KBDSTF_LEFTALT)
+ {
+ key = KEY_ALT_L;
+ }
+ else if (old_shift & KBDSTF_RIGHTALT)
+ {
+ key = KEY_ALT_R;
+ }
+ else if (old_shift & KBDSTF_LEFTCONTROL)
+ {
+ key = KEY_CONTROL_L;
+ }
+ else if (old_shift & KBDSTF_RIGHTCONTROL)
+ {
+ key = KEY_CONTROL_R;
+ }
+ else if (old_shift & KBDSTF_LEFTSHIFT)
+ {
+ key = KEY_SHIFT_L;
+ }
+ else if (old_shift & KBDSTF_RIGHTSHIFT)
+ {
+ key = KEY_SHIFT_R;
+ }
+
+ key_pressed = FALSE;
+ old_shift = kbdinfo.fsState;
+
+ SP->key_code = TRUE;
+ return key;
+ }
+
+ KbdCharIn(&keyInfo, IO_WAIT, 0); /* get a character */
+
+ key = keyInfo.chChar;
+ scan = keyInfo.chScan;
+
+ if (SP->save_key_modifiers)
+ {
+ if (keyInfo.fsState & KBDSTF_ALT)
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT;
+
+ if (keyInfo.fsState & KBDSTF_CONTROL)
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
+
+ if (keyInfo.fsState & KBDSTF_NUMLOCK_ON)
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
+
+ if (keyInfo.fsState & (KBDSTF_LEFTSHIFT|KBDSTF_RIGHTSHIFT))
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
+ }
+#endif
+ if (scan == 0x1c && key == 0x0a) /* ^Enter */
+ key = CTL_ENTER;
+ else if (scan == 0xe0 && key == 0x0d) /* PadEnter */
+ key = PADENTER;
+ else if (scan == 0xe0 && key == 0x0a) /* ^PadEnter */
+ key = CTL_PADENTER;
+ else if (scan == 0x37 && key == 0x2a) /* Star */
+ key = PADSTAR;
+ else if (scan == 0x4a && key == 0x2d) /* Minus */
+ key = PADMINUS;
+ else if (scan == 0x4e && key == 0x2b) /* Plus */
+ key = PADPLUS;
+ else if (scan == 0xe0 && key == 0x2f) /* Slash */
+ key = PADSLASH;
+ else if (key == 0x00 || (key == 0xe0 && scan > 53 && scan != 86))
+ key = (scan > 0xa7) ? -1 : key_table[scan];
+
+ if (keyInfo.fsState & (KBDSTF_LEFTSHIFT|KBDSTF_RIGHTSHIFT))
+ {
+ switch (key)
+ {
+ case KEY_HOME: /* Shift Home */
+ key = KEY_SHOME;
+ break;
+ case KEY_UP: /* Shift Up */
+ key = KEY_SUP;
+ break;
+ case KEY_PPAGE: /* Shift PgUp */
+ key = KEY_SPREVIOUS;
+ break;
+ case KEY_LEFT: /* Shift Left */
+ key = KEY_SLEFT;
+ break;
+ case KEY_RIGHT: /* Shift Right */
+ key = KEY_SRIGHT;
+ break;
+ case KEY_END: /* Shift End */
+ key = KEY_SEND;
+ break;
+ case KEY_DOWN: /* Shift Down */
+ key = KEY_SDOWN;
+ break;
+ case KEY_NPAGE: /* Shift PgDn */
+ key = KEY_SNEXT;
+ break;
+ case KEY_IC: /* Shift Ins */
+ key = KEY_SIC;
+ break;
+ case KEY_DC: /* Shift Del */
+ key = KEY_SDC;
+ }
+ }
+
+ key_pressed = TRUE;
+ SP->key_code = ((unsigned)key >= 256);
+
+ return key;
+}
+
+/* discard any pending keyboard or mouse input -- this is the core
+ routine for flushinp() */
+
+void PDC_flushinp(void)
+{
+ PDC_LOG(("PDC_flushinp() - called\n"));
+
+#ifdef EMXVIDEO
+ tcflush(0, TCIFLUSH);
+#else
+ if (mouse_handle)
+ MouFlushQue(mouse_handle);
+
+ KbdFlushBuffer(0);
+#endif
+}
+
+int PDC_mouse_set(void)
+{
+#ifndef EMXVIDEO
+
+ unsigned long mbe = SP->_trap_mbe;
+
+ if (mbe && !mouse_handle)
+ {
+ memset(&old_mouse_status, 0, sizeof(MOUSE_STATUS));
+ MouOpen(NULL, &mouse_handle);
+ if (mouse_handle)
+ MouDrawPtr(mouse_handle);
+ }
+ else if (!mbe && mouse_handle)
+ {
+ MouClose(mouse_handle);
+ mouse_handle = 0;
+ }
+
+ if (mbe && mouse_handle)
+ {
+ USHORT mask = ((mbe & (BUTTON1_PRESSED | BUTTON1_CLICKED |
+ BUTTON1_MOVED)) ? 6 : 0) |
+
+ ((mbe & (BUTTON3_PRESSED | BUTTON3_CLICKED |
+ BUTTON3_MOVED)) ? 24 : 0) |
+
+ ((mbe & (BUTTON2_PRESSED | BUTTON2_CLICKED |
+ BUTTON2_MOVED)) ? 96 : 0);
+
+ MouSetEventMask(&mask, mouse_handle);
+ }
+#endif
+ return OK;
+}
+
+int PDC_modifiers_set(void)
+{
+ key_pressed = FALSE;
+
+ return OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/os2/pdcos2.h b/payloads/libpayload/curses/PDCurses-3.4/os2/pdcos2.h
new file mode 100644
index 0000000000..1c11d480ed
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/os2/pdcos2.h
@@ -0,0 +1,51 @@
+/* Public Domain Curses */
+
+/* $Id: pdcos2.h,v 1.9 2008/08/14 06:38:35 wmcbrine Exp $ */
+
+#ifdef _MSC_VER
+# define USE_OS2_H 1 /* Use the os2.h for the compiler */
+# define APIRET USHORT
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef EMXVIDEO
+# include <sys/video.h>
+#else
+# define INCL_DOS
+# define INCL_DOSMISC
+# define INCL_WIN
+# define INCL_VIO
+# define INCL_KBD
+# define INCL_MOU
+# include <os2.h>
+#endif
+
+#include <curspriv.h>
+
+#ifdef __WATCOMC__
+# define PDCTHUNK(x) ((ptr_16)(x))
+# ifdef __386__
+# define SEG16 _Seg16
+# else
+# define SEG16
+# endif
+
+typedef void * SEG16 ptr_16;
+
+#else
+# ifdef __EMX__
+# ifdef __INNOTEK_LIBC__
+# define PDCTHUNK(x) ((PCH)_libc_32to16(x))
+# else
+# define PDCTHUNK(x) ((PCH)_emx_32to16(x))
+# endif
+# endif
+#endif
+
+extern unsigned char *pdc_atrtab;
+extern int pdc_font;
+
+extern void PDC_get_keyboard_info(void);
+extern void PDC_set_keyboard_default(void);
diff --git a/payloads/libpayload/curses/PDCurses-3.4/os2/pdcscrn.c b/payloads/libpayload/curses/PDCurses-3.4/os2/pdcscrn.c
new file mode 100644
index 0000000000..e2d68faa03
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/os2/pdcscrn.c
@@ -0,0 +1,422 @@
+/* Public Domain Curses */
+
+#include "pdcos2.h"
+
+RCSID("$Id: pdcscrn.c,v 1.76 2008/07/14 04:24:51 wmcbrine Exp $")
+
+#ifdef CHTYPE_LONG
+# define PDC_OFFSET 32
+#else
+# define PDC_OFFSET 8
+#endif
+
+/* COLOR_PAIR to attribute encoding table. */
+
+unsigned char *pdc_atrtab = (unsigned char *)NULL;
+
+int pdc_font; /* default font size */
+
+static short curstoreal[16], realtocurs[16] =
+{
+ COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, COLOR_RED,
+ COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE, COLOR_BLACK + 8,
+ COLOR_BLUE + 8, COLOR_GREEN + 8, COLOR_CYAN + 8, COLOR_RED + 8,
+ COLOR_MAGENTA + 8, COLOR_YELLOW + 8, COLOR_WHITE + 8
+};
+
+#ifdef EMXVIDEO
+static unsigned char *saved_screen = NULL;
+static int saved_lines = 0;
+static int saved_cols = 0;
+#else
+# ifdef PDCTHUNK
+# ifdef __EMX__
+# define THUNKEDVIO VIOCOLORREG
+# else
+
+typedef struct {
+ USHORT cb;
+ USHORT type;
+ USHORT firstcolorreg;
+ USHORT numcolorregs;
+ ptr_16 colorregaddr;
+} THUNKEDVIO;
+
+# endif
+# endif
+
+static PCH saved_screen = NULL;
+static USHORT saved_lines = 0;
+static USHORT saved_cols = 0;
+static VIOMODEINFO scrnmode; /* default screen mode */
+static VIOMODEINFO saved_scrnmode[3];
+static int saved_font[3];
+static bool can_change = FALSE;
+
+static int _get_font(void)
+{
+ VIOMODEINFO modeInfo = {0};
+
+ modeInfo.cb = sizeof(modeInfo);
+
+ VioGetMode(&modeInfo, 0);
+ return (modeInfo.vres / modeInfo.row);
+}
+
+static void _set_font(int size)
+{
+ VIOMODEINFO modeInfo = {0};
+
+ if (pdc_font != size)
+ {
+ modeInfo.cb = sizeof(modeInfo);
+
+ /* set most parameters of modeInfo */
+
+ VioGetMode(&modeInfo, 0);
+ modeInfo.cb = 8; /* ignore horiz an vert resolution */
+ modeInfo.row = modeInfo.vres / size;
+ VioSetMode(&modeInfo, 0);
+ }
+
+ curs_set(SP->visibility);
+
+ pdc_font = _get_font();
+}
+
+#endif
+
+/* close the physical screen -- may restore the screen to its state
+ before PDC_scr_open(); miscellaneous cleanup */
+
+void PDC_scr_close(void)
+{
+ PDC_LOG(("PDC_scr_close() - called\n"));
+
+ if (saved_screen && getenv("PDC_RESTORE_SCREEN"))
+ {
+#ifdef EMXVIDEO
+ v_putline(saved_screen, 0, 0, saved_lines * saved_cols);
+#else
+ VioWrtCellStr(saved_screen, saved_lines * saved_cols * 2,
+ 0, 0, (HVIO)NULL);
+#endif
+ free(saved_screen);
+ saved_screen = NULL;
+ }
+
+ reset_shell_mode();
+
+ if (SP->visibility != 1)
+ curs_set(1);
+
+ /* Position cursor to the bottom left of the screen. */
+
+ PDC_gotoyx(PDC_get_rows() - 2, 0);
+}
+
+void PDC_scr_free(void)
+{
+ if (SP)
+ free(SP);
+ if (pdc_atrtab)
+ free(pdc_atrtab);
+
+ pdc_atrtab = (unsigned char *)NULL;
+}
+
+/* open the physical screen -- allocate SP, miscellaneous intialization,
+ and may save the existing screen for later restoration */
+
+int PDC_scr_open(int argc, char **argv)
+{
+#ifdef EMXVIDEO
+ int adapter;
+#else
+ USHORT totchars;
+#endif
+ int i;
+ short r, g, b;
+
+ PDC_LOG(("PDC_scr_open() - called\n"));
+
+ SP = calloc(1, sizeof(SCREEN));
+ pdc_atrtab = calloc(PDC_COLOR_PAIRS * PDC_OFFSET, 1);
+
+ if (!SP || !pdc_atrtab)
+ return ERR;
+
+ for (i = 0; i < 16; i++)
+ curstoreal[realtocurs[i]] = i;
+
+#ifdef EMXVIDEO
+ v_init();
+#endif
+ SP->orig_attr = FALSE;
+
+#ifdef EMXVIDEO
+ adapter = v_hardware();
+ SP->mono = (adapter == V_MONOCHROME);
+
+ pdc_font = SP->mono ? 14 : (adapter == V_COLOR_8) ? 8 : 12;
+#else
+ VioGetMode(&scrnmode, 0);
+ PDC_get_keyboard_info();
+
+ pdc_font = _get_font();
+#endif
+ SP->lines = PDC_get_rows();
+ SP->cols = PDC_get_columns();
+
+ SP->mouse_wait = PDC_CLICK_PERIOD;
+ SP->audible = TRUE;
+
+ /* This code for preserving the current screen */
+
+ if (getenv("PDC_RESTORE_SCREEN"))
+ {
+ saved_lines = SP->lines;
+ saved_cols = SP->cols;
+
+ saved_screen = malloc(2 * saved_lines * saved_cols);
+
+ if (!saved_screen)
+ {
+ SP->_preserve = FALSE;
+ return OK;
+ }
+#ifdef EMXVIDEO
+ v_getline(saved_screen, 0, 0, saved_lines * saved_cols);
+#else
+ totchars = saved_lines * saved_cols * 2;
+ VioReadCellStr((PCH)saved_screen, &totchars, 0, 0, (HVIO)NULL);
+#endif
+ }
+
+ SP->_preserve = (getenv("PDC_PRESERVE_SCREEN") != NULL);
+
+ can_change = (PDC_color_content(0, &r, &g, &b) == OK);
+
+ return OK;
+}
+
+/* the core of resize_term() */
+
+int PDC_resize_screen(int nlines, int ncols)
+{
+#ifndef EMXVIDEO
+ VIOMODEINFO modeInfo = {0};
+ USHORT result;
+#endif
+
+ PDC_LOG(("PDC_resize_screen() - called. Lines: %d Cols: %d\n",
+ nlines, ncols));
+
+#ifdef EMXVIDEO
+ return ERR;
+#else
+ modeInfo.cb = sizeof(modeInfo);
+
+ /* set most parameters of modeInfo */
+
+ VioGetMode(&modeInfo, 0);
+ modeInfo.fbType = 1;
+ modeInfo.row = nlines;
+ modeInfo.col = ncols;
+ result = VioSetMode(&modeInfo, 0);
+
+ LINES = PDC_get_rows();
+ COLS = PDC_get_columns();
+
+ return (result == 0) ? OK : ERR;
+#endif
+}
+
+void PDC_reset_prog_mode(void)
+{
+ PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
+
+#ifndef EMXVIDEO
+ PDC_set_keyboard_binary(TRUE);
+#endif
+}
+
+void PDC_reset_shell_mode(void)
+{
+ PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
+
+#ifndef EMXVIDEO
+ PDC_set_keyboard_default();
+#endif
+}
+
+#ifndef EMXVIDEO
+
+static bool _screen_mode_equals(VIOMODEINFO *oldmode)
+{
+ VIOMODEINFO current = {0};
+
+ VioGetMode(&current, 0);
+
+ return ((current.cb == oldmode->cb) &&
+ (current.fbType == oldmode->fbType) &&
+ (current.color == oldmode->color) &&
+ (current.col == oldmode->col) &&
+ (current.row == oldmode->row) &&
+ (current.hres == oldmode->vres) &&
+ (current.vres == oldmode->vres));
+}
+
+#endif
+
+void PDC_restore_screen_mode(int i)
+{
+#ifndef EMXVIDEO
+ if (i >= 0 && i <= 2)
+ {
+ pdc_font = _get_font();
+ _set_font(saved_font[i]);
+
+ if (!_screen_mode_equals(&saved_scrnmode[i]))
+ if (VioSetMode(&saved_scrnmode[i], 0) != 0)
+ {
+ pdc_font = _get_font();
+ scrnmode = saved_scrnmode[i];
+ LINES = PDC_get_rows();
+ COLS = PDC_get_columns();
+ }
+ }
+#endif
+}
+
+void PDC_save_screen_mode(int i)
+{
+#ifndef EMXVIDEO
+ if (i >= 0 && i <= 2)
+ {
+ saved_font[i] = pdc_font;
+ saved_scrnmode[i] = scrnmode;
+ }
+#endif
+}
+
+void PDC_init_pair(short pair, short fg, short bg)
+{
+ unsigned char att, temp_bg;
+ chtype i;
+
+ fg = curstoreal[fg];
+ bg = curstoreal[bg];
+
+ for (i = 0; i < PDC_OFFSET; i++)
+ {
+ att = fg | (bg << 4);
+
+ if (i & (A_REVERSE >> PDC_ATTR_SHIFT))
+ att = bg | (fg << 4);
+ if (i & (A_UNDERLINE >> PDC_ATTR_SHIFT))
+ att = 1;
+ if (i & (A_INVIS >> PDC_ATTR_SHIFT))
+ {
+ temp_bg = att >> 4;
+ att = temp_bg << 4 | temp_bg;
+ }
+ if (i & (A_BOLD >> PDC_ATTR_SHIFT))
+ att |= 8;
+ if (i & (A_BLINK >> PDC_ATTR_SHIFT))
+ att |= 128;
+
+ pdc_atrtab[pair * PDC_OFFSET + i] = att;
+ }
+}
+
+int PDC_pair_content(short pair, short *fg, short *bg)
+{
+ *fg = realtocurs[pdc_atrtab[pair * PDC_OFFSET] & 0x0F];
+ *bg = realtocurs[(pdc_atrtab[pair * PDC_OFFSET] & 0xF0) >> 4];
+
+ return OK;
+}
+
+bool PDC_can_change_color(void)
+{
+ return can_change;
+}
+
+int PDC_color_content(short color, short *red, short *green, short *blue)
+{
+#ifdef PDCTHUNK
+ THUNKEDVIO vcr;
+ USHORT palbuf[4];
+ unsigned char pal[3];
+ int rc;
+
+ /* Read single DAC register */
+
+ palbuf[0] = 8;
+ palbuf[1] = 0;
+ palbuf[2] = curstoreal[color];
+
+ rc = VioGetState(&palbuf, 0);
+ if (rc)
+ return ERR;
+
+ vcr.cb = sizeof(vcr);
+ vcr.type = 3;
+ vcr.firstcolorreg = palbuf[3];
+ vcr.numcolorregs = 1;
+ vcr.colorregaddr = PDCTHUNK(pal);
+
+ rc = VioGetState(&vcr, 0);
+ if (rc)
+ return ERR;
+
+ /* Scale and store */
+
+ *red = DIVROUND((unsigned)(pal[0]) * 1000, 63);
+ *green = DIVROUND((unsigned)(pal[1]) * 1000, 63);
+ *blue = DIVROUND((unsigned)(pal[2]) * 1000, 63);
+
+ return OK;
+#else
+ return ERR;
+#endif
+}
+
+int PDC_init_color(short color, short red, short green, short blue)
+{
+#ifdef PDCTHUNK
+ THUNKEDVIO vcr;
+ USHORT palbuf[4];
+ unsigned char pal[3];
+ int rc;
+
+ /* Scale */
+
+ pal[0] = DIVROUND((unsigned)red * 63, 1000);
+ pal[1] = DIVROUND((unsigned)green * 63, 1000);
+ pal[2] = DIVROUND((unsigned)blue * 63, 1000);
+
+ /* Set single DAC register */
+
+ palbuf[0] = 8;
+ palbuf[1] = 0;
+ palbuf[2] = curstoreal[color];
+
+ rc = VioGetState(&palbuf, 0);
+ if (rc)
+ return ERR;
+
+ vcr.cb = sizeof(vcr);
+ vcr.type = 3;
+ vcr.firstcolorreg = palbuf[3];
+ vcr.numcolorregs = 1;
+ vcr.colorregaddr = PDCTHUNK(pal);
+
+ rc = VioSetState(&vcr, 0);
+
+ return rc ? ERR : OK;
+#else
+ return ERR;
+#endif
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/os2/pdcsetsc.c b/payloads/libpayload/curses/PDCurses-3.4/os2/pdcsetsc.c
new file mode 100644
index 0000000000..2a770bd237
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/os2/pdcsetsc.c
@@ -0,0 +1,110 @@
+/* Public Domain Curses */
+
+#include "pdcos2.h"
+
+RCSID("$Id: pdcsetsc.c,v 1.44 2008/07/14 04:24:51 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: pdcsetsc
+
+ Synopsis:
+ int PDC_set_blink(bool blinkon);
+ void PDC_set_title(const char *title);
+
+ Description:
+ PDC_set_blink() toggles whether the A_BLINK attribute sets an
+ actual blink mode (TRUE), or sets the background color to high
+ intensity (FALSE). The default is platform-dependent (FALSE in
+ most cases). It returns OK if it could set the state to match
+ the given parameter, ERR otherwise. Current platforms also
+ adjust the value of COLORS according to this function -- 16 for
+ FALSE, and 8 for TRUE.
+
+ PDC_set_title() sets the title of the window in which the curses
+ program is running. This function may not do anything on some
+ platforms. (Currently it only works in Win32 and X11.)
+
+ Portability X/Open BSD SYS V
+ PDC_set_blink - - -
+ PDC_set_title - - -
+
+**man-end****************************************************************/
+
+int PDC_curs_set(int visibility)
+{
+#ifndef EMXVIDEO
+ VIOCURSORINFO pvioCursorInfo;
+#endif
+ int ret_vis, hidden = 0, start = 0, end = 0;
+
+ PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
+
+ ret_vis = SP->visibility;
+ SP->visibility = visibility;
+
+ switch(visibility)
+ {
+ case 0: /* invisible */
+#ifdef EMXVIDEO
+ start = end = 0;
+#else
+ start = pdc_font / 4;
+ end = pdc_font;
+ hidden = -1;
+#endif
+ break;
+
+ case 2: /* highly visible */
+ start = 2; /* almost full-height block */
+ end = pdc_font - 1;
+ break;
+
+ default: /* normal visibility */
+ start = (SP->orig_cursor >> 8) & 0xff;
+ end = SP->orig_cursor & 0xff;
+ }
+
+#ifdef EMXVIDEO
+ if (!visibility)
+ v_hidecursor();
+ else
+ v_ctype(start, end);
+#else
+ pvioCursorInfo.yStart = (USHORT)start;
+ pvioCursorInfo.cEnd = (USHORT)end;
+ pvioCursorInfo.cx = (USHORT)1;
+ pvioCursorInfo.attr = hidden;
+ VioSetCurType((PVIOCURSORINFO)&pvioCursorInfo, 0);
+#endif
+ return ret_vis;
+}
+
+void PDC_set_title(const char *title)
+{
+ PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
+}
+
+int PDC_set_blink(bool blinkon)
+{
+#ifndef EMXVIDEO
+ USHORT statebuf[3], result;
+
+ statebuf[0] = 6; /* length */
+ statebuf[1] = 2; /* blink/intensity */
+ statebuf[2] = !blinkon;
+
+ result = VioSetState(&statebuf, 0);
+ VioGetState(&statebuf, 0); /* needed? */
+
+ if (pdc_color_started)
+ COLORS = statebuf[2] ? 16 : 8;
+
+ return (result == 0) ? OK : ERR;
+#else
+ if (pdc_color_started)
+ COLORS = 16;
+
+ return blinkon ? ERR : OK;
+#endif
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/os2/pdcutil.c b/payloads/libpayload/curses/PDCurses-3.4/os2/pdcutil.c
new file mode 100644
index 0000000000..290be3595f
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/os2/pdcutil.c
@@ -0,0 +1,36 @@
+/* Public Domain Curses */
+
+#include "pdcos2.h"
+
+RCSID("$Id: pdcutil.c,v 1.14 2008/07/14 04:24:51 wmcbrine Exp $")
+
+#if defined(OS2) && !defined(__EMX__)
+APIRET APIENTRY DosSleep(ULONG ulTime);
+#endif
+
+void PDC_beep(void)
+{
+ PDC_LOG(("PDC_beep() - called\n"));
+
+#ifdef EMXVIDEO
+ putchar('\007');
+#else
+ DosBeep(1380, 100);
+#endif
+}
+
+void PDC_napms(int ms)
+{
+ PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
+
+#ifdef __EMX__
+ _sleep2(ms);
+#else
+ DosSleep(ms);
+#endif
+}
+
+const char *PDC_sysname(void)
+{
+ return "OS/2";
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/os2/wccos2.mak b/payloads/libpayload/curses/PDCurses-3.4/os2/wccos2.mak
new file mode 100644
index 0000000000..d5900d3055
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/os2/wccos2.mak
@@ -0,0 +1,43 @@
+# Watcom WMAKE Makefile for PDCurses library - OS/2 Open Watcom 1.1+
+#
+# Usage: wmake -f [path\]wccos2.mak [DEBUG=Y] [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.lib|testcurs.exe...]
+
+!ifdef %PDCURSES_SRCDIR
+PDCURSES_SRCDIR = $(%PDCURSES_SRCDIR)
+!else
+PDCURSES_SRCDIR = ..
+!endif
+
+!include $(PDCURSES_SRCDIR)\version.mif
+
+osdir = $(PDCURSES_SRCDIR)\os2
+
+CC = wcc386
+TARGET = os2v2
+
+CFLAGS = /bt=$(TARGET) /wx /s /zq /i=$(PDCURSES_SRCDIR)
+
+!ifeq DEBUG Y
+CFLAGS += /d2 /DPDCDEBUG
+LDFLAGS = D A op q sys $(TARGET)
+!else
+CFLAGS += /oneatx
+LDFLAGS = op q sys $(TARGET)
+!endif
+
+LIBEXE = wlib /q /n /b /c /t
+
+!include $(PDCURSES_SRCDIR)\watcom.mif
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ $(LIBEXE) $@ $(LIBOBJS) $(PDCOBJS)
+ -copy $(LIBCURSES) panel.lib
+
+PLATFORM1 = Watcom C++ OS/2
+PLATFORM2 = Open Watcom 1.6 for OS/2
+ARCNAME = pdc$(VER)_wcc_os2
+
+!include $(PDCURSES_SRCDIR)\makedist.mif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/panel.h b/payloads/libpayload/curses/PDCurses-3.4/panel.h
new file mode 100644
index 0000000000..1d7cacef94
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/panel.h
@@ -0,0 +1,58 @@
+/* Public Domain Curses */
+
+/* $Id: panel.h,v 1.19 2008/07/13 16:08:16 wmcbrine Exp $ */
+
+/*----------------------------------------------------------------------*
+ * Panels for PDCurses *
+ *----------------------------------------------------------------------*/
+
+#ifndef __PDCURSES_PANEL_H__
+#define __PDCURSES_PANEL_H__ 1
+
+#include <curses.h>
+
+#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
+extern "C"
+{
+#endif
+
+typedef struct panelobs
+{
+ struct panelobs *above;
+ struct panel *pan;
+} PANELOBS;
+
+typedef struct panel
+{
+ WINDOW *win;
+ int wstarty;
+ int wendy;
+ int wstartx;
+ int wendx;
+ struct panel *below;
+ struct panel *above;
+ const void *user;
+ struct panelobs *obscure;
+} PANEL;
+
+int bottom_panel(PANEL *pan);
+int del_panel(PANEL *pan);
+int hide_panel(PANEL *pan);
+int move_panel(PANEL *pan, int starty, int startx);
+PANEL *new_panel(WINDOW *win);
+PANEL *panel_above(const PANEL *pan);
+PANEL *panel_below(const PANEL *pan);
+int panel_hidden(const PANEL *pan);
+const void *panel_userptr(const PANEL *pan);
+WINDOW *panel_window(const PANEL *pan);
+int replace_panel(PANEL *pan, WINDOW *win);
+int set_panel_userptr(PANEL *pan, const void *uptr);
+int show_panel(PANEL *pan);
+int top_panel(PANEL *pan);
+void update_panels(void);
+
+#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
+}
+#endif
+
+#endif /* __PDCURSES_PANEL_H__ */
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/README b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/README
new file mode 100644
index 0000000000..bef1c4c469
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/README
@@ -0,0 +1,25 @@
+PDCurses Portable Core
+======================
+
+This directory contains core PDCurses source code files common to all
+platforms.
+
+
+Building
+--------
+
+These modules are built by the platform-specific makefiles, in the
+platform directories.
+
+
+Distribution Status
+-------------------
+
+The files in this directory are released to the Public Domain.
+
+
+Acknowledgements
+----------------
+
+The panel library was originally provided by
+Warren Tucker <wht@n4hgf.mt-park.ga.us>
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/addch.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/addch.c
new file mode 100644
index 0000000000..586d1a71fa
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/addch.c
@@ -0,0 +1,408 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: addch.c,v 1.54 2008/07/13 16:08:17 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: addch
+
+ Synopsis:
+ int addch(const chtype ch);
+ int waddch(WINDOW *win, const chtype ch);
+ int mvaddch(int y, int x, const chtype ch);
+ int mvwaddch(WINDOW *win, int y, int x, const chtype ch);
+ int echochar(const chtype ch);
+ int wechochar(WINDOW *win, const chtype ch);
+
+ int addrawch(chtype ch);
+ int waddrawch(WINDOW *win, chtype ch);
+ int mvaddrawch(int y, int x, chtype ch);
+ int mvwaddrawch(WINDOW *win, int y, int x, chtype ch);
+
+ int add_wch(const cchar_t *wch);
+ int wadd_wch(WINDOW *win, const cchar_t *wch);
+ int mvadd_wch(int y, int x, const cchar_t *wch);
+ int mvwadd_wch(WINDOW *win, int y, int x, const cchar_t *wch);
+ int echo_wchar(const cchar_t *wch);
+ int wecho_wchar(WINDOW *win, const cchar_t *wch);
+
+ Description:
+ addch() adds the chtype ch to the default window (stdscr) at the
+ current cursor position, and advances the cursor. Note that
+ chtypes can convey both text (a single character) and
+ attributes, including a color pair. add_wch() is the wide-
+ character version of this function, taking a pointer to a
+ cchar_t instead of a chtype.
+
+ waddch() is like addch(), but also lets you specify the window.
+ (This is in fact the core output routine.) wadd_wch() is the
+ wide version.
+
+ mvaddch() moves the cursor to the specified (y, x) position, and
+ adds ch to stdscr. mvadd_wch() is the wide version.
+
+ mvwaddch() moves the cursor to the specified position and adds
+ ch to the specified window. mvwadd_wch() is the wide version.
+
+ echochar() adds ch to stdscr at the current cursor position and
+ calls refresh(). echo_wchar() is the wide version.
+
+ wechochar() adds ch to the specified window and calls
+ wrefresh(). wecho_wchar() is the wide version.
+
+ addrawch(), waddrawch(), mvaddrawch() and mvwaddrawch() are
+ PDCurses-specific wrappers for addch() etc. that disable the
+ translation of control characters.
+
+ The following applies to all these functions:
+
+ If the cursor moves on to the right margin, an automatic newline
+ is performed. If scrollok is enabled, and a character is added
+ to the bottom right corner of the window, the scrolling region
+ will be scrolled up one line. If scrolling is not allowed, ERR
+ will be returned.
+
+ If ch is a tab, newline, or backspace, the cursor will be moved
+ appropriately within the window. If ch is a newline, the
+ clrtoeol routine is called before the cursor is moved to the
+ beginning of the next line. If newline mapping is off, the
+ cursor will be moved to the next line, but the x coordinate will
+ be unchanged. If ch is a tab the cursor is moved to the next
+ tab position within the window. If ch is another control
+ character, it will be drawn in the ^X notation. Calling the
+ inch() routine after adding a control character returns the
+ representation of the control character, not the control
+ character.
+
+ Video attributes can be combined with a character by ORing them
+ into the parameter. Text, including attributes, can be copied
+ from one place to another by using inch() and addch().
+
+ Note that in PDCurses, for now, a cchar_t and a chtype are the
+ same. The text field is 16 bits wide, and is treated as Unicode
+ (UCS-2) when PDCurses is built with wide-character support
+ (define PDC_WIDE). So, in functions that take a chtype, like
+ addch(), both the wide and narrow versions will handle Unicode.
+ But for portability, you should use the wide functions.
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ addch Y Y Y
+ waddch Y Y Y
+ mvaddch Y Y Y
+ mvwaddch Y Y Y
+ echochar Y - 3.0
+ wechochar Y - 3.0
+ addrawch - - -
+ waddrawch - - -
+ mvaddrawch - - -
+ mvwaddrawch - - -
+ add_wch Y
+ wadd_wch Y
+ mvadd_wch Y
+ mvwadd_wch Y
+ echo_wchar Y
+ wecho_wchar Y
+
+**man-end****************************************************************/
+
+int waddch(WINDOW *win, const chtype ch)
+{
+ int x, y;
+ chtype text, attr;
+ bool xlat;
+
+ PDC_LOG(("waddch() - called: win=%p ch=%x (text=%c attr=0x%x)\n",
+ win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES));
+
+ if (!win)
+ return ERR;
+
+ x = win->_curx;
+ y = win->_cury;
+
+ if (y > win->_maxy || x > win->_maxx || y < 0 || x < 0)
+ return ERR;
+
+ xlat = !SP->raw_out && !(ch & A_ALTCHARSET);
+ text = ch & A_CHARTEXT;
+ attr = ch & A_ATTRIBUTES;
+
+ if (xlat && (text < ' ' || text == 0x7f))
+ {
+ int x2;
+
+ switch (text)
+ {
+ case '\t':
+ for (x2 = ((x / TABSIZE) + 1) * TABSIZE; x < x2; x++)
+ {
+ if (waddch(win, attr | ' ') == ERR)
+ return ERR;
+
+ /* if tab to next line, exit the loop */
+
+ if (!win->_curx)
+ break;
+ }
+ return OK;
+
+ case '\n':
+ /* if lf -> crlf */
+
+ if (!SP->raw_out)
+ x = 0;
+
+ wclrtoeol(win);
+
+ if (++y > win->_bmarg)
+ {
+ y--;
+
+ if (wscrl(win, 1) == ERR)
+ return ERR;
+ }
+
+ break;
+
+ case '\b':
+ /* don't back over left margin */
+
+ if (--x < 0)
+ case '\r':
+ x = 0;
+
+ break;
+
+ case 0x7f:
+ if (waddch(win, attr | '^') == ERR)
+ return ERR;
+
+ return waddch(win, attr | '?');
+
+ default:
+ /* handle control chars */
+
+ if (waddch(win, attr | '^') == ERR)
+ return ERR;
+
+ return waddch(win, ch + '@');
+ }
+ }
+ else
+ {
+ /* If the incoming character doesn't have its own attribute,
+ then use the current attributes for the window. If it has
+ attributes but not a color component, OR the attributes to
+ the current attributes for the window. If it has a color
+ component, use the attributes solely from the incoming
+ character. */
+
+ if (!(attr & A_COLOR))
+ attr |= win->_attrs;
+
+ /* wrs (4/10/93): Apply the same sort of logic for the window
+ background, in that it only takes precedence if other color
+ attributes are not there and that the background character
+ will only print if the printing character is blank. */
+
+ if (!(attr & A_COLOR))
+ attr |= win->_bkgd & A_ATTRIBUTES;
+ else
+ attr |= win->_bkgd & (A_ATTRIBUTES ^ A_COLOR);
+
+ if (text == ' ')
+ text = win->_bkgd & A_CHARTEXT;
+
+ /* Add the attribute back into the character. */
+
+ text |= attr;
+
+ /* Only change _firstch/_lastch if the character to be added is
+ different from the character/attribute that is already in
+ that position in the window. */
+
+ if (win->_y[y][x] != text)
+ {
+ if (win->_firstch[y] == _NO_CHANGE)
+ win->_firstch[y] = win->_lastch[y] = x;
+ else
+ if (x < win->_firstch[y])
+ win->_firstch[y] = x;
+ else
+ if (x > win->_lastch[y])
+ win->_lastch[y] = x;
+
+ win->_y[y][x] = text;
+ }
+
+ if (++x >= win->_maxx)
+ {
+ /* wrap around test */
+
+ x = 0;
+
+ if (++y > win->_bmarg)
+ {
+ y--;
+
+ if (wscrl(win, 1) == ERR)
+ {
+ PDC_sync(win);
+ return ERR;
+ }
+ }
+ }
+ }
+
+ win->_curx = x;
+ win->_cury = y;
+
+ if (win->_immed)
+ wrefresh(win);
+ if (win->_sync)
+ wsyncup(win);
+
+ return OK;
+}
+
+int addch(const chtype ch)
+{
+ PDC_LOG(("addch() - called: ch=%x\n", ch));
+
+ return waddch(stdscr, ch);
+}
+
+int mvaddch(int y, int x, const chtype ch)
+{
+ PDC_LOG(("mvaddch() - called: y=%d x=%d ch=%x\n", y, x, ch));
+
+ if (move(y,x) == ERR)
+ return ERR;
+
+ return waddch(stdscr, ch);
+}
+
+int mvwaddch(WINDOW *win, int y, int x, const chtype ch)
+{
+ PDC_LOG(("mvwaddch() - called: win=%p y=%d x=%d ch=%d\n", win, y, x, ch));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return waddch(win, ch);
+}
+
+int echochar(const chtype ch)
+{
+ PDC_LOG(("echochar() - called: ch=%x\n", ch));
+
+ return wechochar(stdscr, ch);
+}
+
+int wechochar(WINDOW *win, const chtype ch)
+{
+ PDC_LOG(("wechochar() - called: win=%p ch=%x\n", win, ch));
+
+ if (waddch(win, ch) == ERR)
+ return ERR;
+
+ return wrefresh(win);
+}
+
+int waddrawch(WINDOW *win, chtype ch)
+{
+ PDC_LOG(("waddrawch() - called: win=%p ch=%x (text=%c attr=0x%x)\n",
+ win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES));
+
+ if ((ch & A_CHARTEXT) < ' ' || (ch & A_CHARTEXT) == 0x7f)
+ ch |= A_ALTCHARSET;
+
+ return waddch(win, ch);
+}
+
+int addrawch(chtype ch)
+{
+ PDC_LOG(("addrawch() - called: ch=%x\n", ch));
+
+ return waddrawch(stdscr, ch);
+}
+
+int mvaddrawch(int y, int x, chtype ch)
+{
+ PDC_LOG(("mvaddrawch() - called: y=%d x=%d ch=%d\n", y, x, ch));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return waddrawch(stdscr, ch);
+}
+
+int mvwaddrawch(WINDOW *win, int y, int x, chtype ch)
+{
+ PDC_LOG(("mvwaddrawch() - called: win=%p y=%d x=%d ch=%d\n",
+ win, y, x, ch));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return waddrawch(win, ch);
+}
+
+#ifdef PDC_WIDE
+int wadd_wch(WINDOW *win, const cchar_t *wch)
+{
+ PDC_LOG(("wadd_wch() - called: win=%p wch=%x\n", win, *wch));
+
+ return wch ? waddch(win, *wch) : ERR;
+}
+
+int add_wch(const cchar_t *wch)
+{
+ PDC_LOG(("add_wch() - called: wch=%x\n", *wch));
+
+ return wadd_wch(stdscr, wch);
+}
+
+int mvadd_wch(int y, int x, const cchar_t *wch)
+{
+ PDC_LOG(("mvaddch() - called: y=%d x=%d wch=%x\n", y, x, *wch));
+
+ if (move(y,x) == ERR)
+ return ERR;
+
+ return wadd_wch(stdscr, wch);
+}
+
+int mvwadd_wch(WINDOW *win, int y, int x, const cchar_t *wch)
+{
+ PDC_LOG(("mvwaddch() - called: win=%p y=%d x=%d wch=%d\n",
+ win, y, x, *wch));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return wadd_wch(win, wch);
+}
+
+int echo_wchar(const cchar_t *wch)
+{
+ PDC_LOG(("echo_wchar() - called: wch=%x\n", *wch));
+
+ return wecho_wchar(stdscr, wch);
+}
+
+int wecho_wchar(WINDOW *win, const cchar_t *wch)
+{
+ PDC_LOG(("wecho_wchar() - called: win=%p wch=%x\n", win, *wch));
+
+ if (!wch || (wadd_wch(win, wch) == ERR))
+ return ERR;
+
+ return wrefresh(win);
+}
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/addchstr.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/addchstr.c
new file mode 100644
index 0000000000..0eea85a741
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/addchstr.c
@@ -0,0 +1,242 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: addchstr.c,v 1.43 2008/07/13 16:08:17 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: addchstr
+
+ Synopsis:
+ int addchstr(const chtype *ch);
+ int addchnstr(const chtype *ch, int n);
+ int waddchstr(WINDOW *win, const chtype *ch);
+ int waddchnstr(WINDOW *win, const chtype *ch, int n);
+ int mvaddchstr(int y, int x, const chtype *ch);
+ int mvaddchnstr(int y, int x, const chtype *ch, int n);
+ int mvwaddchstr(WINDOW *, int y, int x, const chtype *ch);
+ int mvwaddchnstr(WINDOW *, int y, int x, const chtype *ch, int n);
+
+ int add_wchstr(const cchar_t *wch);
+ int add_wchnstr(const cchar_t *wch, int n);
+ int wadd_wchstr(WINDOW *win, const cchar_t *wch);
+ int wadd_wchnstr(WINDOW *win, const cchar_t *wch, int n);
+ int mvadd_wchstr(int y, int x, const cchar_t *wch);
+ int mvadd_wchnstr(int y, int x, const cchar_t *wch, int n);
+ int mvwadd_wchstr(WINDOW *win, int y, int x, const cchar_t *wch);
+ int mvwadd_wchnstr(WINDOW *win, int y, int x, const cchar_t *wch,
+ int n);
+
+ Description:
+ These routines write a chtype or cchar_t string directly into
+ the window structure, starting at the current or specified
+ position. The four routines with n as the last argument copy at
+ most n elements, but no more than will fit on the line. If n =
+ -1 then the whole string is copied, up to the maximum number
+ that will fit on the line.
+
+ The cursor position is not advanced. These routines do not check
+ for newline or other special characters, nor does any line
+ wrapping occur.
+
+ Return Value:
+ All functions return OK or ERR.
+
+ Portability X/Open BSD SYS V
+ addchstr Y - 4.0
+ waddchstr Y - 4.0
+ mvaddchstr Y - 4.0
+ mvwaddchstr Y - 4.0
+ addchnstr Y - 4.0
+ waddchnstr Y - 4.0
+ mvaddchnstr Y - 4.0
+ mvwaddchnstr Y - 4.0
+ add_wchstr Y
+ wadd_wchstr Y
+ mvadd_wchstr Y
+ mvwadd_wchstr Y
+ add_wchnstr Y
+ wadd_wchnstr Y
+ mvadd_wchnstr Y
+ mvwadd_wchnstr Y
+
+**man-end****************************************************************/
+
+#include <string.h>
+
+int waddchnstr(WINDOW *win, const chtype *ch, int n)
+{
+ int y, x, maxx, minx;
+ chtype *ptr;
+
+ PDC_LOG(("waddchnstr() - called: win=%p n=%d\n", win, n));
+
+ if (!win || !ch || !n || n < -1)
+ return ERR;
+
+ x = win->_curx;
+ y = win->_cury;
+ ptr = &(win->_y[y][x]);
+
+ if (n == -1 || n > win->_maxx - x)
+ n = win->_maxx - x;
+
+ minx = win->_firstch[y];
+ maxx = win->_lastch[y];
+
+ for (; n && *ch; n--, x++, ptr++, ch++)
+ {
+ if (*ptr != *ch)
+ {
+ if (x < minx || minx == _NO_CHANGE)
+ minx = x;
+
+ if (x > maxx)
+ maxx = x;
+
+ PDC_LOG(("y %d x %d minx %d maxx %d *ptr %x *ch"
+ " %x firstch: %d lastch: %d\n",
+ y, x, minx, maxx, *ptr, *ch,
+ win->_firstch[y], win->_lastch[y]));
+
+ *ptr = *ch;
+ }
+ }
+
+ win->_firstch[y] = minx;
+ win->_lastch[y] = maxx;
+
+ return OK;
+}
+
+int addchstr(const chtype *ch)
+{
+ PDC_LOG(("addchstr() - called\n"));
+
+ return waddchnstr(stdscr, ch, -1);
+}
+
+int addchnstr(const chtype *ch, int n)
+{
+ PDC_LOG(("addchnstr() - called\n"));
+
+ return waddchnstr(stdscr, ch, n);
+}
+
+int waddchstr(WINDOW *win, const chtype *ch)
+{
+ PDC_LOG(("waddchstr() - called: win=%p\n", win));
+
+ return waddchnstr(win, ch, -1);
+}
+
+int mvaddchstr(int y, int x, const chtype *ch)
+{
+ PDC_LOG(("mvaddchstr() - called: y %d x %d\n", y, x));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return waddchnstr(stdscr, ch, -1);
+}
+
+int mvaddchnstr(int y, int x, const chtype *ch, int n)
+{
+ PDC_LOG(("mvaddchnstr() - called: y %d x %d n %d\n", y, x, n));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return waddchnstr(stdscr, ch, n);
+}
+
+int mvwaddchstr(WINDOW *win, int y, int x, const chtype *ch)
+{
+ PDC_LOG(("mvwaddchstr() - called:\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return waddchnstr(win, ch, -1);
+}
+
+int mvwaddchnstr(WINDOW *win, int y, int x, const chtype *ch, int n)
+{
+ PDC_LOG(("mvwaddchnstr() - called: y %d x %d n %d \n", y, x, n));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return waddchnstr(win, ch, n);
+}
+
+#ifdef PDC_WIDE
+int wadd_wchnstr(WINDOW *win, const cchar_t *wch, int n)
+{
+ PDC_LOG(("wadd_wchnstr() - called: win=%p n=%d\n", win, n));
+
+ return waddchnstr(win, wch, n);
+}
+
+int add_wchstr(const cchar_t *wch)
+{
+ PDC_LOG(("add_wchstr() - called\n"));
+
+ return wadd_wchnstr(stdscr, wch, -1);
+}
+
+int add_wchnstr(const cchar_t *wch, int n)
+{
+ PDC_LOG(("add_wchnstr() - called\n"));
+
+ return wadd_wchnstr(stdscr, wch, n);
+}
+
+int wadd_wchstr(WINDOW *win, const cchar_t *wch)
+{
+ PDC_LOG(("wadd_wchstr() - called: win=%p\n", win));
+
+ return wadd_wchnstr(win, wch, -1);
+}
+
+int mvadd_wchstr(int y, int x, const cchar_t *wch)
+{
+ PDC_LOG(("mvadd_wchstr() - called: y %d x %d\n", y, x));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return wadd_wchnstr(stdscr, wch, -1);
+}
+
+int mvadd_wchnstr(int y, int x, const cchar_t *wch, int n)
+{
+ PDC_LOG(("mvadd_wchnstr() - called: y %d x %d n %d\n", y, x, n));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return wadd_wchnstr(stdscr, wch, n);
+}
+
+int mvwadd_wchstr(WINDOW *win, int y, int x, const cchar_t *wch)
+{
+ PDC_LOG(("mvwadd_wchstr() - called:\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return wadd_wchnstr(win, wch, -1);
+}
+
+int mvwadd_wchnstr(WINDOW *win, int y, int x, const cchar_t *wch, int n)
+{
+ PDC_LOG(("mvwadd_wchnstr() - called: y %d x %d n %d \n", y, x, n));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return wadd_wchnstr(win, wch, n);
+}
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/addstr.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/addstr.c
new file mode 100644
index 0000000000..ca19fd0293
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/addstr.c
@@ -0,0 +1,237 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: addstr.c,v 1.44 2008/07/13 16:08:17 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: addstr
+
+ Synopsis:
+ int addstr(const char *str);
+ int addnstr(const char *str, int n);
+ int waddstr(WINDOW *win, const char *str);
+ int waddnstr(WINDOW *win, const char *str, int n);
+ int mvaddstr(int y, int x, const char *str);
+ int mvaddnstr(int y, int x, const char *str, int n);
+ int mvwaddstr(WINDOW *win, int y, int x, const char *str);
+ int mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n);
+
+ int addwstr(const wchar_t *wstr);
+ int addnwstr(const wchar_t *wstr, int n);
+ int waddwstr(WINDOW *win, const wchar_t *wstr);
+ int waddnwstr(WINDOW *win, const wchar_t *wstr, int n);
+ int mvaddwstr(int y, int x, const wchar_t *wstr);
+ int mvaddnwstr(int y, int x, const wchar_t *wstr, int n);
+ int mvwaddwstr(WINDOW *win, int y, int x, const wchar_t *wstr);
+ int mvwaddnwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n);
+
+ Description:
+ These routines write all the characters of the null-terminated
+ string str or wide-character string wstr to the given window.
+ The functionality is similar to calling waddch() once for each
+ character in the string; except that, when PDCurses is built
+ with wide-character support enabled, the narrow-character
+ functions treat the string as a multibyte string in the current
+ locale, and convert it. The routines with n as the last
+ argument write at most n characters; if n is negative, then the
+ entire string will be added.
+
+ Return Value:
+ All functions return OK or ERR.
+
+ Portability X/Open BSD SYS V
+ addstr Y Y Y
+ waddstr Y Y Y
+ mvaddstr Y Y Y
+ mvwaddstr Y Y Y
+ addnstr Y - 4.0
+ waddnstr Y - 4.0
+ mvaddnstr Y - 4.0
+ mvwaddnstr Y - 4.0
+ addwstr Y
+ waddwstr Y
+ mvaddwstr Y
+ mvwaddwstr Y
+ addnwstr Y
+ waddnwstr Y
+ mvaddnwstr Y
+ mvwaddnwstr Y
+
+**man-end****************************************************************/
+
+int waddnstr(WINDOW *win, const char *str, int n)
+{
+ int i = 0;
+
+ PDC_LOG(("waddnstr() - called: string=\"%s\" n %d \n", str, n));
+
+ if (!win || !str)
+ return ERR;
+
+ while (str[i] && (i < n || n < 0))
+ {
+#ifdef PDC_WIDE
+ wchar_t wch;
+ int retval = PDC_mbtowc(&wch, str + i, n >= 0 ? n - i : 6);
+
+ if (retval <= 0)
+ return OK;
+
+ i += retval;
+#else
+ chtype wch = (unsigned char)(str[i++]);
+#endif
+ if (waddch(win, wch) == ERR)
+ return ERR;
+ }
+
+ return OK;
+}
+
+int addstr(const char *str)
+{
+ PDC_LOG(("addstr() - called: string=\"%s\"\n", str));
+
+ return waddnstr(stdscr, str, -1);
+}
+
+int addnstr(const char *str, int n)
+{
+ PDC_LOG(("addnstr() - called: string=\"%s\" n %d \n", str, n));
+
+ return waddnstr(stdscr, str, n);
+}
+
+int waddstr(WINDOW *win, const char *str)
+{
+ PDC_LOG(("waddstr() - called: string=\"%s\"\n", str));
+
+ return waddnstr(win, str, -1);
+}
+
+int mvaddstr(int y, int x, const char *str)
+{
+ PDC_LOG(("mvaddstr() - called: y %d x %d string=\"%s\"\n", y, x, str));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return waddnstr(stdscr, str, -1);
+}
+
+int mvaddnstr(int y, int x, const char *str, int n)
+{
+ PDC_LOG(("mvaddnstr() - called: y %d x %d string=\"%s\" n %d \n",
+ y, x, str, n));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return waddnstr(stdscr, str, n);
+}
+
+int mvwaddstr(WINDOW *win, int y, int x, const char *str)
+{
+ PDC_LOG(("mvwaddstr() - called: string=\"%s\"\n", str));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return waddnstr(win, str, -1);
+}
+
+int mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n)
+{
+ PDC_LOG(("mvwaddnstr() - called: y %d x %d string=\"%s\" n %d \n",
+ y, x, str, n));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return waddnstr(win, str, n);
+}
+
+#ifdef PDC_WIDE
+int waddnwstr(WINDOW *win, const wchar_t *wstr, int n)
+{
+ int i = 0;
+
+ PDC_LOG(("waddnwstr() - called\n"));
+
+ if (!win || !wstr)
+ return ERR;
+
+ while (wstr[i] && (i < n || n < 0))
+ {
+ chtype wch = wstr[i++];
+
+ if (waddch(win, wch) == ERR)
+ return ERR;
+ }
+
+ return OK;
+}
+
+int addwstr(const wchar_t *wstr)
+{
+ PDC_LOG(("addwstr() - called\n"));
+
+ return waddnwstr(stdscr, wstr, -1);
+}
+
+int addnwstr(const wchar_t *wstr, int n)
+{
+ PDC_LOG(("addnwstr() - called\n"));
+
+ return waddnwstr(stdscr, wstr, n);
+}
+
+int waddwstr(WINDOW *win, const wchar_t *wstr)
+{
+ PDC_LOG(("waddwstr() - called\n"));
+
+ return waddnwstr(win, wstr, -1);
+}
+
+int mvaddwstr(int y, int x, const wchar_t *wstr)
+{
+ PDC_LOG(("mvaddstr() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return waddnwstr(stdscr, wstr, -1);
+}
+
+int mvaddnwstr(int y, int x, const wchar_t *wstr, int n)
+{
+ PDC_LOG(("mvaddnstr() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return waddnwstr(stdscr, wstr, n);
+}
+
+int mvwaddwstr(WINDOW *win, int y, int x, const wchar_t *wstr)
+{
+ PDC_LOG(("mvwaddstr() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return waddnwstr(win, wstr, -1);
+}
+
+int mvwaddnwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n)
+{
+ PDC_LOG(("mvwaddnstr() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return waddnwstr(win, wstr, n);
+}
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/attr.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/attr.c
new file mode 100644
index 0000000000..532384b357
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/attr.c
@@ -0,0 +1,349 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: attr.c,v 1.41 2008/07/13 16:08:17 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: attr
+
+ Synopsis:
+ int attroff(chtype attrs);
+ int wattroff(WINDOW *win, chtype attrs);
+ int attron(chtype attrs);
+ int wattron(WINDOW *win, chtype attrs);
+ int attrset(chtype attrs);
+ int wattrset(WINDOW *win, chtype attrs);
+ int standend(void);
+ int wstandend(WINDOW *win);
+ int standout(void);
+ int wstandout(WINDOW *win);
+
+ int color_set(short color_pair, void *opts);
+ int wcolor_set(WINDOW *win, short color_pair, void *opts);
+
+ int attr_get(attr_t *attrs, short *color_pair, void *opts);
+ int attr_off(attr_t attrs, void *opts);
+ int attr_on(attr_t attrs, void *opts);
+ int attr_set(attr_t attrs, short color_pair, void *opts);
+ int wattr_get(WINDOW *win, attr_t *attrs, short *color_pair,
+ void *opts);
+ int wattr_off(WINDOW *win, attr_t attrs, void *opts);
+ int wattr_on(WINDOW *win, attr_t attrs, void *opts);
+ int wattr_set(WINDOW *win, attr_t attrs, short color_pair,
+ void *opts);
+
+ int chgat(int n, attr_t attr, short color, const void *opts);
+ int mvchgat(int y, int x, int n, attr_t attr, short color,
+ const void *opts);
+ int mvwchgat(WINDOW *win, int y, int x, int n, attr_t attr,
+ short color, const void *opts);
+ int wchgat(WINDOW *win, int n, attr_t attr, short color,
+ const void *opts);
+
+ chtype getattrs(WINDOW *win);
+
+ Description:
+ These functions manipulate the current attributes and/or colors
+ of the named window. These attributes can be any combination
+ of A_STANDOUT, A_REVERSE, A_BOLD, A_DIM, A_BLINK, A_UNDERLINE.
+
+ These constants are defined in <curses.h> and can be combined
+ with the bitwise-OR operator (|).
+
+ The current attributes of a window are applied to all chtypes
+ that are written into the window with waddch(). Attributes are
+ a property of the chtype, and move with the character through
+ any scrolling or insert/delete operations.
+
+ attrset() sets the current attributes of the given window to
+ attrs. attroff() turns off the named attributes without
+ affecting any other attributes; attron() turns them on.
+ color_set() sets the window color to the value of color_pair.
+
+ standout() is the same as attron(A_STANDOUT). standend() is the
+ same as attrset(A_NORMAL); that is, it turns off all attributes.
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ attroff Y Y Y
+ wattroff Y Y Y
+ attron Y Y Y
+ wattron Y Y Y
+ attrset Y Y Y
+ wattrset Y Y Y
+ standend Y Y Y
+ wstandend Y Y Y
+ standout Y Y Y
+ wstandout Y Y Y
+ color_set Y
+ wcolor_set Y
+ attr_get Y
+ wattr_get Y
+ attr_on Y
+ wattr_on Y
+ attr_off Y
+ wattr_off Y
+ attr_set Y
+ wattr_set Y
+ chgat Y
+ wchgat Y
+ mvchgat Y
+ mvwchgat Y
+ getattrs -
+
+**man-end****************************************************************/
+
+int wattroff(WINDOW *win, chtype attrs)
+{
+ PDC_LOG(("wattroff() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ win->_attrs &= (~attrs & A_ATTRIBUTES);
+
+ return OK;
+}
+
+int attroff(chtype attrs)
+{
+ PDC_LOG(("attroff() - called\n"));
+
+ return wattroff(stdscr, attrs);
+}
+
+int wattron(WINDOW *win, chtype attrs)
+{
+ chtype newcolr, oldcolr, newattr, oldattr;
+
+ PDC_LOG(("wattron() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ if ((win->_attrs & A_COLOR) && (attrs & A_COLOR))
+ {
+ oldcolr = win->_attrs & A_COLOR;
+ oldattr = win->_attrs ^ oldcolr;
+ newcolr = attrs & A_COLOR;
+ newattr = (attrs & A_ATTRIBUTES) ^ newcolr;
+ newattr |= oldattr;
+ win->_attrs = newattr | newcolr;
+ }
+ else
+ win->_attrs |= (attrs & A_ATTRIBUTES);
+
+ return OK;
+}
+
+int attron(chtype attrs)
+{
+ PDC_LOG(("attron() - called\n"));
+
+ return wattron(stdscr, attrs);
+}
+
+int wattrset(WINDOW *win, chtype attrs)
+{
+ PDC_LOG(("wattrset() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ win->_attrs = attrs & A_ATTRIBUTES;
+
+ return OK;
+}
+
+int attrset(chtype attrs)
+{
+ PDC_LOG(("attrset() - called\n"));
+
+ return wattrset(stdscr, attrs);
+}
+
+int standend(void)
+{
+ PDC_LOG(("standend() - called\n"));
+
+ return wattrset(stdscr, A_NORMAL);
+}
+
+int standout(void)
+{
+ PDC_LOG(("standout() - called\n"));
+
+ return wattrset(stdscr, A_STANDOUT);
+}
+
+int wstandend(WINDOW *win)
+{
+ PDC_LOG(("wstandend() - called\n"));
+
+ return wattrset(win, A_NORMAL);
+}
+
+int wstandout(WINDOW *win)
+{
+ PDC_LOG(("wstandout() - called\n"));
+
+ return wattrset(win, A_STANDOUT);
+}
+
+chtype getattrs(WINDOW *win)
+{
+ return win ? win->_attrs : 0;
+}
+
+int wcolor_set(WINDOW *win, short color_pair, void *opts)
+{
+ PDC_LOG(("wcolor_set() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ win->_attrs = (win->_attrs & ~A_COLOR) | COLOR_PAIR(color_pair);
+
+ return OK;
+}
+
+int color_set(short color_pair, void *opts)
+{
+ PDC_LOG(("color_set() - called\n"));
+
+ return wcolor_set(stdscr, color_pair, opts);
+}
+
+int wattr_get(WINDOW *win, attr_t *attrs, short *color_pair, void *opts)
+{
+ PDC_LOG(("wattr_get() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ if (attrs)
+ *attrs = win->_attrs & (A_ATTRIBUTES & ~A_COLOR);
+
+ if (color_pair)
+ *color_pair = PAIR_NUMBER(win->_attrs);
+
+ return OK;
+}
+
+int attr_get(attr_t *attrs, short *color_pair, void *opts)
+{
+ PDC_LOG(("attr_get() - called\n"));
+
+ return wattr_get(stdscr, attrs, color_pair, opts);
+}
+
+int wattr_off(WINDOW *win, attr_t attrs, void *opts)
+{
+ PDC_LOG(("wattr_off() - called\n"));
+
+ return wattroff(win, attrs);
+}
+
+int attr_off(attr_t attrs, void *opts)
+{
+ PDC_LOG(("attr_off() - called\n"));
+
+ return wattroff(stdscr, attrs);
+}
+
+int wattr_on(WINDOW *win, attr_t attrs, void *opts)
+{
+ PDC_LOG(("wattr_off() - called\n"));
+
+ return wattron(win, attrs);
+}
+
+int attr_on(attr_t attrs, void *opts)
+{
+ PDC_LOG(("attr_on() - called\n"));
+
+ return wattron(stdscr, attrs);
+}
+
+int wattr_set(WINDOW *win, attr_t attrs, short color_pair, void *opts)
+{
+ PDC_LOG(("wattr_set() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ win->_attrs = (attrs & (A_ATTRIBUTES & ~A_COLOR)) | COLOR_PAIR(color_pair);
+
+ return OK;
+}
+
+int attr_set(attr_t attrs, short color_pair, void *opts)
+{
+ PDC_LOG(("attr_get() - called\n"));
+
+ return wattr_set(stdscr, attrs, color_pair, opts);
+}
+
+int wchgat(WINDOW *win, int n, attr_t attr, short color, const void *opts)
+{
+ chtype *dest, newattr;
+ int startpos, endpos;
+
+ PDC_LOG(("wchgat() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ newattr = (attr & A_ATTRIBUTES) | COLOR_PAIR(color);
+
+ startpos = win->_curx;
+ endpos = ((n < 0) ? win->_maxx : min(startpos + n, win->_maxx)) - 1;
+ dest = win->_y[win->_cury];
+
+ for (n = startpos; n <= endpos; n++)
+ dest[n] = (dest[n] & A_CHARTEXT) | newattr;
+
+ n = win->_cury;
+
+ if (startpos < win->_firstch[n] || win->_firstch[n] == _NO_CHANGE)
+ win->_firstch[n] = startpos;
+
+ if (endpos > win->_lastch[n])
+ win->_lastch[n] = endpos;
+
+ PDC_sync(win);
+
+ return OK;
+}
+
+int chgat(int n, attr_t attr, short color, const void *opts)
+{
+ PDC_LOG(("chgat() - called\n"));
+
+ return wchgat(stdscr, n, attr, color, opts);
+}
+
+int mvchgat(int y, int x, int n, attr_t attr, short color, const void *opts)
+{
+ PDC_LOG(("mvchgat() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return wchgat(stdscr, n, attr, color, opts);
+}
+
+int mvwchgat(WINDOW *win, int y, int x, int n, attr_t attr, short color,
+ const void *opts)
+{
+ PDC_LOG(("mvwchgat() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return wchgat(win, n, attr, color, opts);
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/beep.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/beep.c
new file mode 100644
index 0000000000..9e92f45727
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/beep.c
@@ -0,0 +1,65 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: beep.c,v 1.34 2008/07/13 16:08:17 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: beep
+
+ Synopsis:
+ int beep(void);
+ int flash(void);
+
+ Description:
+ beep() sounds the audible bell on the terminal, if possible;
+ if not, it calls flash().
+
+ flash() "flashes" the screen, by inverting the foreground and
+ background of every cell, pausing, and then restoring the
+ original attributes.
+
+ Return Value:
+ These functions return OK.
+
+ Portability X/Open BSD SYS V
+ beep Y Y Y
+ flash Y Y Y
+
+**man-end****************************************************************/
+
+int beep(void)
+{
+ PDC_LOG(("beep() - called\n"));
+
+ if (SP->audible)
+ PDC_beep();
+ else
+ flash();
+
+ return OK;
+}
+
+int flash(void)
+{
+ int z, y, x;
+
+ PDC_LOG(("flash() - called\n"));
+
+ /* Reverse each cell; wait; restore the screen */
+
+ for (z = 0; z < 2; z++)
+ {
+ for (y = 0; y < LINES; y++)
+ for (x = 0; x < COLS; x++)
+ curscr->_y[y][x] ^= A_REVERSE;
+
+ wrefresh(curscr);
+
+ if (!z)
+ napms(50);
+ }
+
+ return OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/bkgd.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/bkgd.c
new file mode 100644
index 0000000000..083239e1da
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/bkgd.c
@@ -0,0 +1,220 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: bkgd.c,v 1.39 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: bkgd
+
+ Synopsis:
+ int bkgd(chtype ch);
+ void bkgdset(chtype ch);
+ chtype getbkgd(WINDOW *win);
+ int wbkgd(WINDOW *win, chtype ch);
+ void wbkgdset(WINDOW *win, chtype ch);
+
+ int bkgrnd(const cchar_t *wch);
+ void bkgrndset(const cchar_t *wch);
+ int getbkgrnd(cchar_t *wch);
+ int wbkgrnd(WINDOW *win, const cchar_t *wch);
+ void wbkgrndset(WINDOW *win, const cchar_t *wch);
+ int wgetbkgrnd(WINDOW *win, cchar_t *wch);
+
+ Description:
+ bkgdset() and wbkgdset() manipulate the background of a window.
+ The background is a chtype consisting of any combination of
+ attributes and a character; it is combined with each chtype
+ added or inserted to the window by waddch() or winsch(). Only
+ the attribute part is used to set the background of non-blank
+ characters, while both character and attributes are used for
+ blank positions.
+
+ bkgd() and wbkgd() not only change the background, but apply it
+ immediately to every cell in the window.
+
+ The attributes that are defined with the attrset()/attron() set
+ of functions take precedence over the background attributes if
+ there is a conflict (e.g., different color pairs).
+
+ Return Value:
+ bkgd() and wbkgd() return OK, unless the window is NULL, in
+ which case they return ERR.
+
+ Portability X/Open BSD SYS V
+ bkgd Y - 4.0
+ bkgdset Y - 4.0
+ getbkgd Y
+ wbkgd Y - 4.0
+ wbkgdset Y - 4.0
+ bkgrnd Y
+ bkgrndset Y
+ getbkgrnd Y
+ wbkgrnd Y
+ wbkgrndset Y
+ wgetbkgrnd Y
+
+**man-end****************************************************************/
+
+int wbkgd(WINDOW *win, chtype ch)
+{
+ int x, y;
+ chtype oldcolr, oldch, newcolr, newch, colr, attr;
+ chtype oldattr = 0, newattr = 0;
+ chtype *winptr;
+
+ PDC_LOG(("wbkgd() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ if (win->_bkgd == ch)
+ return OK;
+
+ oldcolr = win->_bkgd & A_COLOR;
+ if (oldcolr)
+ oldattr = (win->_bkgd & A_ATTRIBUTES) ^ oldcolr;
+
+ oldch = win->_bkgd & A_CHARTEXT;
+
+ wbkgdset(win, ch);
+
+ newcolr = win->_bkgd & A_COLOR;
+ if (newcolr)
+ newattr = (win->_bkgd & A_ATTRIBUTES) ^ newcolr;
+
+ newch = win->_bkgd & A_CHARTEXT;
+
+ /* what follows is what seems to occur in the System V
+ implementation of this routine */
+
+ for (y = 0; y < win->_maxy; y++)
+ {
+ for (x = 0; x < win->_maxx; x++)
+ {
+ winptr = win->_y[y] + x;
+
+ ch = *winptr;
+
+ /* determine the colors and attributes of the character read
+ from the window */
+
+ colr = ch & A_COLOR;
+ attr = ch & (A_ATTRIBUTES ^ A_COLOR);
+
+ /* if the color is the same as the old background color,
+ then make it the new background color, otherwise leave it */
+
+ if (colr == oldcolr)
+ colr = newcolr;
+
+ /* remove any attributes (non color) from the character that
+ were part of the old background, then combine the
+ remaining ones with the new background */
+
+ attr ^= oldattr;
+ attr |= newattr;
+
+ /* change character if it is there because it was the old
+ background character */
+
+ ch &= A_CHARTEXT;
+ if (ch == oldch)
+ ch = newch;
+
+ ch |= (attr | colr);
+
+ *winptr = ch;
+
+ }
+ }
+
+ touchwin(win);
+ PDC_sync(win);
+ return OK;
+}
+
+int bkgd(chtype ch)
+{
+ PDC_LOG(("bkgd() - called\n"));
+
+ return wbkgd(stdscr, ch);
+}
+
+void wbkgdset(WINDOW *win, chtype ch)
+{
+ PDC_LOG(("wbkgdset() - called\n"));
+
+ if (win)
+ {
+ if (!(ch & A_CHARTEXT))
+ ch |= ' ';
+
+ win->_bkgd = ch;
+ }
+}
+
+void bkgdset(chtype ch)
+{
+ PDC_LOG(("bkgdset() - called\n"));
+
+ wbkgdset(stdscr, ch);
+}
+
+chtype getbkgd(WINDOW *win)
+{
+ PDC_LOG(("getbkgd() - called\n"));
+
+ return win ? win->_bkgd : (chtype)ERR;
+}
+
+#ifdef PDC_WIDE
+int wbkgrnd(WINDOW *win, const cchar_t *wch)
+{
+ PDC_LOG(("wbkgrnd() - called\n"));
+
+ return wch ? wbkgd(win, *wch) : ERR;
+}
+
+int bkgrnd(const cchar_t *wch)
+{
+ PDC_LOG(("bkgrnd() - called\n"));
+
+ return wbkgrnd(stdscr, wch);
+}
+
+void wbkgrndset(WINDOW *win, const cchar_t *wch)
+{
+ PDC_LOG(("wbkgdset() - called\n"));
+
+ if (wch)
+ wbkgdset(win, *wch);
+}
+
+void bkgrndset(const cchar_t *wch)
+{
+ PDC_LOG(("bkgrndset() - called\n"));
+
+ wbkgrndset(stdscr, wch);
+}
+
+int wgetbkgrnd(WINDOW *win, cchar_t *wch)
+{
+ PDC_LOG(("wgetbkgrnd() - called\n"));
+
+ if (!win || !wch)
+ return ERR;
+
+ *wch = win->_bkgd;
+
+ return OK;
+}
+
+int getbkgrnd(cchar_t *wch)
+{
+ PDC_LOG(("getbkgrnd() - called\n"));
+
+ return wgetbkgrnd(stdscr, wch);
+}
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/border.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/border.c
new file mode 100644
index 0000000000..ec86aafdff
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/border.c
@@ -0,0 +1,408 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: border.c,v 1.53 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: border
+
+ Synopsis:
+ int border(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl,
+ chtype tr, chtype bl, chtype br);
+ int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts,
+ chtype bs, chtype tl, chtype tr, chtype bl, chtype br);
+ int box(WINDOW *win, chtype verch, chtype horch);
+ int hline(chtype ch, int n);
+ int vline(chtype ch, int n);
+ int whline(WINDOW *win, chtype ch, int n);
+ int wvline(WINDOW *win, chtype ch, int n);
+ int mvhline(int y, int x, chtype ch, int n);
+ int mvvline(int y, int x, chtype ch, int n);
+ int mvwhline(WINDOW *win, int y, int x, chtype ch, int n);
+ int mvwvline(WINDOW *win, int y, int x, chtype ch, int n);
+
+ int border_set(const cchar_t *ls, const cchar_t *rs,
+ const cchar_t *ts, const cchar_t *bs,
+ const cchar_t *tl, const cchar_t *tr,
+ const cchar_t *bl, const cchar_t *br);
+ int wborder_set(WINDOW *win, const cchar_t *ls, const cchar_t *rs,
+ const cchar_t *ts, const cchar_t *bs,
+ const cchar_t *tl, const cchar_t *tr,
+ const cchar_t *bl, const cchar_t *br);
+ int box_set(WINDOW *win, const cchar_t *verch, const cchar_t *horch);
+ int hline_set(const cchar_t *wch, int n);
+ int vline_set(const cchar_t *wch, int n);
+ int whline_set(WINDOW *win, const cchar_t *wch, int n);
+ int wvline_set(WINDOW *win, const cchar_t *wch, int n);
+ int mvhline_set(int y, int x, const cchar_t *wch, int n);
+ int mvvline_set(int y, int x, const cchar_t *wch, int n);
+ int mvwhline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n);
+ int mvwvline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n);
+
+ Description:
+ border(), wborder(), and box() draw a border around the edge of
+ the window. If any argument is zero, an appropriate default is
+ used:
+
+ ls left side of border ACS_VLINE
+ rs right side of border ACS_VLINE
+ ts top side of border ACS_HLINE
+ bs bottom side of border ACS_HLINE
+ tl top left corner of border ACS_ULCORNER
+ tr top right corner of border ACS_URCORNER
+ bl bottom left corner of border ACS_LLCORNER
+ br bottom right corner of border ACS_LRCORNER
+
+ hline() and whline() draw a horizontal line, using ch, starting
+ from the current cursor position. The cursor position does not
+ change. The line is at most n characters long, or as many as
+ will fit in the window.
+
+ vline() and wvline() draw a vertical line, using ch, starting
+ from the current cursor position. The cursor position does not
+ change. The line is at most n characters long, or as many as
+ will fit in the window.
+
+ Return Value:
+ These functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ border Y - 4.0
+ wborder Y - 4.0
+ box Y Y Y
+ hline Y - 4.0
+ vline Y - 4.0
+ whline Y - 4.0
+ wvline Y - 4.0
+ mvhline Y
+ mvvline Y
+ mvwhline Y
+ mvwvline Y
+ border_set Y
+ wborder_set Y
+ box_set Y
+ hline_set Y
+ vline_set Y
+ whline_set Y
+ wvline_set Y
+ mvhline_set Y
+ mvvline_set Y
+ mvwhline_set Y
+ mvwvline_set Y
+
+**man-end****************************************************************/
+
+/* _attr_passthru() -- Takes a single chtype 'ch' and checks if the
+ current attribute of window 'win', as set by wattrset(), and/or the
+ current background of win, as set by wbkgd(), should by combined with
+ it. Attributes set explicitly in ch take precedence. */
+
+static chtype _attr_passthru(WINDOW *win, chtype ch)
+{
+ chtype attr;
+
+ /* If the incoming character doesn't have its own attribute, then
+ use the current attributes for the window. If the incoming
+ character has attributes, but not a color component, OR the
+ attributes to the current attributes for the window. If the
+ incoming character has a color component, use only the attributes
+ from the incoming character. */
+
+ attr = ch & A_ATTRIBUTES;
+ if (!(attr & A_COLOR))
+ attr |= win->_attrs;
+
+ /* wrs (4/10/93) -- Apply the same sort of logic for the window
+ background, in that it only takes precedence if other color
+ attributes are not there. */
+
+ if (!(attr & A_COLOR))
+ attr |= win->_bkgd & A_ATTRIBUTES;
+ else
+ attr |= win->_bkgd & (A_ATTRIBUTES ^ A_COLOR);
+
+ ch = (ch & A_CHARTEXT) | attr;
+
+ return ch;
+}
+
+int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs,
+ chtype tl, chtype tr, chtype bl, chtype br)
+{
+ int i, ymax, xmax;
+
+ PDC_LOG(("wborder() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ ymax = win->_maxy - 1;
+ xmax = win->_maxx - 1;
+
+ ls = _attr_passthru(win, ls ? ls : ACS_VLINE);
+ rs = _attr_passthru(win, rs ? rs : ACS_VLINE);
+ ts = _attr_passthru(win, ts ? ts : ACS_HLINE);
+ bs = _attr_passthru(win, bs ? bs : ACS_HLINE);
+ tl = _attr_passthru(win, tl ? tl : ACS_ULCORNER);
+ tr = _attr_passthru(win, tr ? tr : ACS_URCORNER);
+ bl = _attr_passthru(win, bl ? bl : ACS_LLCORNER);
+ br = _attr_passthru(win, br ? br : ACS_LRCORNER);
+
+ for (i = 1; i < xmax; i++)
+ {
+ win->_y[0][i] = ts;
+ win->_y[ymax][i] = bs;
+ }
+
+ for (i = 1; i < ymax; i++)
+ {
+ win->_y[i][0] = ls;
+ win->_y[i][xmax] = rs;
+ }
+
+ win->_y[0][0] = tl;
+ win->_y[0][xmax] = tr;
+ win->_y[ymax][0] = bl;
+ win->_y[ymax][xmax] = br;
+
+ for (i = 0; i <= ymax; i++)
+ {
+ win->_firstch[i] = 0;
+ win->_lastch[i] = xmax;
+ }
+
+ PDC_sync(win);
+
+ return OK;
+}
+
+int border(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl,
+ chtype tr, chtype bl, chtype br)
+{
+ PDC_LOG(("border() - called\n"));
+
+ return wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br);
+}
+
+int box(WINDOW *win, chtype verch, chtype horch)
+{
+ PDC_LOG(("box() - called\n"));
+
+ return wborder(win, verch, verch, horch, horch, 0, 0, 0, 0);
+}
+
+int whline(WINDOW *win, chtype ch, int n)
+{
+ chtype *dest;
+ int startpos, endpos;
+
+ PDC_LOG(("whline() - called\n"));
+
+ if (!win || n < 1)
+ return ERR;
+
+ startpos = win->_curx;
+ endpos = min(startpos + n, win->_maxx) - 1;
+ dest = win->_y[win->_cury];
+ ch = _attr_passthru(win, ch ? ch : ACS_HLINE);
+
+ for (n = startpos; n <= endpos; n++)
+ dest[n] = ch;
+
+ n = win->_cury;
+
+ if (startpos < win->_firstch[n] || win->_firstch[n] == _NO_CHANGE)
+ win->_firstch[n] = startpos;
+
+ if (endpos > win->_lastch[n])
+ win->_lastch[n] = endpos;
+
+ PDC_sync(win);
+
+ return OK;
+}
+
+int hline(chtype ch, int n)
+{
+ PDC_LOG(("hline() - called\n"));
+
+ return whline(stdscr, ch, n);
+}
+
+int mvhline(int y, int x, chtype ch, int n)
+{
+ PDC_LOG(("mvhline() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return whline(stdscr, ch, n);
+}
+
+int mvwhline(WINDOW *win, int y, int x, chtype ch, int n)
+{
+ PDC_LOG(("mvwhline() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return whline(win, ch, n);
+}
+
+int wvline(WINDOW *win, chtype ch, int n)
+{
+ int endpos, x;
+
+ PDC_LOG(("wvline() - called\n"));
+
+ if (!win || n < 1)
+ return ERR;
+
+ endpos = min(win->_cury + n, win->_maxy);
+ x = win->_curx;
+
+ ch = _attr_passthru(win, ch ? ch : ACS_VLINE);
+
+ for (n = win->_cury; n < endpos; n++)
+ {
+ win->_y[n][x] = ch;
+
+ if (x < win->_firstch[n] || win->_firstch[n] == _NO_CHANGE)
+ win->_firstch[n] = x;
+
+ if (x > win->_lastch[n])
+ win->_lastch[n] = x;
+ }
+
+ PDC_sync(win);
+
+ return OK;
+}
+
+int vline(chtype ch, int n)
+{
+ PDC_LOG(("vline() - called\n"));
+
+ return wvline(stdscr, ch, n);
+}
+
+int mvvline(int y, int x, chtype ch, int n)
+{
+ PDC_LOG(("mvvline() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return wvline(stdscr, ch, n);
+}
+
+int mvwvline(WINDOW *win, int y, int x, chtype ch, int n)
+{
+ PDC_LOG(("mvwvline() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return wvline(win, ch, n);
+}
+
+#ifdef PDC_WIDE
+int wborder_set(WINDOW *win, const cchar_t *ls, const cchar_t *rs,
+ const cchar_t *ts, const cchar_t *bs, const cchar_t *tl,
+ const cchar_t *tr, const cchar_t *bl, const cchar_t *br)
+{
+ PDC_LOG(("wborder_set() - called\n"));
+
+ return wborder(win, ls ? *ls : 0, rs ? *rs : 0, ts ? *ts : 0,
+ bs ? *bs : 0, tl ? *tl : 0, tr ? *tr : 0,
+ bl ? *bl : 0, br ? *br : 0);
+}
+
+int border_set(const cchar_t *ls, const cchar_t *rs, const cchar_t *ts,
+ const cchar_t *bs, const cchar_t *tl, const cchar_t *tr,
+ const cchar_t *bl, const cchar_t *br)
+{
+ PDC_LOG(("border_set() - called\n"));
+
+ return wborder_set(stdscr, ls, rs, ts, bs, tl, tr, bl, br);
+}
+
+int box_set(WINDOW *win, const cchar_t *verch, const cchar_t *horch)
+{
+ PDC_LOG(("box_set() - called\n"));
+
+ return wborder_set(win, verch, verch, horch, horch,
+ (const cchar_t *)NULL, (const cchar_t *)NULL,
+ (const cchar_t *)NULL, (const cchar_t *)NULL);
+}
+
+int whline_set(WINDOW *win, const cchar_t *wch, int n)
+{
+ PDC_LOG(("whline_set() - called\n"));
+
+ return wch ? whline(win, *wch, n) : ERR;
+}
+
+int hline_set(const cchar_t *wch, int n)
+{
+ PDC_LOG(("hline_set() - called\n"));
+
+ return whline_set(stdscr, wch, n);
+}
+
+int mvhline_set(int y, int x, const cchar_t *wch, int n)
+{
+ PDC_LOG(("mvhline_set() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return whline_set(stdscr, wch, n);
+}
+
+int mvwhline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n)
+{
+ PDC_LOG(("mvwhline_set() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return whline_set(win, wch, n);
+}
+
+int wvline_set(WINDOW *win, const cchar_t *wch, int n)
+{
+ PDC_LOG(("wvline_set() - called\n"));
+
+ return wch ? wvline(win, *wch, n) : ERR;
+}
+
+int vline_set(const cchar_t *wch, int n)
+{
+ PDC_LOG(("vline_set() - called\n"));
+
+ return wvline_set(stdscr, wch, n);
+}
+
+int mvvline_set(int y, int x, const cchar_t *wch, int n)
+{
+ PDC_LOG(("mvvline_set() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return wvline_set(stdscr, wch, n);
+}
+
+int mvwvline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n)
+{
+ PDC_LOG(("mvwvline_set() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return wvline_set(win, wch, n);
+}
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/clear.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/clear.c
new file mode 100644
index 0000000000..eda33855d0
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/clear.c
@@ -0,0 +1,154 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: clear.c,v 1.35 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: clear
+
+ Synopsis:
+ int clear(void);
+ int wclear(WINDOW *win);
+ int erase(void);
+ int werase(WINDOW *win);
+ int clrtobot(void);
+ int wclrtobot(WINDOW *win);
+ int clrtoeol(void);
+ int wclrtoeol(WINDOW *win);
+
+ Description:
+ erase() and werase() copy blanks (i.e. the background chtype) to
+ every cell of the window.
+
+ clear() and wclear() are similar to erase() and werase(), but
+ they also call clearok() to ensure that the the window is
+ cleared on the next wrefresh().
+
+ clrtobot() and wclrtobot() clear the window from the current
+ cursor position to the end of the window.
+
+ clrtoeol() and wclrtoeol() clear the window from the current
+ cursor position to the end of the current line.
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ clear Y Y Y
+ wclear Y Y Y
+ erase Y Y Y
+ werase Y Y Y
+ clrtobot Y Y Y
+ wclrtobot Y Y Y
+ clrtoeol Y Y Y
+ wclrtoeol Y Y Y
+
+**man-end****************************************************************/
+
+int wclrtoeol(WINDOW *win)
+{
+ int x, y, minx;
+ chtype blank, *ptr;
+
+ PDC_LOG(("wclrtoeol() - called: Row: %d Col: %d\n",
+ win->_cury, win->_curx));
+
+ if (!win)
+ return ERR;
+
+ y = win->_cury;
+ x = win->_curx;
+
+ /* wrs (4/10/93) account for window background */
+
+ blank = win->_bkgd;
+
+ for (minx = x, ptr = &win->_y[y][x]; minx < win->_maxx; minx++, ptr++)
+ *ptr = blank;
+
+ if (x < win->_firstch[y] || win->_firstch[y] == _NO_CHANGE)
+ win->_firstch[y] = x;
+
+ win->_lastch[y] = win->_maxx - 1;
+
+ PDC_sync(win);
+ return OK;
+}
+
+int clrtoeol(void)
+{
+ PDC_LOG(("clrtoeol() - called\n"));
+
+ return wclrtoeol(stdscr);
+}
+
+int wclrtobot(WINDOW *win)
+{
+ int savey = win->_cury;
+ int savex = win->_curx;
+
+ PDC_LOG(("wclrtobot() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ /* should this involve scrolling region somehow ? */
+
+ if (win->_cury + 1 < win->_maxy)
+ {
+ win->_curx = 0;
+ win->_cury++;
+ for (; win->_maxy > win->_cury; win->_cury++)
+ wclrtoeol(win);
+ win->_cury = savey;
+ win->_curx = savex;
+ }
+ wclrtoeol(win);
+
+ PDC_sync(win);
+ return OK;
+}
+
+int clrtobot(void)
+{
+ PDC_LOG(("clrtobot() - called\n"));
+
+ return wclrtobot(stdscr);
+}
+
+int werase(WINDOW *win)
+{
+ PDC_LOG(("werase() - called\n"));
+
+ if (wmove(win, 0, 0) == ERR)
+ return ERR;
+
+ return wclrtobot(win);
+}
+
+int erase(void)
+{
+ PDC_LOG(("erase() - called\n"));
+
+ return werase(stdscr);
+}
+
+int wclear(WINDOW *win)
+{
+ PDC_LOG(("wclear() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ win->_clear = TRUE;
+ return werase(win);
+}
+
+int clear(void)
+{
+ PDC_LOG(("clear() - called\n"));
+
+ return wclear(stdscr);
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/color.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/color.c
new file mode 100644
index 0000000000..038f760457
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/color.c
@@ -0,0 +1,295 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: color.c,v 1.83 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: color
+
+ Synopsis:
+ int start_color(void);
+ int init_pair(short pair, short fg, short bg);
+ int init_color(short color, short red, short green, short blue);
+ bool has_colors(void);
+ bool can_change_color(void);
+ int color_content(short color, short *red, short *green, short *blue);
+ int pair_content(short pair, short *fg, short *bg);
+
+ int assume_default_colors(int f, int b);
+ int use_default_colors(void);
+
+ int PDC_set_line_color(short color);
+
+ Description:
+ To use these routines, start_color() must be called, usually
+ immediately after initscr(). Colors are always used in pairs,
+ referred to as color-pairs. A color-pair consists of a
+ foreground color and a background color. A color-pair is
+ initialized via init_pair(). After initialization, COLOR_PAIR(n)
+ can be used like any other video attribute.
+
+ start_color() initializes eight basic colors (black, red, green,
+ yellow, blue, magenta, cyan, and white), and two global
+ variables; COLORS and COLOR_PAIRS (respectively defining the
+ maximum number of colors and color-pairs the terminal is capable
+ of displaying).
+
+ init_pair() changes the definition of a color-pair. It takes
+ three arguments: the number of the color-pair to be redefined,
+ and the new values of the foreground and background colors. The
+ pair number must be between 0 and COLOR_PAIRS - 1, inclusive.
+ The foreground and background must be between 0 and COLORS - 1,
+ inclusive. If the color pair was previously initialized, the
+ screen is refreshed, and all occurrences of that color-pair are
+ changed to the new definition.
+
+ has_colors() indicates if the terminal supports, and can
+ maniplulate color. It returns TRUE or FALSE.
+
+ can_change_color() indicates if the terminal has the capability
+ to change the definition of its colors.
+
+ pair_content() is used to determine what the colors of a given
+ color-pair consist of.
+
+ assume_default_colors() and use_default_colors() emulate the
+ ncurses extensions of the same names. assume_default_colors(f,
+ b) is essentially the same as init_pair(0, f, b) (which isn't
+ allowed); it redefines the default colors. use_default_colors()
+ allows the use of -1 as a foreground or background color with
+ init_pair(), and calls assume_default_colors(-1, -1); -1
+ represents the foreground or background color that the terminal
+ had at startup. If the environment variable PDC_ORIGINAL_COLORS
+ is set at the time start_color() is called, that's equivalent to
+ calling use_default_colors().
+
+ PDC_set_line_color() is used to set the color, globally, for
+ the color of the lines drawn for the attributes: A_UNDERLINE,
+ A_OVERLINE, A_LEFTLINE and A_RIGHTLINE. A value of -1 (the
+ default) indicates that the current foreground color should be
+ used.
+
+ NOTE: COLOR_PAIR() and PAIR_NUMBER() are implemented as macros.
+
+ Return Value:
+ All functions return OK on success and ERR on error, except for
+ has_colors() and can_change_colors(), which return TRUE or FALSE.
+
+ Portability X/Open BSD SYS V
+ start_color Y - 3.2
+ init_pair Y - 3.2
+ init_color Y - 3.2
+ has_colors Y - 3.2
+ can_change_color Y - 3.2
+ color_content Y - 3.2
+ pair_content Y - 3.2
+ assume_default_colors - - -
+ use_default_colors - - -
+ PDC_set_line_color - - -
+
+**man-end****************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+
+int COLORS = 0;
+int COLOR_PAIRS = PDC_COLOR_PAIRS;
+
+bool pdc_color_started = FALSE;
+
+/* pair_set[] tracks whether a pair has been set via init_pair() */
+
+static bool pair_set[PDC_COLOR_PAIRS];
+static bool default_colors = FALSE;
+static short first_col = 0;
+
+int start_color(void)
+{
+ PDC_LOG(("start_color() - called\n"));
+
+ if (SP->mono)
+ return ERR;
+
+ pdc_color_started = TRUE;
+
+ PDC_set_blink(FALSE); /* Also sets COLORS, to 8 or 16 */
+
+ if (!default_colors && SP->orig_attr && getenv("PDC_ORIGINAL_COLORS"))
+ default_colors = TRUE;
+
+ PDC_init_atrtab();
+
+ memset(pair_set, 0, PDC_COLOR_PAIRS);
+
+ return OK;
+}
+
+static void _normalize(short *fg, short *bg)
+{
+ if (*fg == -1)
+ *fg = SP->orig_attr ? SP->orig_fore : COLOR_WHITE;
+
+ if (*bg == -1)
+ *bg = SP->orig_attr ? SP->orig_back : COLOR_BLACK;
+}
+
+int init_pair(short pair, short fg, short bg)
+{
+ PDC_LOG(("init_pair() - called: pair %d fg %d bg %d\n", pair, fg, bg));
+
+ if (!pdc_color_started || pair < 1 || pair >= COLOR_PAIRS ||
+ fg < first_col || fg >= COLORS || bg < first_col || bg >= COLORS)
+ return ERR;
+
+ _normalize(&fg, &bg);
+
+ /* To allow the PDC_PRESERVE_SCREEN option to work, we only reset
+ curscr if this call to init_pair() alters a color pair created by
+ the user. */
+
+ if (pair_set[pair])
+ {
+ short oldfg, oldbg;
+
+ PDC_pair_content(pair, &oldfg, &oldbg);
+
+ if (oldfg != fg || oldbg != bg)
+ curscr->_clear = TRUE;
+ }
+
+ PDC_init_pair(pair, fg, bg);
+
+ pair_set[pair] = TRUE;
+
+ return OK;
+}
+
+bool has_colors(void)
+{
+ PDC_LOG(("has_colors() - called\n"));
+
+ return !(SP->mono);
+}
+
+int init_color(short color, short red, short green, short blue)
+{
+ PDC_LOG(("init_color() - called\n"));
+
+ if (color < 0 || color >= COLORS || !PDC_can_change_color() ||
+ red < 0 || red > 1000 || green < 0 || green > 1000 ||
+ blue < 0 || blue > 1000)
+ return ERR;
+
+ return PDC_init_color(color, red, green, blue);
+}
+
+int color_content(short color, short *red, short *green, short *blue)
+{
+ PDC_LOG(("color_content() - called\n"));
+
+ if (color < 0 || color >= COLORS || !red || !green || !blue)
+ return ERR;
+
+ if (PDC_can_change_color())
+ return PDC_color_content(color, red, green, blue);
+ else
+ {
+ /* Simulated values for platforms that don't support palette
+ changing */
+
+ short maxval = (color & 8) ? 1000 : 680;
+
+ *red = (color & COLOR_RED) ? maxval : 0;
+ *green = (color & COLOR_GREEN) ? maxval : 0;
+ *blue = (color & COLOR_BLUE) ? maxval : 0;
+
+ return OK;
+ }
+}
+
+bool can_change_color(void)
+{
+ PDC_LOG(("can_change_color() - called\n"));
+
+ return PDC_can_change_color();
+}
+
+int pair_content(short pair, short *fg, short *bg)
+{
+ PDC_LOG(("pair_content() - called\n"));
+
+ if (pair < 0 || pair >= COLOR_PAIRS || !fg || !bg)
+ return ERR;
+
+ return PDC_pair_content(pair, fg, bg);
+}
+
+int assume_default_colors(int f, int b)
+{
+ PDC_LOG(("assume_default_colors() - called: f %d b %d\n", f, b));
+
+ if (f < -1 || f >= COLORS || b < -1 || b >= COLORS)
+ return ERR;
+
+ if (pdc_color_started)
+ {
+ short fg, bg, oldfg, oldbg;
+
+ fg = f;
+ bg = b;
+
+ _normalize(&fg, &bg);
+
+ PDC_pair_content(0, &oldfg, &oldbg);
+
+ if (oldfg != fg || oldbg != bg)
+ curscr->_clear = TRUE;
+
+ PDC_init_pair(0, fg, bg);
+ }
+
+ return OK;
+}
+
+int use_default_colors(void)
+{
+ PDC_LOG(("use_default_colors() - called\n"));
+
+ default_colors = TRUE;
+ first_col = -1;
+
+ return assume_default_colors(-1, -1);
+}
+
+int PDC_set_line_color(short color)
+{
+ PDC_LOG(("PDC_set_line_color() - called: %d\n", color));
+
+ if (color < -1 || color >= COLORS)
+ return ERR;
+
+ SP->line_color = color;
+
+ return OK;
+}
+
+void PDC_init_atrtab(void)
+{
+ int i;
+ short fg, bg;
+
+ if (pdc_color_started && !default_colors)
+ {
+ fg = COLOR_WHITE;
+ bg = COLOR_BLACK;
+ }
+ else
+ fg = bg = -1;
+
+ _normalize(&fg, &bg);
+
+ for (i = 0; i < PDC_COLOR_PAIRS; i++)
+ PDC_init_pair(i, fg, bg);
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/debug.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/debug.c
new file mode 100644
index 0000000000..95dc7d445f
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/debug.c
@@ -0,0 +1,81 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: debug.c,v 1.7 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: debug
+
+ Synopsis:
+ void traceon(void);
+ void traceoff(void);
+ void PDC_debug(const char *, ...);
+
+ Description:
+ traceon() and traceoff() toggle the recording of debugging
+ information to the file "trace". Although not standard, similar
+ functions are in some other curses implementations.
+
+ PDC_debug() is the function that writes to the file, based on
+ whether traceon() has been called. It's used from the PDC_LOG()
+ macro.
+
+ Portability X/Open BSD SYS V
+ traceon - - -
+ traceoff - - -
+ PDC_debug - - -
+
+**man-end****************************************************************/
+
+#include <string.h>
+#include <sys/types.h>
+#include <time.h>
+
+bool pdc_trace_on = FALSE;
+
+void PDC_debug(const char *fmt, ...)
+{
+ va_list args;
+ FILE *dbfp;
+ char hms[9];
+ time_t now;
+
+ if (!pdc_trace_on)
+ return;
+
+ /* open debug log file append */
+
+ dbfp = fopen("trace", "a");
+ if (!dbfp)
+ {
+ fprintf(stderr,
+ "PDC_debug(): Unable to open debug log file\n");
+ return;
+ }
+
+ time(&now);
+ strftime(hms, 9, "%H:%M:%S", localtime(&now));
+ fprintf(dbfp, "At: %8.8ld - %s ", (long) clock(), hms);
+
+ va_start(args, fmt);
+ vfprintf(dbfp, fmt, args);
+ va_end(args);
+
+ fclose(dbfp);
+}
+
+void traceon(void)
+{
+ PDC_LOG(("traceon() - called\n"));
+
+ pdc_trace_on = TRUE;
+}
+
+void traceoff(void)
+{
+ PDC_LOG(("traceoff() - called\n"));
+
+ pdc_trace_on = FALSE;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/delch.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/delch.c
new file mode 100644
index 0000000000..9c2416eefb
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/delch.c
@@ -0,0 +1,93 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: delch.c,v 1.33 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: delch
+
+ Synopsis:
+ int delch(void);
+ int wdelch(WINDOW *win);
+ int mvdelch(int y, int x);
+ int mvwdelch(WINDOW *win, int y, int x);
+
+ Description:
+ The character under the cursor in the window is deleted. All
+ characters to the right on the same line are moved to the left
+ one position and the last character on the line is filled with
+ a blank. The cursor position does not change (after moving to
+ y, x if coordinates are specified).
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ delch Y Y Y
+ wdelch Y Y Y
+ mvdelch Y Y Y
+ mvwdelch Y Y Y
+
+**man-end****************************************************************/
+
+#include <string.h>
+
+int wdelch(WINDOW *win)
+{
+ int y, x, maxx;
+ chtype *temp1;
+
+ PDC_LOG(("wdelch() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ y = win->_cury;
+ x = win->_curx;
+ maxx = win->_maxx - 1;
+ temp1 = &win->_y[y][x];
+
+ memmove(temp1, temp1 + 1, (maxx - x) * sizeof(chtype));
+
+ /* wrs (4/10/93) account for window background */
+
+ win->_y[y][maxx] = win->_bkgd;
+
+ win->_lastch[y] = maxx;
+
+ if ((win->_firstch[y] == _NO_CHANGE) || (win->_firstch[y] > x))
+ win->_firstch[y] = x;
+
+ PDC_sync(win);
+
+ return OK;
+}
+
+int delch(void)
+{
+ PDC_LOG(("delch() - called\n"));
+
+ return wdelch(stdscr);
+}
+
+int mvdelch(int y, int x)
+{
+ PDC_LOG(("mvdelch() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return wdelch(stdscr);
+}
+
+int mvwdelch(WINDOW *win, int y, int x)
+{
+ PDC_LOG(("mvwdelch() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return wdelch(win);
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/deleteln.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/deleteln.c
new file mode 100644
index 0000000000..c856e90a38
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/deleteln.c
@@ -0,0 +1,208 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: deleteln.c,v 1.35 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: deleteln
+
+ Synopsis:
+ int deleteln(void);
+ int wdeleteln(WINDOW *win);
+ int insdelln(int n);
+ int winsdelln(WINDOW *win, int n);
+ int insertln(void);
+ int winsertln(WINDOW *win);
+
+ int mvdeleteln(int y, int x);
+ int mvwdeleteln(WINDOW *win, int y, int x);
+ int mvinsertln(int y, int x);
+ int mvwinsertln(WINDOW *win, int y, int x);
+
+ Description:
+ With the deleteln() and wdeleteln() functions, the line under
+ the cursor in the window is deleted. All lines below the
+ current line are moved up one line. The bottom line of the
+ window is cleared. The cursor position does not change.
+
+ With the insertln() and winsertn() functions, a blank line is
+ inserted above the current line and the bottom line is lost.
+
+ mvdeleteln(), mvwdeleteln(), mvinsertln() and mvwinsertln()
+ allow moving the cursor and inserting/deleting in one call.
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ deleteln Y Y Y
+ wdeleteln Y Y Y
+ mvdeleteln - - -
+ mvwdeleteln - - -
+ insdelln Y - 4.0
+ winsdelln Y - 4.0
+ insertln Y Y Y
+ winsertln Y Y Y
+ mvinsertln - - -
+ mvwinsertln - - -
+
+**man-end****************************************************************/
+
+int wdeleteln(WINDOW *win)
+{
+ chtype blank, *temp, *ptr;
+ int y;
+
+ PDC_LOG(("wdeleteln() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ /* wrs (4/10/93) account for window background */
+
+ blank = win->_bkgd;
+
+ temp = win->_y[win->_cury];
+
+ for (y = win->_cury; y < win->_bmarg; y++)
+ {
+ win->_y[y] = win->_y[y + 1];
+ win->_firstch[y] = 0;
+ win->_lastch[y] = win->_maxx - 1;
+ }
+
+ for (ptr = temp; (ptr - temp < win->_maxx); ptr++)
+ *ptr = blank; /* make a blank line */
+
+ if (win->_cury <= win->_bmarg)
+ {
+ win->_firstch[win->_bmarg] = 0;
+ win->_lastch[win->_bmarg] = win->_maxx - 1;
+ win->_y[win->_bmarg] = temp;
+ }
+
+ return OK;
+}
+
+int deleteln(void)
+{
+ PDC_LOG(("deleteln() - called\n"));
+
+ return wdeleteln(stdscr);
+}
+
+int mvdeleteln(int y, int x)
+{
+ PDC_LOG(("mvdeleteln() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return wdeleteln(stdscr);
+}
+
+int mvwdeleteln(WINDOW *win, int y, int x)
+{
+ PDC_LOG(("mvwdeleteln() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return wdeleteln(win);
+}
+
+int winsdelln(WINDOW *win, int n)
+{
+ int i;
+
+ PDC_LOG(("winsdelln() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ if (n > 0)
+ {
+ for (i = 0; i < n; i++)
+ if (winsertln(win) == ERR)
+ return ERR;
+ }
+ else if (n < 0)
+ {
+ n = -n;
+ for (i = 0; i < n; i++)
+ if (wdeleteln(win) == ERR)
+ return ERR;
+ }
+
+ return OK;
+}
+
+int insdelln(int n)
+{
+ PDC_LOG(("insdelln() - called\n"));
+
+ return winsdelln(stdscr, n);
+}
+
+int winsertln(WINDOW *win)
+{
+ chtype blank, *temp, *end;
+ int y;
+
+ PDC_LOG(("winsertln() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ /* wrs (4/10/93) account for window background */
+
+ blank = win->_bkgd;
+
+ temp = win->_y[win->_maxy - 1];
+
+ for (y = win->_maxy - 1; y > win->_cury; y--)
+ {
+ win->_y[y] = win->_y[y - 1];
+ win->_firstch[y] = 0;
+ win->_lastch[y] = win->_maxx - 1;
+ }
+
+ win->_y[win->_cury] = temp;
+
+ for (end = &temp[win->_maxx - 1]; temp <= end; temp++)
+ *temp = blank;
+
+ win->_firstch[win->_cury] = 0;
+ win->_lastch[win->_cury] = win->_maxx - 1;
+
+ return OK;
+}
+
+int insertln(void)
+{
+ PDC_LOG(("insertln() - called\n"));
+
+ return winsertln(stdscr);
+}
+
+int mvinsertln(int y, int x)
+{
+ PDC_LOG(("mvinsertln() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return winsertln(stdscr);
+}
+
+int mvwinsertln(WINDOW *win, int y, int x)
+{
+ PDC_LOG(("mvwinsertln() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return winsertln(win);
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/deprec.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/deprec.c
new file mode 100644
index 0000000000..83e6131102
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/deprec.c
@@ -0,0 +1,29 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: deprec.c,v 1.6 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/* Deprecated functions. These should not be used, and will eventually
+ be removed. They're here solely for the benefit of applications that
+ linked to them in older versions of PDCurses. */
+
+bool PDC_check_bios_key(void)
+{
+ return PDC_check_key();
+}
+
+int PDC_get_bios_key(void)
+{
+ return PDC_get_key();
+}
+
+bool PDC_get_ctrl_break(void)
+{
+ return !SP->raw_inp;
+}
+
+int PDC_set_ctrl_break(bool setting)
+{
+ return setting ? noraw() : raw();
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/getch.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/getch.c
new file mode 100644
index 0000000000..87677bae2e
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/getch.c
@@ -0,0 +1,410 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: getch.c,v 1.72 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: getch
+
+ Synopsis:
+ int getch(void);
+ int wgetch(WINDOW *win);
+ int mvgetch(int y, int x);
+ int mvwgetch(WINDOW *win, int y, int x);
+ int ungetch(int ch);
+ int flushinp(void);
+
+ int get_wch(wint_t *wch);
+ int wget_wch(WINDOW *win, wint_t *wch);
+ int mvget_wch(int y, int x, wint_t *wch);
+ int mvwget_wch(WINDOW *win, int y, int x, wint_t *wch);
+ int unget_wch(const wchar_t wch);
+
+ unsigned long PDC_get_key_modifiers(void);
+ int PDC_save_key_modifiers(bool flag);
+ int PDC_return_key_modifiers(bool flag);
+
+ Description:
+ With the getch(), wgetch(), mvgetch(), and mvwgetch() functions,
+ a character is read from the terminal associated with the window.
+ In nodelay mode, if there is no input waiting, the value ERR is
+ returned. In delay mode, the program will hang until the system
+ passes text through to the program. Depending on the setting of
+ cbreak(), this will be after one character or after the first
+ newline. Unless noecho() has been set, the character will also
+ be echoed into the designated window.
+
+ If keypad() is TRUE, and a function key is pressed, the token for
+ that function key will be returned instead of the raw characters.
+ Possible function keys are defined in <curses.h> with integers
+ beginning with 0401, whose names begin with KEY_.
+
+ If nodelay(win, TRUE) has been called on the window and no input
+ is waiting, the value ERR is returned.
+
+ ungetch() places ch back onto the input queue to be returned by
+ the next call to wgetch().
+
+ flushinp() throws away any type-ahead that has been typed by the
+ user and has not yet been read by the program.
+
+ PDC_get_key_modifiers() returns the keyboard modifiers (shift,
+ control, alt, numlock) effective at the time of the last getch()
+ call, if PDC_save_key_modifiers(TRUE) has been called before the
+ getch(). Use the macros PDC_KEY_MODIFIER_* to determine which
+ modifier(s) were set. PDC_return_key_modifiers() tells getch()
+ to return modifier keys pressed alone as keystrokes (KEY_ALT_L,
+ etc.). These may not work on all platforms.
+
+ NOTE: getch() and ungetch() are implemented as macros, to avoid
+ conflict with many DOS compiler's runtime libraries.
+
+ Return Value:
+ These functions return ERR or the value of the character, meta
+ character or function key token.
+
+ Portability X/Open BSD SYS V
+ getch Y Y Y
+ wgetch Y Y Y
+ mvgetch Y Y Y
+ mvwgetch Y Y Y
+ ungetch Y Y Y
+ flushinp Y Y Y
+ get_wch Y
+ wget_wch Y
+ mvget_wch Y
+ mvwget_wch Y
+ unget_wch Y
+ PDC_get_key_modifiers - - -
+
+**man-end****************************************************************/
+
+#define _INBUFSIZ 512 /* size of terminal input buffer */
+#define NUNGETCH 256 /* max # chars to ungetch() */
+
+static int c_pindex = 0; /* putter index */
+static int c_gindex = 1; /* getter index */
+static int c_ungind = 0; /* ungetch() push index */
+static int c_ungch[NUNGETCH]; /* array of ungotten chars */
+
+static int _mouse_key(WINDOW *win)
+{
+ int i, key = KEY_MOUSE;
+ unsigned long mbe = SP->_trap_mbe;
+
+ /* Filter unwanted mouse events */
+
+ for (i = 0; i < 3; i++)
+ {
+ if (pdc_mouse_status.changes & (1 << i))
+ {
+ int shf = i * 5;
+ short button = pdc_mouse_status.button[i] & BUTTON_ACTION_MASK;
+
+ if ( (!(mbe & (BUTTON1_PRESSED << shf)) &&
+ (button == BUTTON_PRESSED))
+
+ || (!(mbe & (BUTTON1_CLICKED << shf)) &&
+ (button == BUTTON_CLICKED))
+
+ || (!(mbe & (BUTTON1_DOUBLE_CLICKED << shf)) &&
+ (button == BUTTON_DOUBLE_CLICKED))
+
+ || (!(mbe & (BUTTON1_MOVED << shf)) &&
+ (button == BUTTON_MOVED))
+
+ || (!(mbe & (BUTTON1_RELEASED << shf)) &&
+ (button == BUTTON_RELEASED))
+ )
+ pdc_mouse_status.changes ^= (1 << i);
+ }
+ }
+
+ if (pdc_mouse_status.changes & PDC_MOUSE_MOVED)
+ {
+ if (!(mbe & (BUTTON1_MOVED|BUTTON2_MOVED|BUTTON3_MOVED)))
+ pdc_mouse_status.changes ^= PDC_MOUSE_MOVED;
+ }
+
+ if (pdc_mouse_status.changes &
+ (PDC_MOUSE_WHEEL_UP|PDC_MOUSE_WHEEL_DOWN))
+ {
+ if (!(mbe & MOUSE_WHEEL_SCROLL))
+ pdc_mouse_status.changes &=
+ ~(PDC_MOUSE_WHEEL_UP|PDC_MOUSE_WHEEL_DOWN);
+ }
+
+ if (!pdc_mouse_status.changes)
+ return -1;
+
+ /* Check for click in slk area */
+
+ i = PDC_mouse_in_slk(pdc_mouse_status.y, pdc_mouse_status.x);
+
+ if (i)
+ {
+ if (pdc_mouse_status.button[0] & (BUTTON_PRESSED|BUTTON_CLICKED))
+ key = KEY_F(i);
+ else
+ key = -1;
+ }
+
+ return key;
+}
+
+int wgetch(WINDOW *win)
+{
+ static int buffer[_INBUFSIZ]; /* character buffer */
+ int key, waitcount;
+
+ PDC_LOG(("wgetch() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ waitcount = 0;
+
+ /* set the number of 1/20th second napms() calls */
+
+ if (SP->delaytenths)
+ waitcount = 2 * SP->delaytenths;
+ else
+ if (win->_delayms)
+ {
+ /* Can't really do millisecond intervals, so delay in
+ 1/20ths of a second (50ms) */
+
+ waitcount = win->_delayms / 50;
+ if (!waitcount)
+ waitcount = 1;
+ }
+
+ /* refresh window when wgetch is called if there have been changes
+ to it and it is not a pad */
+
+ if (!(win->_flags & _PAD) && ((!win->_leaveit &&
+ (win->_begx + win->_curx != SP->curscol ||
+ win->_begy + win->_cury != SP->cursrow)) || is_wintouched(win)))
+ wrefresh(win);
+
+ /* if ungotten char exists, remove and return it */
+
+ if (c_ungind)
+ return c_ungch[--c_ungind];
+
+ /* if normal and data in buffer */
+
+ if ((!SP->raw_inp && !SP->cbreak) && (c_gindex < c_pindex))
+ return buffer[c_gindex++];
+
+ /* prepare to buffer data */
+
+ c_pindex = 0;
+ c_gindex = 0;
+
+ /* to get here, no keys are buffered. go and get one. */
+
+ for (;;) /* loop for any buffering */
+ {
+ /* is there a keystroke ready? */
+
+ if (!PDC_check_key())
+ {
+ /* if not, handle timeout() and halfdelay() */
+
+ if (SP->delaytenths || win->_delayms)
+ {
+ if (!waitcount)
+ return ERR;
+
+ waitcount--;
+ }
+ else
+ if (win->_nodelay)
+ return ERR;
+
+ napms(50); /* sleep for 1/20th second */
+ continue; /* then check again */
+ }
+
+ /* if there is, fetch it */
+
+ key = PDC_get_key();
+
+ if (SP->key_code)
+ {
+ /* filter special keys if not in keypad mode */
+
+ if (!win->_use_keypad)
+ key = -1;
+
+ /* filter mouse events; translate mouse clicks in the slk
+ area to function keys */
+
+ else if (key == KEY_MOUSE)
+ key = _mouse_key(win);
+ }
+
+ /* unwanted key? loop back */
+
+ if (key == -1)
+ continue;
+
+ /* translate CR */
+
+ if (key == '\r' && SP->autocr && !SP->raw_inp)
+ key = '\n';
+
+ /* if echo is enabled */
+
+ if (SP->echo && !SP->key_code)
+ {
+ waddch(win, key);
+ wrefresh(win);
+ }
+
+ /* if no buffering */
+
+ if (SP->raw_inp || SP->cbreak)
+ return key;
+
+ /* if no overflow, put data in buffer */
+
+ if (key == '\b')
+ {
+ if (c_pindex > c_gindex)
+ c_pindex--;
+ }
+ else
+ if (c_pindex < _INBUFSIZ - 2)
+ buffer[c_pindex++] = key;
+
+ /* if we got a line */
+
+ if (key == '\n' || key == '\r')
+ return buffer[c_gindex++];
+ }
+}
+
+int mvgetch(int y, int x)
+{
+ PDC_LOG(("mvgetch() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return wgetch(stdscr);
+}
+
+int mvwgetch(WINDOW *win, int y, int x)
+{
+ PDC_LOG(("mvwgetch() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return wgetch(win);
+}
+
+int PDC_ungetch(int ch)
+{
+ PDC_LOG(("ungetch() - called\n"));
+
+ if (c_ungind >= NUNGETCH) /* pushback stack full */
+ return ERR;
+
+ c_ungch[c_ungind++] = ch;
+
+ return OK;
+}
+
+int flushinp(void)
+{
+ PDC_LOG(("flushinp() - called\n"));
+
+ PDC_flushinp();
+
+ c_gindex = 1; /* set indices to kill buffer */
+ c_pindex = 0;
+ c_ungind = 0; /* clear c_ungch array */
+
+ return OK;
+}
+
+unsigned long PDC_get_key_modifiers(void)
+{
+ PDC_LOG(("PDC_get_key_modifiers() - called\n"));
+
+ return pdc_key_modifiers;
+}
+
+int PDC_save_key_modifiers(bool flag)
+{
+ PDC_LOG(("PDC_save_key_modifiers() - called\n"));
+
+ SP->save_key_modifiers = flag;
+ return OK;
+}
+
+int PDC_return_key_modifiers(bool flag)
+{
+ PDC_LOG(("PDC_return_key_modifiers() - called\n"));
+
+ SP->return_key_modifiers = flag;
+ return PDC_modifiers_set();
+}
+
+#ifdef PDC_WIDE
+int wget_wch(WINDOW *win, wint_t *wch)
+{
+ int key;
+
+ PDC_LOG(("wget_wch() - called\n"));
+
+ if (!wch)
+ return ERR;
+
+ key = wgetch(win);
+
+ if (key == ERR)
+ return ERR;
+
+ *wch = key;
+
+ return SP->key_code ? KEY_CODE_YES : OK;
+}
+
+int get_wch(wint_t *wch)
+{
+ PDC_LOG(("get_wch() - called\n"));
+
+ return wget_wch(stdscr, wch);
+}
+
+int mvget_wch(int y, int x, wint_t *wch)
+{
+ PDC_LOG(("mvget_wch() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return wget_wch(stdscr, wch);
+}
+
+int mvwget_wch(WINDOW *win, int y, int x, wint_t *wch)
+{
+ PDC_LOG(("mvwget_wch() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return wget_wch(win, wch);
+}
+
+int unget_wch(const wchar_t wch)
+{
+ return PDC_ungetch(wch);
+}
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/getstr.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/getstr.c
new file mode 100644
index 0000000000..c6386d3158
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/getstr.c
@@ -0,0 +1,471 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: getstr.c,v 1.51 2008/07/14 04:24:51 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: getstr
+
+ Synopsis:
+ int getstr(char *str);
+ int wgetstr(WINDOW *win, char *str);
+ int mvgetstr(int y, int x, char *str);
+ int mvwgetstr(WINDOW *win, int y, int x, char *str);
+ int getnstr(char *str, int n);
+ int wgetnstr(WINDOW *win, char *str, int n);
+ int mvgetnstr(int y, int x, char *str, int n);
+ int mvwgetnstr(WINDOW *win, int y, int x, char *str, int n);
+
+ int get_wstr(wint_t *wstr);
+ int wget_wstr(WINDOW *win, wint_t *wstr);
+ int mvget_wstr(int y, int x, wint_t *wstr);
+ int mvwget_wstr(WINDOW *win, int, int, wint_t *wstr);
+ int getn_wstr(wint_t *wstr, int n);
+ int wgetn_wstr(WINDOW *win, wint_t *wstr, int n);
+ int mvgetn_wstr(int y, int x, wint_t *wstr, int n);
+ int mvwgetn_wstr(WINDOW *win, int y, int x, wint_t *wstr, int n);
+
+ Description:
+ These routines call wgetch() repeatedly to build a string,
+ interpreting erase and kill characters along the way, until a
+ newline or carriage return is received. When PDCurses is built
+ with wide-character support enabled, the narrow-character
+ functions convert the wgetch()'d values into a multibyte string
+ in the current locale before returning it. The resulting string
+ is placed in the area pointed to by *str. The routines with n as
+ the last argument read at most n characters.
+
+ Note that there's no way to know how long the buffer passed to
+ wgetstr() is, so use wgetnstr() to avoid buffer overflows.
+
+ Return Value:
+ This functions return ERR on failure or any other value on
+ success.
+
+ Portability X/Open BSD SYS V
+ getstr Y Y Y
+ wgetstr Y Y Y
+ mvgetstr Y Y Y
+ mvwgetstr Y Y Y
+ getnstr Y - 4.0
+ wgetnstr Y - 4.0
+ mvgetnstr Y - -
+ mvwgetnstr Y - -
+ get_wstr Y
+ wget_wstr Y
+ mvget_wstr Y
+ mvwget_wstr Y
+ getn_wstr Y
+ wgetn_wstr Y
+ mvgetn_wstr Y
+ mvwgetn_wstr Y
+
+**man-end****************************************************************/
+
+#define MAXLINE 255
+
+int wgetnstr(WINDOW *win, char *str, int n)
+{
+#ifdef PDC_WIDE
+ wchar_t wstr[MAXLINE + 1];
+
+ if (n < 0 || n > MAXLINE)
+ n = MAXLINE;
+
+ if (wgetn_wstr(win, (wint_t *)wstr, n) == ERR)
+ return ERR;
+
+ return PDC_wcstombs(str, wstr, n);
+#else
+ int ch, i, num, x, chars;
+ char *p;
+ bool stop, oldecho, oldcbreak, oldnodelay;
+
+ PDC_LOG(("wgetnstr() - called\n"));
+
+ if (!win || !str)
+ return ERR;
+
+ chars = 0;
+ p = str;
+ stop = FALSE;
+
+ x = win->_curx;
+
+ oldcbreak = SP->cbreak; /* remember states */
+ oldecho = SP->echo;
+ oldnodelay = win->_nodelay;
+
+ SP->echo = FALSE; /* we do echo ourselves */
+ cbreak(); /* ensure each key is returned immediately */
+ win->_nodelay = FALSE; /* don't return -1 */
+
+ wrefresh(win);
+
+ while (!stop)
+ {
+ ch = wgetch(win);
+
+ switch (ch)
+ {
+
+ case '\t':
+ ch = ' ';
+ num = TABSIZE - (win->_curx - x) % TABSIZE;
+ for (i = 0; i < num; i++)
+ {
+ if (chars < n)
+ {
+ if (oldecho)
+ waddch(win, ch);
+ *p++ = ch;
+ ++chars;
+ }
+ else
+ beep();
+ }
+ break;
+
+ case _ECHAR: /* CTRL-H -- Delete character */
+ if (p > str)
+ {
+ if (oldecho)
+ waddstr(win, "\b \b");
+ ch = (unsigned char)(*--p);
+ if ((ch < ' ') && (oldecho))
+ waddstr(win, "\b \b");
+ chars--;
+ }
+ break;
+
+ case _DLCHAR: /* CTRL-U -- Delete line */
+ while (p > str)
+ {
+ if (oldecho)
+ waddstr(win, "\b \b");
+ ch = (unsigned char)(*--p);
+ if ((ch < ' ') && (oldecho))
+ waddstr(win, "\b \b");
+ }
+ chars = 0;
+ break;
+
+ case _DWCHAR: /* CTRL-W -- Delete word */
+
+ while ((p > str) && (*(p - 1) == ' '))
+ {
+ if (oldecho)
+ waddstr(win, "\b \b");
+
+ --p; /* remove space */
+ chars--;
+ }
+ while ((p > str) && (*(p - 1) != ' '))
+ {
+ if (oldecho)
+ waddstr(win, "\b \b");
+
+ ch = (unsigned char)(*--p);
+ if ((ch < ' ') && (oldecho))
+ waddstr(win, "\b \b");
+ chars--;
+ }
+ break;
+
+ case '\n':
+ case '\r':
+ stop = TRUE;
+ if (oldecho)
+ waddch(win, '\n');
+ break;
+
+ default:
+ if (chars < n)
+ {
+ if (!SP->key_code && ch < 0x100)
+ {
+ *p++ = ch;
+ if (oldecho)
+ waddch(win, ch);
+ chars++;
+ }
+ }
+ else
+ beep();
+
+ break;
+
+ }
+
+ wrefresh(win);
+ }
+
+ *p = '\0';
+
+ SP->echo = oldecho; /* restore old settings */
+ SP->cbreak = oldcbreak;
+ win->_nodelay = oldnodelay;
+
+ return OK;
+#endif
+}
+
+int getstr(char *str)
+{
+ PDC_LOG(("getstr() - called\n"));
+
+ return wgetnstr(stdscr, str, MAXLINE);
+}
+
+int wgetstr(WINDOW *win, char *str)
+{
+ PDC_LOG(("wgetstr() - called\n"));
+
+ return wgetnstr(win, str, MAXLINE);
+}
+
+int mvgetstr(int y, int x, char *str)
+{
+ PDC_LOG(("mvgetstr() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return wgetnstr(stdscr, str, MAXLINE);
+}
+
+int mvwgetstr(WINDOW *win, int y, int x, char *str)
+{
+ PDC_LOG(("mvwgetstr() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return wgetnstr(win, str, MAXLINE);
+}
+
+int getnstr(char *str, int n)
+{
+ PDC_LOG(("getnstr() - called\n"));
+
+ return wgetnstr(stdscr, str, n);
+}
+
+int mvgetnstr(int y, int x, char *str, int n)
+{
+ PDC_LOG(("mvgetnstr() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return wgetnstr(stdscr, str, n);
+}
+
+int mvwgetnstr(WINDOW *win, int y, int x, char *str, int n)
+{
+ PDC_LOG(("mvwgetnstr() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return wgetnstr(win, str, n);
+}
+
+#ifdef PDC_WIDE
+int wgetn_wstr(WINDOW *win, wint_t *wstr, int n)
+{
+ int ch, i, num, x, chars;
+ wint_t *p;
+ bool stop, oldecho, oldcbreak, oldnodelay;
+
+ PDC_LOG(("wgetn_wstr() - called\n"));
+
+ if (!win || !wstr)
+ return ERR;
+
+ chars = 0;
+ p = wstr;
+ stop = FALSE;
+
+ x = win->_curx;
+
+ oldcbreak = SP->cbreak; /* remember states */
+ oldecho = SP->echo;
+ oldnodelay = win->_nodelay;
+
+ SP->echo = FALSE; /* we do echo ourselves */
+ cbreak(); /* ensure each key is returned immediately */
+ win->_nodelay = FALSE; /* don't return -1 */
+
+ wrefresh(win);
+
+ while (!stop)
+ {
+ ch = wgetch(win);
+
+ switch (ch)
+ {
+
+ case '\t':
+ ch = ' ';
+ num = TABSIZE - (win->_curx - x) % TABSIZE;
+ for (i = 0; i < num; i++)
+ {
+ if (chars < n)
+ {
+ if (oldecho)
+ waddch(win, ch);
+ *p++ = ch;
+ ++chars;
+ }
+ else
+ beep();
+ }
+ break;
+
+ case _ECHAR: /* CTRL-H -- Delete character */
+ if (p > wstr)
+ {
+ if (oldecho)
+ waddstr(win, "\b \b");
+ ch = *--p;
+ if ((ch < ' ') && (oldecho))
+ waddstr(win, "\b \b");
+ chars--;
+ }
+ break;
+
+ case _DLCHAR: /* CTRL-U -- Delete line */
+ while (p > wstr)
+ {
+ if (oldecho)
+ waddstr(win, "\b \b");
+ ch = *--p;
+ if ((ch < ' ') && (oldecho))
+ waddstr(win, "\b \b");
+ }
+ chars = 0;
+ break;
+
+ case _DWCHAR: /* CTRL-W -- Delete word */
+
+ while ((p > wstr) && (*(p - 1) == ' '))
+ {
+ if (oldecho)
+ waddstr(win, "\b \b");
+
+ --p; /* remove space */
+ chars--;
+ }
+ while ((p > wstr) && (*(p - 1) != ' '))
+ {
+ if (oldecho)
+ waddstr(win, "\b \b");
+
+ ch = *--p;
+ if ((ch < ' ') && (oldecho))
+ waddstr(win, "\b \b");
+ chars--;
+ }
+ break;
+
+ case '\n':
+ case '\r':
+ stop = TRUE;
+ if (oldecho)
+ waddch(win, '\n');
+ break;
+
+ default:
+ if (chars < n)
+ {
+ if (!SP->key_code)
+ {
+ *p++ = ch;
+ if (oldecho)
+ waddch(win, ch);
+ chars++;
+ }
+ }
+ else
+ beep();
+
+ break;
+
+ }
+
+ wrefresh(win);
+ }
+
+ *p = '\0';
+
+ SP->echo = oldecho; /* restore old settings */
+ SP->cbreak = oldcbreak;
+ win->_nodelay = oldnodelay;
+
+ return OK;
+}
+
+int get_wstr(wint_t *wstr)
+{
+ PDC_LOG(("get_wstr() - called\n"));
+
+ return wgetn_wstr(stdscr, wstr, MAXLINE);
+}
+
+int wget_wstr(WINDOW *win, wint_t *wstr)
+{
+ PDC_LOG(("wget_wstr() - called\n"));
+
+ return wgetn_wstr(win, wstr, MAXLINE);
+}
+
+int mvget_wstr(int y, int x, wint_t *wstr)
+{
+ PDC_LOG(("mvget_wstr() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return wgetn_wstr(stdscr, wstr, MAXLINE);
+}
+
+int mvwget_wstr(WINDOW *win, int y, int x, wint_t *wstr)
+{
+ PDC_LOG(("mvwget_wstr() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return wgetn_wstr(win, wstr, MAXLINE);
+}
+
+int getn_wstr(wint_t *wstr, int n)
+{
+ PDC_LOG(("getn_wstr() - called\n"));
+
+ return wgetn_wstr(stdscr, wstr, n);
+}
+
+int mvgetn_wstr(int y, int x, wint_t *wstr, int n)
+{
+ PDC_LOG(("mvgetn_wstr() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return wgetn_wstr(stdscr, wstr, n);
+}
+
+int mvwgetn_wstr(WINDOW *win, int y, int x, wint_t *wstr, int n)
+{
+ PDC_LOG(("mvwgetn_wstr() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return wgetn_wstr(win, wstr, n);
+}
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/getyx.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/getyx.c
new file mode 100644
index 0000000000..fd0564d904
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/getyx.c
@@ -0,0 +1,143 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: getyx.c,v 1.29 2008/07/15 17:13:26 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: getyx
+
+ Synopsis:
+ void getyx(WINDOW *win, int y, int x);
+ void getparyx(WINDOW *win, int y, int x);
+ void getbegyx(WINDOW *win, int y, int x);
+ void getmaxyx(WINDOW *win, int y, int x);
+
+ void getsyx(int y, int x);
+ int setsyx(int y, int x);
+
+ int getbegy(WINDOW *win);
+ int getbegx(WINDOW *win);
+ int getcury(WINDOW *win);
+ int getcurx(WINDOW *win);
+ int getpary(WINDOW *win);
+ int getparx(WINDOW *win);
+ int getmaxy(WINDOW *win);
+ int getmaxx(WINDOW *win);
+
+ Description:
+ The getyx() macro (defined in curses.h -- the prototypes here
+ are merely illustrative) puts the current cursor position of the
+ specified window into y and x. getbegyx() and getmaxyx() return
+ the starting coordinates and size of the specified window,
+ respectively. getparyx() returns the starting coordinates of the
+ parent's window, if the specified window is a subwindow;
+ otherwise it sets y and x to -1. These are all macros.
+
+ getsyx() gets the coordinates of the virtual screen cursor, and
+ stores them in y and x. If leaveok() is TRUE, it returns -1, -1.
+ If lines have been removed with ripoffline(), then getsyx()
+ includes these lines in its count; so, the returned y and x
+ values should only be used with setsyx().
+
+ setsyx() sets the virtual screen cursor to the y, x coordinates.
+ If y, x are -1, -1, leaveok() is set TRUE.
+
+ getsyx() and setsyx() are meant to be used by a library routine
+ that manipulates curses windows without altering the position of
+ the cursor. Note that getsyx() is defined only as a macro.
+
+ getbegy(), getbegx(), getcurx(), getcury(), getmaxy(),
+ getmaxx(), getpary(), and getparx() return the appropriate
+ coordinate or size values, or ERR in the case of a NULL window.
+
+ Portability X/Open BSD SYS V
+ getyx Y Y Y
+ getparyx - - 4.0
+ getbegyx - - 3.0
+ getmaxyx - - 3.0
+ getsyx - - 3.0
+ setsyx - - 3.0
+ getbegy - - -
+ getbegx - - -
+ getcury - - -
+ getcurx - - -
+ getpary - - -
+ getparx - - -
+ getmaxy - - -
+ getmaxx - - -
+
+**man-end****************************************************************/
+
+int getbegy(WINDOW *win)
+{
+ PDC_LOG(("getbegy() - called\n"));
+
+ return win ? win->_begy : ERR;
+}
+
+int getbegx(WINDOW *win)
+{
+ PDC_LOG(("getbegx() - called\n"));
+
+ return win ? win->_begx : ERR;
+}
+
+int getcury(WINDOW *win)
+{
+ PDC_LOG(("getcury() - called\n"));
+
+ return win ? win->_cury : ERR;
+}
+
+int getcurx(WINDOW *win)
+{
+ PDC_LOG(("getcurx() - called\n"));
+
+ return win ? win->_curx : ERR;
+}
+
+int getpary(WINDOW *win)
+{
+ PDC_LOG(("getpary() - called\n"));
+
+ return win ? win->_pary : ERR;
+}
+
+int getparx(WINDOW *win)
+{
+ PDC_LOG(("getparx() - called\n"));
+
+ return win ? win->_parx : ERR;
+}
+
+int getmaxy(WINDOW *win)
+{
+ PDC_LOG(("getmaxy() - called\n"));
+
+ return win ? win->_maxy : ERR;
+}
+
+int getmaxx(WINDOW *win)
+{
+ PDC_LOG(("getmaxx() - called\n"));
+
+ return win ? win->_maxx : ERR;
+}
+
+int setsyx(int y, int x)
+{
+ PDC_LOG(("setsyx() - called\n"));
+
+ if(y == -1 && x == -1)
+ {
+ curscr->_leaveit = TRUE;
+ return OK;
+ }
+ else
+ {
+ curscr->_leaveit = FALSE;
+ return wmove(curscr, y, x);
+ }
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/inch.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/inch.c
new file mode 100644
index 0000000000..7347e74032
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/inch.c
@@ -0,0 +1,125 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: inch.c,v 1.33 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: inch
+
+ Synopsis:
+ chtype inch(void);
+ chtype winch(WINDOW *win);
+ chtype mvinch(int y, int x);
+ chtype mvwinch(WINDOW *win, int y, int x);
+
+ int in_wch(cchar_t *wcval);
+ int win_wch(WINDOW *win, cchar_t *wcval);
+ int mvin_wch(int y, int x, cchar_t *wcval);
+ int mvwin_wch(WINDOW *win, int y, int x, cchar_t *wcval);
+
+ Description:
+ The inch() functions retrieve the character and attribute from
+ the current or specified window position, in the form of a
+ chtype. If a NULL window is specified, (chtype)ERR is returned.
+
+ The in_wch() functions are the wide-character versions; instead
+ of returning a chtype, they store a cchar_t at the address
+ specified by wcval, and return OK or ERR. (No value is stored
+ when ERR is returned.) Note that in PDCurses, chtype and cchar_t
+ are the same.
+
+ Portability X/Open BSD SYS V
+ inch Y Y Y
+ winch Y Y Y
+ mvinch Y Y Y
+ mvwinch Y Y Y
+ in_wch Y
+ win_wch Y
+ mvin_wch Y
+ mvwin_wch Y
+
+**man-end****************************************************************/
+
+chtype winch(WINDOW *win)
+{
+ PDC_LOG(("winch() - called\n"));
+
+ if (!win)
+ return (chtype)ERR;
+
+ return win->_y[win->_cury][win->_curx];
+}
+
+chtype inch(void)
+{
+ PDC_LOG(("inch() - called\n"));
+
+ return winch(stdscr);
+}
+
+chtype mvinch(int y, int x)
+{
+ PDC_LOG(("mvinch() - called\n"));
+
+ if (move(y, x) == ERR)
+ return (chtype)ERR;
+
+ return stdscr->_y[stdscr->_cury][stdscr->_curx];
+}
+
+chtype mvwinch(WINDOW *win, int y, int x)
+{
+ PDC_LOG(("mvwinch() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return (chtype)ERR;
+
+ return win->_y[win->_cury][win->_curx];
+}
+
+#ifdef PDC_WIDE
+int win_wch(WINDOW *win, cchar_t *wcval)
+{
+ PDC_LOG(("win_wch() - called\n"));
+
+ if (!win || !wcval)
+ return ERR;
+
+ *wcval = win->_y[win->_cury][win->_curx];
+
+ return OK;
+}
+
+int in_wch(cchar_t *wcval)
+{
+ PDC_LOG(("in_wch() - called\n"));
+
+ return win_wch(stdscr, wcval);
+}
+
+int mvin_wch(int y, int x, cchar_t *wcval)
+{
+ PDC_LOG(("mvin_wch() - called\n"));
+
+ if (!wcval || (move(y, x) == ERR))
+ return ERR;
+
+ *wcval = stdscr->_y[stdscr->_cury][stdscr->_curx];
+
+ return OK;
+}
+
+int mvwin_wch(WINDOW *win, int y, int x, cchar_t *wcval)
+{
+ PDC_LOG(("mvwin_wch() - called\n"));
+
+ if (!wcval || (wmove(win, y, x) == ERR))
+ return ERR;
+
+ *wcval = win->_y[win->_cury][win->_curx];
+
+ return OK;
+}
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/inchstr.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/inchstr.c
new file mode 100644
index 0000000000..50b8cf5bc7
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/inchstr.c
@@ -0,0 +1,211 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: inchstr.c,v 1.34 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: inchstr
+
+ Synopsis:
+ int inchstr(chtype *ch);
+ int inchnstr(chtype *ch, int n);
+ int winchstr(WINDOW *win, chtype *ch);
+ int winchnstr(WINDOW *win, chtype *ch, int n);
+ int mvinchstr(int y, int x, chtype *ch);
+ int mvinchnstr(int y, int x, chtype *ch, int n);
+ int mvwinchstr(WINDOW *, int y, int x, chtype *ch);
+ int mvwinchnstr(WINDOW *, int y, int x, chtype *ch, int n);
+
+ int in_wchstr(cchar_t *wch);
+ int in_wchnstr(cchar_t *wch, int n);
+ int win_wchstr(WINDOW *win, cchar_t *wch);
+ int win_wchnstr(WINDOW *win, cchar_t *wch, int n);
+ int mvin_wchstr(int y, int x, cchar_t *wch);
+ int mvin_wchnstr(int y, int x, cchar_t *wch, int n);
+ int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wch);
+ int mvwin_wchnstr(WINDOW *win, int y, int x, cchar_t *wch, int n);
+
+ Description:
+ These routines read a chtype or cchar_t string from the window,
+ starting at the current or specified position, and ending at the
+ right margin, or after n elements, whichever is less.
+
+ Return Value:
+ All functions return the number of elements read, or ERR on
+ error.
+
+ Portability X/Open BSD SYS V
+ inchstr Y - 4.0
+ winchstr Y - 4.0
+ mvinchstr Y - 4.0
+ mvwinchstr Y - 4.0
+ inchnstr Y - 4.0
+ winchnstr Y - 4.0
+ mvinchnstr Y - 4.0
+ mvwinchnstr Y - 4.0
+ in_wchstr Y
+ win_wchstr Y
+ mvin_wchstr Y
+ mvwin_wchstr Y
+ in_wchnstr Y
+ win_wchnstr Y
+ mvin_wchnstr Y
+ mvwin_wchnstr Y
+
+**man-end****************************************************************/
+
+int winchnstr(WINDOW *win, chtype *ch, int n)
+{
+ chtype *src;
+ int i;
+
+ PDC_LOG(("winchnstr() - called\n"));
+
+ if (!win || !ch || n < 0)
+ return ERR;
+
+ if ((win->_curx + n) > win->_maxx)
+ n = win->_maxx - win->_curx;
+
+ src = win->_y[win->_cury] + win->_curx;
+
+ for (i = 0; i < n; i++)
+ *ch++ = *src++;
+
+ *ch = (chtype)0;
+
+ return OK;
+}
+
+int inchstr(chtype *ch)
+{
+ PDC_LOG(("inchstr() - called\n"));
+
+ return winchnstr(stdscr, ch, stdscr->_maxx - stdscr->_curx);
+}
+
+int winchstr(WINDOW *win, chtype *ch)
+{
+ PDC_LOG(("winchstr() - called\n"));
+
+ return winchnstr(win, ch, win->_maxx - win->_curx);
+}
+
+int mvinchstr(int y, int x, chtype *ch)
+{
+ PDC_LOG(("mvinchstr() - called: y %d x %d\n", y, x));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return winchnstr(stdscr, ch, stdscr->_maxx - stdscr->_curx);
+}
+
+int mvwinchstr(WINDOW *win, int y, int x, chtype *ch)
+{
+ PDC_LOG(("mvwinchstr() - called:\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return winchnstr(win, ch, win->_maxx - win->_curx);
+}
+
+int inchnstr(chtype *ch, int n)
+{
+ PDC_LOG(("inchnstr() - called\n"));
+
+ return winchnstr(stdscr, ch, n);
+}
+
+int mvinchnstr(int y, int x, chtype *ch, int n)
+{
+ PDC_LOG(("mvinchnstr() - called: y %d x %d n %d\n", y, x, n));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return winchnstr(stdscr, ch, n);
+}
+
+int mvwinchnstr(WINDOW *win, int y, int x, chtype *ch, int n)
+{
+ PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y, x, n));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return winchnstr(win, ch, n);
+}
+
+#ifdef PDC_WIDE
+int win_wchnstr(WINDOW *win, cchar_t *wch, int n)
+{
+ PDC_LOG(("win_wchnstr() - called\n"));
+
+ return winchnstr(win, wch, n);
+}
+
+int in_wchstr(cchar_t *wch)
+{
+ PDC_LOG(("in_wchstr() - called\n"));
+
+ return win_wchnstr(stdscr, wch, stdscr->_maxx - stdscr->_curx);
+}
+
+int win_wchstr(WINDOW *win, cchar_t *wch)
+{
+ PDC_LOG(("win_wchstr() - called\n"));
+
+ return win_wchnstr(win, wch, win->_maxx - win->_curx);
+}
+
+int mvin_wchstr(int y, int x, cchar_t *wch)
+{
+ PDC_LOG(("mvin_wchstr() - called: y %d x %d\n", y, x));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return win_wchnstr(stdscr, wch, stdscr->_maxx - stdscr->_curx);
+}
+
+int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wch)
+{
+ PDC_LOG(("mvwin_wchstr() - called:\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return win_wchnstr(win, wch, win->_maxx - win->_curx);
+}
+
+int in_wchnstr(cchar_t *wch, int n)
+{
+ PDC_LOG(("in_wchnstr() - called\n"));
+
+ return win_wchnstr(stdscr, wch, n);
+}
+
+int mvin_wchnstr(int y, int x, cchar_t *wch, int n)
+{
+ PDC_LOG(("mvin_wchnstr() - called: y %d x %d n %d\n", y, x, n));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return win_wchnstr(stdscr, wch, n);
+}
+
+int mvwin_wchnstr(WINDOW *win, int y, int x, cchar_t *wch, int n)
+{
+ PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y, x, n));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return win_wchnstr(win, wch, n);
+}
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/initscr.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/initscr.c
new file mode 100644
index 0000000000..d80fa0cf4e
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/initscr.c
@@ -0,0 +1,339 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: initscr.c,v 1.114 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: initscr
+
+ Synopsis:
+ WINDOW *initscr(void);
+ WINDOW *Xinitscr(int argc, char *argv[]);
+ int endwin(void);
+ bool isendwin(void);
+ SCREEN *newterm(const char *type, FILE *outfd, FILE *infd);
+ SCREEN *set_term(SCREEN *new);
+ void delscreen(SCREEN *sp);
+
+ int resize_term(int nlines, int ncols);
+ bool is_termresized(void);
+ const char *curses_version(void);
+
+ Description:
+ initscr() should be the first curses routine called. It will
+ initialize all curses data structures, and arrange that the
+ first call to refresh() will clear the screen. In case of
+ error, initscr() will write a message to standard error and end
+ the program.
+
+ endwin() should be called before exiting or escaping from curses
+ mode temporarily. It will restore tty modes, move the cursor to
+ the lower left corner of the screen and reset the terminal into
+ the proper non-visual mode. To resume curses after a temporary
+ escape, call refresh() or doupdate().
+
+ isendwin() returns TRUE if endwin() has been called without a
+ subsequent refresh, unless SP is NULL.
+
+ In some implementations of curses, newterm() allows the use of
+ multiple terminals. Here, it's just an alternative interface for
+ initscr(). It always returns SP, or NULL.
+
+ delscreen() frees the memory allocated by newterm() or
+ initscr(), since it's not freed by endwin(). This function is
+ usually not needed. In PDCurses, the parameter must be the
+ value of SP, and delscreen() sets SP to NULL.
+
+ set_term() does nothing meaningful in PDCurses, but is included
+ for compatibility with other curses implementations.
+
+ resize_term() is effectively two functions: When called with
+ nonzero values for nlines and ncols, it attempts to resize the
+ screen to the given size. When called with (0, 0), it merely
+ adjusts the internal structures to match the current size after
+ the screen is resized by the user. On the currently supported
+ platforms, this functionality is mutually exclusive: X11 allows
+ user resizing, while DOS, OS/2 and Win32 allow programmatic
+ resizing. If you want to support user resizing, you should check
+ for getch() returning KEY_RESIZE, and/or call is_termresized()
+ at appropriate times; if either condition occurs, call
+ resize_term(0, 0). Then, with either user or programmatic
+ resizing, you'll have to resize any windows you've created, as
+ appropriate; resize_term() only handles stdscr and curscr.
+
+ is_termresized() returns TRUE if the curses screen has been
+ resized by the user, and a call to resize_term() is needed.
+ Checking for KEY_RESIZE is generally preferable, unless you're
+ not handling the keyboard.
+
+ curses_version() returns a string describing the version of
+ PDCurses.
+
+ Return Value:
+ All functions return NULL on error, except endwin(), which
+ returns ERR on error.
+
+ Portability X/Open BSD SYS V
+ initscr Y Y Y
+ endwin Y Y Y
+ isendwin Y - 3.0
+ newterm Y - Y
+ set_term Y - Y
+ delscreen Y - 4.0
+ resize_term - - -
+ is_termresized - - -
+ curses_version - - -
+
+**man-end****************************************************************/
+
+#include <stdlib.h>
+
+char ttytype[128];
+
+const char *_curses_notice = "PDCurses 3.4 - Public Domain 2008";
+
+SCREEN *SP = (SCREEN*)NULL; /* curses variables */
+WINDOW *curscr = (WINDOW *)NULL; /* the current screen image */
+WINDOW *stdscr = (WINDOW *)NULL; /* the default screen window */
+WINDOW *pdc_lastscr = (WINDOW *)NULL; /* the last screen image */
+
+int LINES = 0; /* current terminal height */
+int COLS = 0; /* current terminal width */
+int TABSIZE = 8;
+
+MOUSE_STATUS Mouse_status, pdc_mouse_status;
+
+extern RIPPEDOFFLINE linesripped[5];
+extern char linesrippedoff;
+
+WINDOW *Xinitscr(int argc, char *argv[])
+{
+ int i;
+
+ PDC_LOG(("Xinitscr() - called\n"));
+
+ if (SP && SP->alive)
+ return NULL;
+
+ if (PDC_scr_open(argc, argv) == ERR)
+ {
+ fprintf(stderr, "initscr(): Unable to create SP\n");
+ exit(8);
+ }
+
+ SP->autocr = TRUE; /* cr -> lf by default */
+ SP->raw_out = FALSE; /* tty I/O modes */
+ SP->raw_inp = FALSE; /* tty I/O modes */
+ SP->cbreak = TRUE;
+ SP->save_key_modifiers = FALSE;
+ SP->return_key_modifiers = FALSE;
+ SP->echo = TRUE;
+ SP->visibility = 1;
+ SP->resized = FALSE;
+ SP->_trap_mbe = 0L;
+ SP->_map_mbe_to_key = 0L;
+ SP->linesrippedoff = 0;
+ SP->linesrippedoffontop = 0;
+ SP->delaytenths = 0;
+ SP->line_color = -1;
+
+ SP->orig_cursor = PDC_get_cursor_mode();
+
+ LINES = SP->lines;
+ COLS = SP->cols;
+
+ if (LINES < 2 || COLS < 2)
+ {
+ fprintf(stderr, "initscr(): LINES=%d COLS=%d: too small.\n",
+ LINES, COLS);
+ exit(4);
+ }
+
+ if ((curscr = newwin(LINES, COLS, 0, 0)) == (WINDOW *)NULL)
+ {
+ fprintf(stderr, "initscr(): Unable to create curscr.\n");
+ exit(2);
+ }
+
+ if ((pdc_lastscr = newwin(LINES, COLS, 0, 0)) == (WINDOW *)NULL)
+ {
+ fprintf(stderr, "initscr(): Unable to create pdc_lastscr.\n");
+ exit(2);
+ }
+
+ wattrset(pdc_lastscr, (chtype)(-1));
+ werase(pdc_lastscr);
+
+ PDC_slk_initialize();
+ LINES -= SP->slklines;
+
+ /* We have to sort out ripped off lines here, and reduce the height
+ of stdscr by the number of lines ripped off */
+
+ for (i = 0; i < linesrippedoff; i++)
+ {
+ if (linesripped[i].line < 0)
+ (*linesripped[i].init)(newwin(1, COLS, LINES - 1, 0), COLS);
+ else
+ (*linesripped[i].init)(newwin(1, COLS,
+ SP->linesrippedoffontop++, 0), COLS);
+
+ SP->linesrippedoff++;
+ LINES--;
+ }
+
+ linesrippedoff = 0;
+
+ if (!(stdscr = newwin(LINES, COLS, SP->linesrippedoffontop, 0)))
+ {
+ fprintf(stderr, "initscr(): Unable to create stdscr.\n");
+ exit(1);
+ }
+
+ wclrtobot(stdscr);
+
+ /* If preserving the existing screen, don't allow a screen clear */
+
+ if (SP->_preserve)
+ {
+ untouchwin(curscr);
+ untouchwin(stdscr);
+ stdscr->_clear = FALSE;
+ curscr->_clear = FALSE;
+ }
+ else
+ curscr->_clear = TRUE;
+
+ PDC_init_atrtab(); /* set up default colors */
+
+ MOUSE_X_POS = MOUSE_Y_POS = -1;
+ BUTTON_STATUS(1) = BUTTON_RELEASED;
+ BUTTON_STATUS(2) = BUTTON_RELEASED;
+ BUTTON_STATUS(3) = BUTTON_RELEASED;
+ Mouse_status.changes = 0;
+
+ SP->alive = TRUE;
+
+ def_shell_mode();
+
+ sprintf(ttytype, "pdcurses|PDCurses for %s", PDC_sysname());
+
+ return stdscr;
+}
+
+WINDOW *initscr(void)
+{
+ PDC_LOG(("initscr() - called\n"));
+
+ return Xinitscr(0, NULL);
+}
+
+int endwin(void)
+{
+ PDC_LOG(("endwin() - called\n"));
+
+ /* Allow temporary exit from curses using endwin() */
+
+ def_prog_mode();
+ PDC_scr_close();
+
+ SP->alive = FALSE;
+
+ return OK;
+}
+
+bool isendwin(void)
+{
+ PDC_LOG(("isendwin() - called\n"));
+
+ return SP ? !(SP->alive) : FALSE;
+}
+
+SCREEN *newterm(const char *type, FILE *outfd, FILE *infd)
+{
+ PDC_LOG(("newterm() - called\n"));
+
+ return Xinitscr(0, NULL) ? SP : NULL;
+}
+
+SCREEN *set_term(SCREEN *new)
+{
+ PDC_LOG(("set_term() - called\n"));
+
+ /* We only support one screen */
+
+ return (new == SP) ? SP : NULL;
+}
+
+void delscreen(SCREEN *sp)
+{
+ PDC_LOG(("delscreen() - called\n"));
+
+ if (sp != SP)
+ return;
+
+ PDC_slk_free(); /* free the soft label keys, if needed */
+
+ delwin(stdscr);
+ delwin(curscr);
+ delwin(pdc_lastscr);
+ stdscr = (WINDOW *)NULL;
+ curscr = (WINDOW *)NULL;
+ pdc_lastscr = (WINDOW *)NULL;
+
+ SP->alive = FALSE;
+
+ PDC_scr_free(); /* free SP and pdc_atrtab */
+
+ SP = (SCREEN *)NULL;
+}
+
+int resize_term(int nlines, int ncols)
+{
+ PDC_LOG(("resize_term() - called: nlines %d\n", nlines));
+
+ if (!stdscr || PDC_resize_screen(nlines, ncols) == ERR)
+ return ERR;
+
+ SP->lines = PDC_get_rows();
+ LINES = SP->lines - SP->linesrippedoff - SP->slklines;
+ SP->cols = COLS = PDC_get_columns();
+
+ if (wresize(curscr, SP->lines, SP->cols) == ERR ||
+ wresize(stdscr, LINES, COLS) == ERR ||
+ wresize(pdc_lastscr, SP->lines, SP->cols) == ERR)
+ return ERR;
+
+ werase(pdc_lastscr);
+ curscr->_clear = TRUE;
+
+ if (SP->slk_winptr)
+ {
+ if (wresize(SP->slk_winptr, SP->slklines, COLS) == ERR)
+ return ERR;
+
+ wmove(SP->slk_winptr, 0, 0);
+ wclrtobot(SP->slk_winptr);
+ PDC_slk_initialize();
+ slk_noutrefresh();
+ }
+
+ touchwin(stdscr);
+ wnoutrefresh(stdscr);
+
+ return OK;
+}
+
+bool is_termresized(void)
+{
+ PDC_LOG(("is_termresized() - called\n"));
+
+ return SP->resized;
+}
+
+const char *curses_version(void)
+{
+ return _curses_notice;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/inopts.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/inopts.c
new file mode 100644
index 0000000000..6d33fc2a38
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/inopts.c
@@ -0,0 +1,321 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: inopts.c,v 1.43 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: inopts
+
+ Synopsis:
+ int cbreak(void);
+ int nocbreak(void);
+ int echo(void);
+ int noecho(void);
+ int halfdelay(int tenths);
+ int intrflush(WINDOW *win, bool bf);
+ int keypad(WINDOW *win, bool bf);
+ int meta(WINDOW *win, bool bf);
+ int nl(void);
+ int nonl(void);
+ int nodelay(WINDOW *win, bool bf);
+ int notimeout(WINDOW *win, bool bf);
+ int raw(void);
+ int noraw(void);
+ void noqiflush(void);
+ void qiflush(void);
+ void timeout(int delay);
+ void wtimeout(WINDOW *win, int delay);
+ int typeahead(int fildes);
+
+ int crmode(void);
+ int nocrmode(void);
+
+ Description:
+ cbreak() and nocbreak() toggle cbreak mode. In cbreak mode,
+ characters typed by the user are made available immediately, and
+ erase/kill character processing is not performed. In nocbreak
+ mode, typed characters are buffered until a newline or carriage
+ return. Interrupt and flow control characters are unaffected by
+ this mode. PDCurses always starts in cbreak mode.
+
+ echo() and noecho() control whether typed characters are echoed
+ by the input routine. Initially, input characters are echoed.
+ Subsequent calls to echo() and noecho() do not flush type-ahead.
+
+ halfdelay() is similar to cbreak(), but allows for a time limit
+ to be specified, in tenths of a second. This causes getch() to
+ block for that period before returning ERR if no key has been
+ received. tenths must be between 1 and 255.
+
+ keypad() controls whether getch() returns function/special keys
+ as single key codes (e.g., the left arrow key as KEY_LEFT). Per
+ X/Open, the default for keypad mode is OFF. You'll probably want
+ it on. With keypad mode off, if a special key is pressed,
+ getch() does nothing or returns ERR.
+
+ nodelay() controls whether wgetch() is a non-blocking call. If
+ the option is enabled, and no input is ready, wgetch() will
+ return ERR. If disabled, wgetch() will hang until input is
+ ready.
+
+ nl() enables the translation of a carriage return into a newline
+ on input. nonl() disables this. Initially, the translation does
+ occur.
+
+ raw() and noraw() toggle raw mode. Raw mode is similar to cbreak
+ mode, in that characters typed are immediately passed through to
+ the user program. The difference is that in raw mode, the INTR,
+ QUIT, SUSP, and STOP characters are passed through without being
+ interpreted, and without generating a signal.
+
+ In PDCurses, the meta() function sets raw mode on or off.
+
+ timeout() and wtimeout() set blocking or non-blocking reads for
+ the specified window. The delay is measured in milliseconds. If
+ it's negative, a blocking read is used; if zero, then non-
+ blocking reads are done -- if no input is waiting, ERR is
+ returned immediately. If the delay is positive, the read blocks
+ for the delay period; if the period expires, ERR is returned.
+
+ intrflush(), notimeout(), noqiflush(), qiflush() and typeahead()
+ do nothing in PDCurses, but are included for compatibility with
+ other curses implementations.
+
+ crmode() and nocrmode() are archaic equivalents to cbreak() and
+ nocbreak(), respectively.
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ cbreak Y Y Y
+ nocbreak Y Y Y
+ echo Y Y Y
+ noecho Y Y Y
+ halfdelay Y - Y
+ intrflush Y - Y
+ keypad Y - Y
+ meta Y - Y
+ nl Y Y Y
+ nonl Y Y Y
+ nodelay Y - Y
+ notimeout Y - Y
+ raw Y Y Y
+ noraw Y Y Y
+ noqiflush Y - Y
+ qiflush Y - Y
+ timeout Y - Y
+ wtimeout Y - Y
+ typeahead Y - Y
+ crmode -
+ nocrmode -
+
+**man-end****************************************************************/
+
+int cbreak(void)
+{
+ PDC_LOG(("cbreak() - called\n"));
+
+ SP->cbreak = TRUE;
+
+ return OK;
+}
+
+int nocbreak(void)
+{
+ PDC_LOG(("nocbreak() - called\n"));
+
+ SP->cbreak = FALSE;
+ SP->delaytenths = 0;
+
+ return OK;
+}
+
+int echo(void)
+{
+ PDC_LOG(("echo() - called\n"));
+
+ SP->echo = TRUE;
+
+ return OK;
+}
+
+int noecho(void)
+{
+ PDC_LOG(("noecho() - called\n"));
+
+ SP->echo = FALSE;
+
+ return OK;
+}
+
+int halfdelay(int tenths)
+{
+ PDC_LOG(("halfdelay() - called\n"));
+
+ if (tenths < 1 || tenths > 255)
+ return ERR;
+
+ SP->delaytenths = tenths;
+
+ return OK;
+}
+
+int intrflush(WINDOW *win, bool bf)
+{
+ PDC_LOG(("intrflush() - called\n"));
+
+ return OK;
+}
+
+int keypad(WINDOW *win, bool bf)
+{
+ PDC_LOG(("keypad() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ win->_use_keypad = bf;
+
+ return OK;
+}
+
+int meta(WINDOW *win, bool bf)
+{
+ PDC_LOG(("meta() - called\n"));
+
+ SP->raw_inp = bf;
+
+ return OK;
+}
+
+int nl(void)
+{
+ PDC_LOG(("nl() - called\n"));
+
+ SP->autocr = TRUE;
+
+ return OK;
+}
+
+int nonl(void)
+{
+ PDC_LOG(("nonl() - called\n"));
+
+ SP->autocr = FALSE;
+
+ return OK;
+}
+
+int nodelay(WINDOW *win, bool flag)
+{
+ PDC_LOG(("nodelay() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ win->_nodelay = flag;
+
+ return OK;
+}
+
+int notimeout(WINDOW *win, bool flag)
+{
+ PDC_LOG(("notimeout() - called\n"));
+
+ return OK;
+}
+
+int raw(void)
+{
+ PDC_LOG(("raw() - called\n"));
+
+ PDC_set_keyboard_binary(TRUE);
+ SP->raw_inp = TRUE;
+
+ return OK;
+}
+
+int noraw(void)
+{
+ PDC_LOG(("noraw() - called\n"));
+
+ PDC_set_keyboard_binary(FALSE);
+ SP->raw_inp = FALSE;
+
+ return OK;
+}
+
+void noqiflush(void)
+{
+ PDC_LOG(("noqiflush() - called\n"));
+}
+
+void qiflush(void)
+{
+ PDC_LOG(("qiflush() - called\n"));
+}
+
+int typeahead(int fildes)
+{
+ PDC_LOG(("typeahead() - called\n"));
+
+ return OK;
+}
+
+void wtimeout(WINDOW *win, int delay)
+{
+ PDC_LOG(("wtimeout() - called\n"));
+
+ if (!win)
+ return;
+
+ if (delay < 0)
+ {
+ /* This causes a blocking read on the window, so turn on delay
+ mode */
+
+ win->_nodelay = FALSE;
+ win->_delayms = 0;
+ }
+ else if (!delay)
+ {
+ /* This causes a non-blocking read on the window, so turn off
+ delay mode */
+
+ win->_nodelay = TRUE;
+ win->_delayms = 0;
+ }
+ else
+ {
+ /* This causes the read on the window to delay for the number of
+ milliseconds. Also forces the window into non-blocking read
+ mode */
+
+ /*win->_nodelay = TRUE;*/
+ win->_delayms = delay;
+ }
+}
+
+void timeout(int delay)
+{
+ PDC_LOG(("timeout() - called\n"));
+
+ wtimeout(stdscr, delay);
+}
+
+int crmode(void)
+{
+ PDC_LOG(("crmode() - called\n"));
+
+ return cbreak();
+}
+
+int nocrmode(void)
+{
+ PDC_LOG(("nocrmode() - called\n"));
+
+ return nocbreak();
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/insch.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/insch.c
new file mode 100644
index 0000000000..50527f2f5b
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/insch.c
@@ -0,0 +1,268 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: insch.c,v 1.44 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: insch
+
+ Synopsis:
+ int insch(chtype ch);
+ int winsch(WINDOW *win, chtype ch);
+ int mvinsch(int y, int x, chtype ch);
+ int mvwinsch(WINDOW *win, int y, int x, chtype ch);
+
+ int insrawch(chtype ch);
+ int winsrawch(WINDOW *win, chtype ch);
+ int mvinsrawch(int y, int x, chtype ch);
+ int mvwinsrawch(WINDOW *win, int y, int x, chtype ch);
+
+ int ins_wch(const cchar_t *wch);
+ int wins_wch(WINDOW *win, const cchar_t *wch);
+ int mvins_wch(int y, int x, const cchar_t *wch);
+ int mvwins_wch(WINDOW *win, int y, int x, const cchar_t *wch);
+
+ Description:
+ The insch() functions insert a chtype into the window at the
+ current or specified cursor position. The cursor is NOT
+ advanced. A newline is equivalent to clrtoeol(); tabs are
+ expanded; other control characters are converted as with
+ unctrl().
+
+ The ins_wch() functions are the wide-character
+ equivalents, taking cchar_t pointers rather than chtypes.
+
+ Video attributes can be combined with a character by ORing
+ them into the parameter. Text, including attributes, can be
+ copied from one place to another using inch() and insch().
+
+ insrawch() etc. are PDCurses-specific wrappers for insch() etc.
+ that disable the translation of control characters.
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ insch Y Y Y
+ winsch Y Y Y
+ mvinsch Y Y Y
+ mvwinsch Y Y Y
+ insrawch - - -
+ winsrawch - - -
+ ins_wch Y
+ wins_wch Y
+ mvins_wch Y
+ mvwins_wch Y
+
+**man-end****************************************************************/
+
+#include <string.h>
+
+int winsch(WINDOW *win, chtype ch)
+{
+ int x, y;
+ chtype attr;
+ bool xlat;
+
+ PDC_LOG(("winsch() - called: win=%p ch=%x (text=%c attr=0x%x)\n",
+ win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES));
+
+ if (!win)
+ return ERR;
+
+ x = win->_curx;
+ y = win->_cury;
+
+ if (y > win->_maxy || x > win->_maxx || y < 0 || x < 0)
+ return ERR;
+
+ xlat = !SP->raw_out && !(ch & A_ALTCHARSET);
+ attr = ch & A_ATTRIBUTES;
+ ch &= A_CHARTEXT;
+
+ if (xlat && (ch < ' ' || ch == 0x7f))
+ {
+ int x2;
+
+ switch (ch)
+ {
+ case '\t':
+ for (x2 = ((x / TABSIZE) + 1) * TABSIZE; x < x2; x++)
+ {
+ if (winsch(win, attr | ' ') == ERR)
+ return ERR;
+ }
+ return OK;
+
+ case '\n':
+ wclrtoeol(win);
+ break;
+
+ case 0x7f:
+ if (winsch(win, attr | '?') == ERR)
+ return ERR;
+
+ return winsch(win, attr | '^');
+
+ default:
+ /* handle control chars */
+
+ if (winsch(win, attr | (ch + '@')) == ERR)
+ return ERR;
+
+ return winsch(win, attr | '^');
+ }
+ }
+ else
+ {
+ int maxx;
+ chtype *temp;
+
+ /* If the incoming character doesn't have its own attribute,
+ then use the current attributes for the window. If it has
+ attributes but not a color component, OR the attributes to
+ the current attributes for the window. If it has a color
+ component, use the attributes solely from the incoming
+ character. */
+
+ if (!(attr & A_COLOR))
+ attr |= win->_attrs;
+
+ /* wrs (4/10/93): Apply the same sort of logic for the window
+ background, in that it only takes precedence if other color
+ attributes are not there and that the background character
+ will only print if the printing character is blank. */
+
+ if (!(attr & A_COLOR))
+ attr |= win->_bkgd & A_ATTRIBUTES;
+ else
+ attr |= win->_bkgd & (A_ATTRIBUTES ^ A_COLOR);
+
+ if (ch == ' ')
+ ch = win->_bkgd & A_CHARTEXT;
+
+ /* Add the attribute back into the character. */
+
+ ch |= attr;
+
+ maxx = win->_maxx;
+ temp = &win->_y[y][x];
+
+ memmove(temp + 1, temp, (maxx - x - 1) * sizeof(chtype));
+
+ win->_lastch[y] = maxx - 1;
+
+ if ((win->_firstch[y] == _NO_CHANGE) || (win->_firstch[y] > x))
+ win->_firstch[y] = x;
+
+ *temp = ch;
+ }
+
+ PDC_sync(win);
+
+ return OK;
+}
+
+int insch(chtype ch)
+{
+ PDC_LOG(("insch() - called\n"));
+
+ return winsch(stdscr, ch);
+}
+
+int mvinsch(int y, int x, chtype ch)
+{
+ PDC_LOG(("mvinsch() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return winsch(stdscr, ch);
+}
+
+int mvwinsch(WINDOW *win, int y, int x, chtype ch)
+{
+ PDC_LOG(("mvwinsch() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return winsch(win, ch);
+}
+
+int winsrawch(WINDOW *win, chtype ch)
+{
+ PDC_LOG(("winsrawch() - called: win=%p ch=%x "
+ "(char=%c attr=0x%x)\n", win, ch,
+ ch & A_CHARTEXT, ch & A_ATTRIBUTES));
+
+ if ((ch & A_CHARTEXT) < ' ' || (ch & A_CHARTEXT) == 0x7f)
+ ch |= A_ALTCHARSET;
+
+ return winsch(win, ch);
+}
+
+int insrawch(chtype ch)
+{
+ PDC_LOG(("insrawch() - called\n"));
+
+ return winsrawch(stdscr, ch);
+}
+
+int mvinsrawch(int y, int x, chtype ch)
+{
+ PDC_LOG(("mvinsrawch() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return winsrawch(stdscr, ch);
+}
+
+int mvwinsrawch(WINDOW *win, int y, int x, chtype ch)
+{
+ PDC_LOG(("mvwinsrawch() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return winsrawch(win, ch);
+}
+
+#ifdef PDC_WIDE
+int wins_wch(WINDOW *win, const cchar_t *wch)
+{
+ PDC_LOG(("wins_wch() - called\n"));
+
+ return wch ? winsch(win, *wch) : ERR;
+}
+
+int ins_wch(const cchar_t *wch)
+{
+ PDC_LOG(("ins_wch() - called\n"));
+
+ return wins_wch(stdscr, wch);
+}
+
+int mvins_wch(int y, int x, const cchar_t *wch)
+{
+ PDC_LOG(("mvins_wch() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return wins_wch(stdscr, wch);
+}
+
+int mvwins_wch(WINDOW *win, int y, int x, const cchar_t *wch)
+{
+ PDC_LOG(("mvwins_wch() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return wins_wch(win, wch);
+}
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/insstr.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/insstr.c
new file mode 100644
index 0000000000..38fa38915c
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/insstr.c
@@ -0,0 +1,261 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: insstr.c,v 1.46 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: insstr
+
+ Synopsis:
+ int insstr(const char *str);
+ int insnstr(const char *str, int n);
+ int winsstr(WINDOW *win, const char *str);
+ int winsnstr(WINDOW *win, const char *str, int n);
+ int mvinsstr(int y, int x, const char *str);
+ int mvinsnstr(int y, int x, const char *str, int n);
+ int mvwinsstr(WINDOW *win, int y, int x, const char *str);
+ int mvwinsnstr(WINDOW *win, int y, int x, const char *str, int n);
+
+ int ins_wstr(const wchar_t *wstr);
+ int ins_nwstr(const wchar_t *wstr, int n);
+ int wins_wstr(WINDOW *win, const wchar_t *wstr);
+ int wins_nwstr(WINDOW *win, const wchar_t *wstr, int n);
+ int mvins_wstr(int y, int x, const wchar_t *wstr);
+ int mvins_nwstr(int y, int x, const wchar_t *wstr, int n);
+ int mvwins_wstr(WINDOW *win, int y, int x, const wchar_t *wstr);
+ int mvwins_nwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n);
+
+ Description:
+ The insstr() functions insert a character string into a window
+ at the current cursor position, by repeatedly calling winsch().
+ When PDCurses is built with wide-character support enabled, the
+ narrow-character functions treat the string as a multibyte
+ string in the current locale, and convert it first. All
+ characters to the right of the cursor are moved to the right,
+ with the possibility of the rightmost characters on the line
+ being lost. The cursor position does not change (after moving
+ to y, x, if specified). The routines with n as the last
+ argument insert at most n characters; if n is negative, then the
+ entire string is inserted.
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ insstr Y - 4.0
+ winsstr Y - 4.0
+ mvinsstr Y - 4.0
+ mvwinsstr Y - 4.0
+ insnstr Y - 4.0
+ winsnstr Y - 4.0
+ mvinsnstr Y - 4.0
+ mvwinsnstr Y - 4.0
+ ins_wstr Y
+ wins_wstr Y
+ mvins_wstr Y
+ mvwins_wstr Y
+ ins_nwstr Y
+ wins_nwstr Y
+ mvins_nwstr Y
+ mvwins_nwstr Y
+
+**man-end****************************************************************/
+
+#include <string.h>
+
+int winsnstr(WINDOW *win, const char *str, int n)
+{
+#ifdef PDC_WIDE
+ wchar_t wstr[513], *p;
+ int i;
+#endif
+ int len;
+
+ PDC_LOG(("winsnstr() - called: string=\"%s\" n %d \n", str, n));
+
+ if (!win || !str)
+ return ERR;
+
+ len = strlen(str);
+
+ if (n < 0 || n < len)
+ n = len;
+
+#ifdef PDC_WIDE
+ if (n > 512)
+ n = 512;
+
+ p = wstr;
+ i = 0;
+
+ while (str[i] && i < n)
+ {
+ int retval = PDC_mbtowc(p, str + i, n - i);
+
+ if (retval <= 0)
+ break;
+ p++;
+ i += retval;
+ }
+
+ while (p > wstr)
+ if (winsch(win, *--p) == ERR)
+#else
+ while (n)
+ if (winsch(win, (unsigned char)(str[--n])) == ERR)
+#endif
+ return ERR;
+
+ return OK;
+}
+
+int insstr(const char *str)
+{
+ PDC_LOG(("insstr() - called: string=\"%s\"\n", str));
+
+ return winsnstr(stdscr, str, -1);
+}
+
+int winsstr(WINDOW *win, const char *str)
+{
+ PDC_LOG(("winsstr() - called: string=\"%s\"\n", str));
+
+ return winsnstr(win, str, -1);
+}
+
+int mvinsstr(int y, int x, const char *str)
+{
+ PDC_LOG(("mvinsstr() - called: y %d x %d string=\"%s\"\n", y, x, str));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return winsnstr(stdscr, str, -1);
+}
+
+int mvwinsstr(WINDOW *win, int y, int x, const char *str)
+{
+ PDC_LOG(("mvwinsstr() - called: string=\"%s\"\n", str));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return winsnstr(win, str, -1);
+}
+
+int insnstr(const char *str, int n)
+{
+ PDC_LOG(("insnstr() - called: string=\"%s\" n %d \n", str, n));
+
+ return winsnstr(stdscr, str, n);
+}
+
+int mvinsnstr(int y, int x, const char *str, int n)
+{
+ PDC_LOG(("mvinsnstr() - called: y %d x %d string=\"%s\" n %d \n",
+ y, x, str, n));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return winsnstr(stdscr, str, n);
+}
+
+int mvwinsnstr(WINDOW *win, int y, int x, const char *str, int n)
+{
+ PDC_LOG(("mvwinsnstr() - called: y %d x %d string=\"%s\" n %d \n",
+ y, x, str, n));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return winsnstr(win, str, n);
+}
+
+#ifdef PDC_WIDE
+int wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
+{
+ const wchar_t *p;
+ int len;
+
+ PDC_LOG(("wins_nwstr() - called\n"));
+
+ if (!win || !wstr)
+ return ERR;
+
+ for (len = 0, p = wstr; *p; p++)
+ len++;
+
+ if (n < 0 || n < len)
+ n = len;
+
+ while (n)
+ if (winsch(win, wstr[--n]) == ERR)
+ return ERR;
+
+ return OK;
+}
+
+int ins_wstr(const wchar_t *wstr)
+{
+ PDC_LOG(("ins_wstr() - called\n"));
+
+ return wins_nwstr(stdscr, wstr, -1);
+}
+
+int wins_wstr(WINDOW *win, const wchar_t *wstr)
+{
+ PDC_LOG(("wins_wstr() - called\n"));
+
+ return wins_nwstr(win, wstr, -1);
+}
+
+int mvins_wstr(int y, int x, const wchar_t *wstr)
+{
+ PDC_LOG(("mvins_wstr() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return wins_nwstr(stdscr, wstr, -1);
+}
+
+int mvwins_wstr(WINDOW *win, int y, int x, const wchar_t *wstr)
+{
+ PDC_LOG(("mvwinsstr() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return wins_nwstr(win, wstr, -1);
+}
+
+int ins_nwstr(const wchar_t *wstr, int n)
+{
+ PDC_LOG(("ins_nwstr() - called\n"));
+
+ return wins_nwstr(stdscr, wstr, n);
+}
+
+int mvins_nwstr(int y, int x, const wchar_t *wstr, int n)
+{
+ PDC_LOG(("mvinsnstr() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return wins_nwstr(stdscr, wstr, n);
+}
+
+int mvwins_nwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n)
+{
+ PDC_LOG(("mvwinsnstr() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return wins_nwstr(win, wstr, n);
+}
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/instr.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/instr.c
new file mode 100644
index 0000000000..bbf369cc8d
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/instr.c
@@ -0,0 +1,243 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: instr.c,v 1.44 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: instr
+
+ Synopsis:
+ int instr(char *str);
+ int innstr(char *str, int n);
+ int winstr(WINDOW *win, char *str);
+ int winnstr(WINDOW *win, char *str, int n);
+ int mvinstr(int y, int x, char *str);
+ int mvinnstr(int y, int x, char *str, int n);
+ int mvwinstr(WINDOW *win, int y, int x, char *str);
+ int mvwinnstr(WINDOW *win, int y, int x, char *str, int n);
+
+ int inwstr(wchar_t *wstr);
+ int innwstr(wchar_t *wstr, int n);
+ int winwstr(WINDOW *win, wchar_t *wstr);
+ int winnwstr(WINDOW *win, wchar_t *wstr, int n);
+ int mvinwstr(int y, int x, wchar_t *wstr);
+ int mvinnwstr(int y, int x, wchar_t *wstr, int n);
+ int mvwinwstr(WINDOW *win, int y, int x, wchar_t *wstr);
+ int mvwinnwstr(WINDOW *win, int y, int x, wchar_t *wstr, int n);
+
+ Description:
+ These functions take characters (or wide characters) from the
+ current or specified position in the window, and return them as
+ a string in str (or wstr). Attributes are ignored. The functions
+ with n as the last argument return a string at most n characters
+ long.
+
+ Return Value:
+ Upon successful completion, innstr(), mvinnstr(), mvwinnstr()
+ and winnstr() return the number of characters actually read into
+ the string; instr(), mvinstr(), mvwinstr() and winstr() return
+ OK. Otherwise, all these functions return ERR.
+
+ Portability X/Open BSD SYS V
+ instr Y - 4.0
+ winstr Y - 4.0
+ mvinstr Y - 4.0
+ mvwinstr Y - 4.0
+ innstr Y - 4.0
+ winnstr Y - 4.0
+ mvinnstr Y - 4.0
+ mvwinnstr Y - 4.0
+ inwstr Y
+ winwstr Y
+ mvinwstr Y
+ mvwinwstr Y
+ innwstr Y
+ winnwstr Y
+ mvinnwstr Y
+ mvwinnwstr Y
+
+**man-end****************************************************************/
+
+int winnstr(WINDOW *win, char *str, int n)
+{
+#ifdef PDC_WIDE
+ wchar_t wstr[513];
+
+ if (n < 0 || n > 512)
+ n = 512;
+
+ if (winnwstr(win, wstr, n) == ERR)
+ return ERR;
+
+ return PDC_wcstombs(str, wstr, n);
+#else
+ chtype *src;
+ int i;
+
+ PDC_LOG(("winnstr() - called: n %d \n", n));
+
+ if (!win || !str)
+ return ERR;
+
+ if (n < 0 || (win->_curx + n) > win->_maxx)
+ n = win->_maxx - win->_curx;
+
+ src = win->_y[win->_cury] + win->_curx;
+
+ for (i = 0; i < n; i++)
+ str[i] = src[i] & A_CHARTEXT;
+
+ str[i] = '\0';
+
+ return i;
+#endif
+}
+
+int instr(char *str)
+{
+ PDC_LOG(("instr() - called: string=\"%s\"\n", str));
+
+ return (ERR == winnstr(stdscr, str, stdscr->_maxx)) ? ERR : OK;
+}
+
+int winstr(WINDOW *win, char *str)
+{
+ PDC_LOG(("winstr() - called: \n"));
+
+ return (ERR == winnstr(win, str, win->_maxx)) ? ERR : OK;
+}
+
+int mvinstr(int y, int x, char *str)
+{
+ PDC_LOG(("mvinstr() - called: y %d x %d \n", y, x));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return (ERR == winnstr(stdscr, str, stdscr->_maxx)) ? ERR : OK;
+}
+
+int mvwinstr(WINDOW *win, int y, int x, char *str)
+{
+ PDC_LOG(("mvwinstr() - called: y %d x %d \n", y, x));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return (ERR == winnstr(win, str, win->_maxx)) ? ERR : OK;
+}
+
+int innstr(char *str, int n)
+{
+ PDC_LOG(("innstr() - called: n %d \n", n));
+
+ return winnstr(stdscr, str, n);
+}
+
+int mvinnstr(int y, int x, char *str, int n)
+{
+ PDC_LOG(("mvinnstr() - called: y %d x %d n %d \n", y, x, n));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return winnstr(stdscr, str, n);
+}
+
+int mvwinnstr(WINDOW *win, int y, int x, char *str, int n)
+{
+ PDC_LOG(("mvwinnstr() - called: y %d x %d n %d \n", y, x, n));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return winnstr(win, str, n);
+}
+
+#ifdef PDC_WIDE
+int winnwstr(WINDOW *win, wchar_t *wstr, int n)
+{
+ chtype *src;
+ int i;
+
+ PDC_LOG(("winnstr() - called: n %d \n", n));
+
+ if (!win || !wstr)
+ return ERR;
+
+ if (n < 0 || (win->_curx + n) > win->_maxx)
+ n = win->_maxx - win->_curx;
+
+ src = win->_y[win->_cury] + win->_curx;
+
+ for (i = 0; i < n; i++)
+ wstr[i] = src[i] & A_CHARTEXT;
+
+ wstr[i] = L'\0';
+
+ return i;
+}
+
+int inwstr(wchar_t *wstr)
+{
+ PDC_LOG(("inwstr() - called\n"));
+
+ return (ERR == winnwstr(stdscr, wstr, stdscr->_maxx)) ? ERR : OK;
+}
+
+int winwstr(WINDOW *win, wchar_t *wstr)
+{
+ PDC_LOG(("winwstr() - called\n"));
+
+ return (ERR == winnwstr(win, wstr, win->_maxx)) ? ERR : OK;
+}
+
+int mvinwstr(int y, int x, wchar_t *wstr)
+{
+ PDC_LOG(("mvinwstr() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return (ERR == winnwstr(stdscr, wstr, stdscr->_maxx)) ? ERR : OK;
+}
+
+int mvwinwstr(WINDOW *win, int y, int x, wchar_t *wstr)
+{
+ PDC_LOG(("mvwinstr() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return (ERR == winnwstr(win, wstr, win->_maxx)) ? ERR : OK;
+}
+
+int innwstr(wchar_t *wstr, int n)
+{
+ PDC_LOG(("innwstr() - called\n"));
+
+ return winnwstr(stdscr, wstr, n);
+}
+
+int mvinnwstr(int y, int x, wchar_t *wstr, int n)
+{
+ PDC_LOG(("mvinnstr() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ return winnwstr(stdscr, wstr, n);
+}
+
+int mvwinnwstr(WINDOW *win, int y, int x, wchar_t *wstr, int n)
+{
+ PDC_LOG(("mvwinnwstr() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ return winnwstr(win, wstr, n);
+}
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/kernel.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/kernel.c
new file mode 100644
index 0000000000..7e41ccfdea
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/kernel.c
@@ -0,0 +1,256 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: kernel.c,v 1.78 2008/07/15 17:13:26 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: kernel
+
+ Synopsis:
+ int def_prog_mode(void);
+ int def_shell_mode(void);
+ int reset_prog_mode(void);
+ int reset_shell_mode(void);
+ int resetty(void);
+ int savetty(void);
+ int ripoffline(int line, int (*init)(WINDOW *, int));
+ int curs_set(int visibility);
+ int napms(int ms);
+
+ int draino(int ms);
+ int resetterm(void);
+ int fixterm(void);
+ int saveterm(void);
+
+ Description:
+ def_prog_mode() and def_shell_mode() save the current terminal
+ modes as the "program" (in curses) or "shell" (not in curses)
+ state for use by the reset_prog_mode() and reset_shell_mode()
+ functions. This is done automatically by initscr().
+
+ reset_prog_mode() and reset_shell_mode() restore the terminal to
+ "program" (in curses) or "shell" (not in curses) state. These
+ are done automatically by endwin() and doupdate() after an
+ endwin(), so they would normally not be called before these
+ functions.
+
+ savetty() and resetty() save and restore the state of the
+ terminal modes. savetty() saves the current state in a buffer,
+ and resetty() restores the state to what it was at the last call
+ to savetty().
+
+ curs_set() alters the appearance of the cursor. A visibility of
+ 0 makes it disappear; 1 makes it appear "normal" (usually an
+ underline) and 2 makes it "highly visible" (usually a block).
+
+ ripoffline() reduces the size of stdscr by one line. If the
+ "line" parameter is positive, the line is removed from the top
+ of the screen; if negative, from the bottom. Up to 5 lines can
+ be ripped off stdscr by calling ripoffline() repeatedly. The
+ function argument, init, is called from within initscr() or
+ newterm(), so ripoffline() must be called before either of these
+ functions. The init function receives a pointer to a one-line
+ WINDOW, and the width of the window. Calling ripoffline() with a
+ NULL init function pointer is an error.
+
+ napms() suspends the program for the specified number of
+ milliseconds. draino() is an archaic equivalent.
+
+ resetterm(), fixterm() and saveterm() are archaic equivalents
+ for reset_shell_mode(), reset_prog_mode() and def_prog_mode(),
+ respectively.
+
+ Return Value:
+ All functions return OK on success and ERR on error, except
+ curs_set(), which returns the previous visibility.
+
+ Portability X/Open BSD SYS V
+ def_prog_mode Y Y Y
+ def_shell_mode Y Y Y
+ reset_prog_mode Y Y Y
+ reset_shell_mode Y Y Y
+ resetty Y Y Y
+ savetty Y Y Y
+ ripoffline Y - 3.0
+ curs_set Y - 3.0
+ napms Y Y Y
+ draino -
+ resetterm -
+ fixterm -
+ saveterm -
+
+**man-end****************************************************************/
+
+#include <string.h>
+
+RIPPEDOFFLINE linesripped[5];
+char linesrippedoff = 0;
+
+static struct cttyset
+{
+ bool been_set;
+ SCREEN saved;
+} ctty[3];
+
+enum { PDC_SH_TTY, PDC_PR_TTY, PDC_SAVE_TTY };
+
+static void _save_mode(int i)
+{
+ ctty[i].been_set = TRUE;
+
+ memcpy(&(ctty[i].saved), SP, sizeof(SCREEN));
+
+ PDC_save_screen_mode(i);
+}
+
+static int _restore_mode(int i)
+{
+ if (ctty[i].been_set == TRUE)
+ {
+ memcpy(SP, &(ctty[i].saved), sizeof(SCREEN));
+
+ if (ctty[i].saved.raw_out)
+ raw();
+
+ PDC_restore_screen_mode(i);
+
+ if ((LINES != ctty[i].saved.lines) ||
+ (COLS != ctty[i].saved.cols))
+ resize_term(ctty[i].saved.lines, ctty[i].saved.cols);
+
+ PDC_curs_set(ctty[i].saved.visibility);
+
+ PDC_gotoyx(ctty[i].saved.cursrow, ctty[i].saved.curscol);
+ }
+
+ return ctty[i].been_set ? OK : ERR;
+}
+
+int def_prog_mode(void)
+{
+ PDC_LOG(("def_prog_mode() - called\n"));
+
+ _save_mode(PDC_PR_TTY);
+
+ return OK;
+}
+
+int def_shell_mode(void)
+{
+ PDC_LOG(("def_shell_mode() - called\n"));
+
+ _save_mode(PDC_SH_TTY);
+
+ return OK;
+}
+
+int reset_prog_mode(void)
+{
+ PDC_LOG(("reset_prog_mode() - called\n"));
+
+ _restore_mode(PDC_PR_TTY);
+ PDC_reset_prog_mode();
+
+ return OK;
+}
+
+int reset_shell_mode(void)
+{
+ PDC_LOG(("reset_shell_mode() - called\n"));
+
+ _restore_mode(PDC_SH_TTY);
+ PDC_reset_shell_mode();
+
+ return OK;
+}
+
+int resetty(void)
+{
+ PDC_LOG(("resetty() - called\n"));
+
+ return _restore_mode(PDC_SAVE_TTY);
+}
+
+int savetty(void)
+{
+ PDC_LOG(("savetty() - called\n"));
+
+ _save_mode(PDC_SAVE_TTY);
+
+ return OK;
+}
+
+int curs_set(int visibility)
+{
+ int ret_vis;
+
+ PDC_LOG(("curs_set() - called: visibility=%d\n", visibility));
+
+ if ((visibility < 0) || (visibility > 2))
+ return ERR;
+
+ ret_vis = PDC_curs_set(visibility);
+
+ /* If the cursor is changing from invisible to visible, update
+ its position */
+
+ if (visibility && !ret_vis)
+ PDC_gotoyx(SP->cursrow, SP->curscol);
+
+ return ret_vis;
+}
+
+int napms(int ms)
+{
+ PDC_LOG(("napms() - called: ms=%d\n", ms));
+
+ if (ms)
+ PDC_napms(ms);
+
+ return OK;
+}
+
+int ripoffline(int line, int (*init)(WINDOW *, int))
+{
+ PDC_LOG(("ripoffline() - called: line=%d\n", line));
+
+ if (linesrippedoff < 5 && line && init)
+ {
+ linesripped[(int)linesrippedoff].line = line;
+ linesripped[(int)linesrippedoff++].init = init;
+
+ return OK;
+ }
+
+ return ERR;
+}
+
+int draino(int ms)
+{
+ PDC_LOG(("draino() - called\n"));
+
+ return napms(ms);
+}
+
+int resetterm(void)
+{
+ PDC_LOG(("resetterm() - called\n"));
+
+ return reset_shell_mode();
+}
+
+int fixterm(void)
+{
+ PDC_LOG(("fixterm() - called\n"));
+
+ return reset_prog_mode();
+}
+
+int saveterm(void)
+{
+ PDC_LOG(("saveterm() - called\n"));
+
+ return def_prog_mode();
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/keyname.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/keyname.c
new file mode 100644
index 0000000000..6d02cef81c
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/keyname.c
@@ -0,0 +1,125 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: keyname.c,v 1.8 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: keyname
+
+ Synopsis:
+ char *keyname(int key);
+
+ char *key_name(wchar_t c);
+
+ bool has_key(int key);
+
+ Description:
+ keyname() returns a string corresponding to the argument key.
+ key may be any key returned by wgetch().
+
+ key_name() is the wide-character version. It takes a wchar_t
+ parameter, but still returns a char *.
+
+ has_key() returns TRUE for recognized keys, FALSE otherwise.
+ This function is an ncurses extension.
+
+ Portability X/Open BSD SYS V
+ keyname Y - 3.0
+ key_name Y
+ has_key - - -
+
+**man-end****************************************************************/
+
+char *keyname(int key)
+{
+ /* Key names must be in exactly the same order as in curses.h */
+
+ static char *key_name[] =
+ {
+ "KEY_BREAK", "KEY_DOWN", "KEY_UP", "KEY_LEFT", "KEY_RIGHT",
+ "KEY_HOME", "KEY_BACKSPACE", "KEY_F0", "KEY_F(1)", "KEY_F(2)",
+ "KEY_F(3)", "KEY_F(4)", "KEY_F(5)", "KEY_F(6)", "KEY_F(7)",
+ "KEY_F(8)", "KEY_F(9)", "KEY_F(10)", "KEY_F(11)", "KEY_F(12)",
+ "KEY_F(13)", "KEY_F(14)", "KEY_F(15)", "KEY_F(16)", "KEY_F(17)",
+ "KEY_F(18)", "KEY_F(19)", "KEY_F(20)", "KEY_F(21)", "KEY_F(22)",
+ "KEY_F(23)", "KEY_F(24)", "KEY_F(25)", "KEY_F(26)", "KEY_F(27)",
+ "KEY_F(28)", "KEY_F(29)", "KEY_F(30)", "KEY_F(31)", "KEY_F(32)",
+ "KEY_F(33)", "KEY_F(34)", "KEY_F(35)", "KEY_F(36)", "KEY_F(37)",
+ "KEY_F(38)", "KEY_F(39)", "KEY_F(40)", "KEY_F(41)", "KEY_F(42)",
+ "KEY_F(43)", "KEY_F(44)", "KEY_F(45)", "KEY_F(46)", "KEY_F(47)",
+ "KEY_F(48)", "KEY_F(49)", "KEY_F(50)", "KEY_F(51)", "KEY_F(52)",
+ "KEY_F(53)", "KEY_F(54)", "KEY_F(55)", "KEY_F(56)", "KEY_F(57)",
+ "KEY_F(58)", "KEY_F(59)", "KEY_F(60)", "KEY_F(61)", "KEY_F(62)",
+ "KEY_F(63)", "KEY_DL", "KEY_IL", "KEY_DC", "KEY_IC", "KEY_EIC",
+ "KEY_CLEAR", "KEY_EOS", "KEY_EOL", "KEY_SF", "KEY_SR",
+ "KEY_NPAGE", "KEY_PPAGE", "KEY_STAB", "KEY_CTAB", "KEY_CATAB",
+ "KEY_ENTER", "KEY_SRESET", "KEY_RESET", "KEY_PRINT", "KEY_LL",
+ "KEY_ABORT", "KEY_SHELP", "KEY_LHELP", "KEY_BTAB", "KEY_BEG",
+ "KEY_CANCEL", "KEY_CLOSE", "KEY_COMMAND", "KEY_COPY",
+ "KEY_CREATE", "KEY_END", "KEY_EXIT", "KEY_FIND", "KEY_HELP",
+ "KEY_MARK", "KEY_MESSAGE", "KEY_MOVE", "KEY_NEXT", "KEY_OPEN",
+ "KEY_OPTIONS", "KEY_PREVIOUS", "KEY_REDO", "KEY_REFERENCE",
+ "KEY_REFRESH", "KEY_REPLACE", "KEY_RESTART", "KEY_RESUME",
+ "KEY_SAVE", "KEY_SBEG", "KEY_SCANCEL", "KEY_SCOMMAND",
+ "KEY_SCOPY", "KEY_SCREATE", "KEY_SDC", "KEY_SDL", "KEY_SELECT",
+ "KEY_SEND", "KEY_SEOL", "KEY_SEXIT", "KEY_SFIND", "KEY_SHOME",
+ "KEY_SIC", "UNKNOWN KEY", "KEY_SLEFT", "KEY_SMESSAGE",
+ "KEY_SMOVE", "KEY_SNEXT", "KEY_SOPTIONS", "KEY_SPREVIOUS",
+ "KEY_SPRINT", "KEY_SREDO", "KEY_SREPLACE", "KEY_SRIGHT",
+ "KEY_SRSUME", "KEY_SSAVE", "KEY_SSUSPEND", "KEY_SUNDO",
+ "KEY_SUSPEND", "KEY_UNDO", "ALT_0", "ALT_1", "ALT_2", "ALT_3",
+ "ALT_4", "ALT_5", "ALT_6", "ALT_7", "ALT_8", "ALT_9", "ALT_A",
+ "ALT_B", "ALT_C", "ALT_D", "ALT_E", "ALT_F", "ALT_G", "ALT_H",
+ "ALT_I", "ALT_J", "ALT_K", "ALT_L", "ALT_M", "ALT_N", "ALT_O",
+ "ALT_P", "ALT_Q", "ALT_R", "ALT_S", "ALT_T", "ALT_U", "ALT_V",
+ "ALT_W", "ALT_X", "ALT_Y", "ALT_Z", "CTL_LEFT", "CTL_RIGHT",
+ "CTL_PGUP", "CTL_PGDN", "CTL_HOME", "CTL_END", "KEY_A1",
+ "KEY_A2", "KEY_A3", "KEY_B1", "KEY_B2", "KEY_B3", "KEY_C1",
+ "KEY_C2", "KEY_C3", "PADSLASH", "PADENTER", "CTL_PADENTER",
+ "ALT_PADENTER", "PADSTOP", "PADSTAR", "PADMINUS", "PADPLUS",
+ "CTL_PADSTOP", "CTL_PADCENTER", "CTL_PADPLUS", "CTL_PADMINUS",
+ "CTL_PADSLASH", "CTL_PADSTAR", "ALT_PADPLUS", "ALT_PADMINUS",
+ "ALT_PADSLASH", "ALT_PADSTAR", "ALT_PADSTOP", "CTL_INS",
+ "ALT_DEL", "ALT_INS", "CTL_UP", "CTL_DOWN", "CTL_TAB",
+ "ALT_TAB", "ALT_MINUS", "ALT_EQUAL", "ALT_HOME", "ALT_PGUP",
+ "ALT_PGDN", "ALT_END", "ALT_UP", "ALT_DOWN", "ALT_RIGHT",
+ "ALT_LEFT", "ALT_ENTER", "ALT_ESC", "ALT_BQUOTE",
+ "ALT_LBRACKET", "ALT_RBRACKET", "ALT_SEMICOLON", "ALT_FQUOTE",
+ "ALT_COMMA", "ALT_STOP", "ALT_FSLASH", "ALT_BKSP", "CTL_BKSP",
+ "PAD0", "CTL_PAD0", "CTL_PAD1", "CTL_PAD2", "CTL_PAD3",
+ "CTL_PAD4", "CTL_PAD5", "CTL_PAD6", "CTL_PAD7","CTL_PAD8",
+ "CTL_PAD9", "ALT_PAD0", "ALT_PAD1", "ALT_PAD2", "ALT_PAD3",
+ "ALT_PAD4", "ALT_PAD5", "ALT_PAD6", "ALT_PAD7", "ALT_PAD8",
+ "ALT_PAD9", "CTL_DEL", "ALT_BSLASH", "CTL_ENTER",
+ "SHF_PADENTER", "SHF_PADSLASH", "SHF_PADSTAR", "SHF_PADPLUS",
+ "SHF_PADMINUS", "SHF_UP", "SHF_DOWN", "SHF_IC", "SHF_DC",
+ "KEY_MOUSE", "KEY_SHIFT_L", "KEY_SHIFT_R", "KEY_CONTROL_L",
+ "KEY_CONTROL_R", "KEY_ALT_L", "KEY_ALT_R", "KEY_RESIZE",
+ "KEY_SUP", "KEY_SDOWN"
+ };
+
+ PDC_LOG(("keyname() - called: key %d\n", key));
+
+ if ((key >= 0) && (key < 0x80))
+ return unctrl((chtype)key);
+
+ return has_key(key) ? key_name[key - KEY_MIN] : "UNKNOWN KEY";
+}
+
+bool has_key(int key)
+{
+ PDC_LOG(("has_key() - called: key %d\n", key));
+
+ return (key >= KEY_MIN && key <= KEY_MAX);
+}
+
+#ifdef PDC_WIDE
+char *key_name(wchar_t c)
+{
+ PDC_LOG(("key_name() - called\n"));
+
+ return keyname((int)c);
+}
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/mouse.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/mouse.c
new file mode 100644
index 0000000000..1f476dd4b9
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/mouse.c
@@ -0,0 +1,429 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: mouse.c,v 1.45 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: mouse
+
+ Synopsis:
+ int mouse_set(unsigned long mbe);
+ int mouse_on(unsigned long mbe);
+ int mouse_off(unsigned long mbe);
+ int request_mouse_pos(void);
+ int map_button(unsigned long button);
+ void wmouse_position(WINDOW *win, int *y, int *x);
+ unsigned long getmouse(void);
+ unsigned long getbmap(void);
+
+ int mouseinterval(int wait);
+ bool wenclose(const WINDOW *win, int y, int x);
+ bool wmouse_trafo(const WINDOW *win, int *y, int *x, bool to_screen);
+ bool mouse_trafo(int *y, int *x, bool to_screen);
+ mmask_t mousemask(mmask_t mask, mmask_t *oldmask);
+ int nc_getmouse(MEVENT *event);
+ int ungetmouse(MEVENT *event);
+
+ Description:
+ As of PDCurses 3.0, there are two separate mouse interfaces: the
+ classic interface, which is based on the undocumented Sys V
+ mouse functions; and an ncurses-compatible interface. Both are
+ active at all times, and you can mix and match functions from
+ each, though it's not recommended. The ncurses interface is
+ essentially an emulation layer built on top of the classic
+ interface; it's here to allow easier porting of ncurses apps.
+
+ The classic interface: mouse_set(), mouse_on(), mouse_off(),
+ request_mouse_pos(), map_button(), wmouse_position(),
+ getmouse(), and getbmap(). An application using this interface
+ would start by calling mouse_set() or mouse_on() with a non-zero
+ value, often ALL_MOUSE_EVENTS. Then it would check for a
+ KEY_MOUSE return from getch(). If found, it would call
+ request_mouse_pos() to get the current mouse status.
+
+ mouse_set(), mouse_on() and mouse_off() are analagous to
+ attrset(), attron() and attroff(). These functions set the
+ mouse button events to trap. The button masks used in these
+ functions are defined in curses.h and can be or'ed together.
+ They are the group of masks starting with BUTTON1_RELEASED.
+
+ request_mouse_pos() requests curses to fill in the Mouse_status
+ structure with the current state of the mouse.
+
+ map_button() enables the specified mouse action to activate the
+ Soft Label Keys if the action occurs over the area of the screen
+ where the Soft Label Keys are displayed. The mouse actions are
+ defined in curses.h in the group that starts with BUTTON_RELEASED.
+
+ wmouse_position() determines if the current mouse position is
+ within the window passed as an argument. If the mouse is
+ outside the current window, -1 is returned in the y and x
+ arguments; otherwise the y and x coordinates of the mouse
+ (relative to the top left corner of the window) are returned in
+ y and x.
+
+ getmouse() returns the current status of the trapped mouse
+ buttons as set by mouse_set() or mouse_on().
+
+ getbmap() returns the current status of the button action used
+ to map a mouse action to the Soft Label Keys as set by the
+ map_button() function.
+
+ The ncurses interface: mouseinterval(), wenclose(),
+ wmouse_trafo(), mouse_trafo(), mousemask(), nc_getmouse(), and
+ ungetmouse(). A typical application using this interface would
+ start by calling mousemask() with a non-zero value, often
+ ALL_MOUSE_EVENTS. Then it would check for a KEY_MOUSE return
+ from getch(). If found, it would call nc_getmouse() to get the
+ current mouse status.
+
+ mouseinterval() sets the timeout for a mouse click. On all
+ current platforms, PDCurses receives mouse button press and
+ release events, but must synthesize click events. It does this
+ by checking whether a release event is queued up after a press
+ event. If it gets a press event, and there are no more events
+ waiting, it will wait for the timeout interval, then check again
+ for a release. A press followed by a release is reported as
+ BUTTON_CLICKED; otherwise it's passed through as BUTTON_PRESSED.
+ The default timeout is 150ms; valid values are 0 (no clicks
+ reported) through 1000ms. In x11, the timeout can also be set
+ via the clickPeriod resource. The return value from
+ mouseinterval() is the old timeout. To check the old value
+ without setting a new one, call it with a parameter of -1. Note
+ that although there's no classic equivalent for this function
+ (apart from the clickPeriod resource), the value set applies in
+ both interfaces.
+
+ wenclose() reports whether the given screen-relative y, x
+ coordinates fall within the given window.
+
+ wmouse_trafo() converts between screen-relative and window-
+ relative coordinates. A to_screen parameter of TRUE means to
+ convert from window to screen; otherwise the reverse. The
+ function returns FALSE if the coordinates aren't within the
+ window, or if any of the parameters are NULL. The coordinates
+ have been converted when the function returns TRUE.
+
+ mouse_trafo() is the stdscr version of wmouse_trafo().
+
+ mousemask() is nearly equivalent to mouse_set(), but instead of
+ OK/ERR, it returns the value of the mask after setting it. (This
+ isn't necessarily the same value passed in, since the mask could
+ be altered on some platforms.) And if the second parameter is a
+ non-null pointer, mousemask() stores the previous mask value
+ there. Also, since the ncurses interface doesn't work with
+ PDCurses' BUTTON_MOVED events, mousemask() filters them out.
+
+ nc_getmouse() returns the current mouse status in an MEVENT
+ struct. This is equivalent to ncurses' getmouse(), renamed to
+ avoid conflict with PDCurses' getmouse(). But if you define
+ NCURSES_MOUSE_VERSION (preferably as 2) before including
+ curses.h, it defines getmouse() to nc_getmouse(), along with a
+ few other redefintions needed for compatibility with ncurses
+ code. nc_getmouse() calls request_mouse_pos(), which (not
+ getmouse()) is the classic equivalent.
+
+ ungetmouse() is the mouse equivalent of ungetch(). However,
+ PDCurses doesn't maintain a queue of mouse events; only one can
+ be pushed back, and it can overwrite or be overwritten by real
+ mouse events.
+
+ Portability X/Open BSD SYS V
+ mouse_set - - 4.0
+ mouse_on - - 4.0
+ mouse_off - - 4.0
+ request_mouse_pos - - 4.0
+ map_button - - 4.0
+ wmouse_position - - 4.0
+ getmouse - - 4.0
+ getbmap - - 4.0
+ mouseinterval - - -
+ wenclose - - -
+ wmouse_trafo - - -
+ mouse_trafo - - -
+ mousemask - - -
+ nc_getmouse - - -
+ ungetmouse - - -
+
+**man-end****************************************************************/
+
+#include <string.h>
+
+static bool ungot = FALSE;
+
+int mouse_set(unsigned long mbe)
+{
+ PDC_LOG(("mouse_set() - called: event %x\n", mbe));
+
+ SP->_trap_mbe = mbe;
+ return PDC_mouse_set();
+}
+
+int mouse_on(unsigned long mbe)
+{
+ PDC_LOG(("mouse_on() - called: event %x\n", mbe));
+
+ SP->_trap_mbe |= mbe;
+ return PDC_mouse_set();
+}
+
+int mouse_off(unsigned long mbe)
+{
+ PDC_LOG(("mouse_off() - called: event %x\n", mbe));
+
+ SP->_trap_mbe &= ~mbe;
+ return PDC_mouse_set();
+}
+
+int map_button(unsigned long button)
+{
+ PDC_LOG(("map_button() - called: button %x\n", button));
+
+/****************** this does nothing at the moment ***************/
+ SP->_map_mbe_to_key = button;
+
+ return OK;
+}
+
+int request_mouse_pos(void)
+{
+ PDC_LOG(("request_mouse_pos() - called\n"));
+
+ Mouse_status = pdc_mouse_status;
+
+ return OK;
+}
+
+void wmouse_position(WINDOW *win, int *y, int *x)
+{
+ PDC_LOG(("wmouse_position() - called\n"));
+
+ if (win && wenclose(win, MOUSE_Y_POS, MOUSE_X_POS))
+ {
+ if (y)
+ *y = MOUSE_Y_POS - win->_begy;
+ if (x)
+ *x = MOUSE_X_POS - win->_begx;
+ }
+ else
+ {
+ if (y)
+ *y = -1;
+ if (x)
+ *x = -1;
+ }
+}
+
+unsigned long getmouse(void)
+{
+ PDC_LOG(("getmouse() - called\n"));
+
+ return SP->_trap_mbe;
+}
+
+unsigned long getbmap(void)
+{
+ PDC_LOG(("getbmap() - called\n"));
+
+ return SP->_map_mbe_to_key;
+}
+
+/* ncurses mouse interface */
+
+int mouseinterval(int wait)
+{
+ int old_wait;
+
+ PDC_LOG(("mouseinterval() - called: %d\n", wait));
+
+ old_wait = SP->mouse_wait;
+
+ if (wait >= 0 && wait <= 1000)
+ SP->mouse_wait = wait;
+
+ return old_wait;
+}
+
+bool wenclose(const WINDOW *win, int y, int x)
+{
+ PDC_LOG(("wenclose() - called: %p %d %d\n", win, y, x));
+
+ return (win && y >= win->_begy && y < win->_begy + win->_maxy
+ && x >= win->_begx && x < win->_begx + win->_maxx);
+}
+
+bool wmouse_trafo(const WINDOW *win, int *y, int *x, bool to_screen)
+{
+ int newy, newx;
+
+ PDC_LOG(("wmouse_trafo() - called\n"));
+
+ if (!win || !y || !x)
+ return FALSE;
+
+ newy = *y;
+ newx = *x;
+
+ if (to_screen)
+ {
+ newy += win->_begy;
+ newx += win->_begx;
+
+ if (!wenclose(win, newy, newx))
+ return FALSE;
+ }
+ else
+ {
+ if (wenclose(win, newy, newx))
+ {
+ newy -= win->_begy;
+ newx -= win->_begx;
+ }
+ else
+ return FALSE;
+ }
+
+ *y = newy;
+ *x = newx;
+
+ return TRUE;
+}
+
+bool mouse_trafo(int *y, int *x, bool to_screen)
+{
+ PDC_LOG(("mouse_trafo() - called\n"));
+
+ return wmouse_trafo(stdscr, y, x, to_screen);
+}
+
+mmask_t mousemask(mmask_t mask, mmask_t *oldmask)
+{
+ PDC_LOG(("mousemask() - called\n"));
+
+ if (oldmask)
+ *oldmask = SP->_trap_mbe;
+
+ /* The ncurses interface doesn't work with our move events, so
+ filter them here */
+
+ mask &= ~(BUTTON1_MOVED | BUTTON2_MOVED | BUTTON3_MOVED);
+
+ mouse_set(mask);
+
+ return SP->_trap_mbe;
+}
+
+int nc_getmouse(MEVENT *event)
+{
+ int i;
+ mmask_t bstate = 0;
+
+ PDC_LOG(("nc_getmouse() - called\n"));
+
+ if (!event)
+ return ERR;
+
+ ungot = FALSE;
+
+ request_mouse_pos();
+
+ event->id = 0;
+
+ event->x = Mouse_status.x;
+ event->y = Mouse_status.y;
+ event->z = 0;
+
+ for (i = 0; i < 3; i++)
+ {
+ if (Mouse_status.changes & (1 << i))
+ {
+ int shf = i * 5;
+ short button = Mouse_status.button[i] & BUTTON_ACTION_MASK;
+
+ if (button == BUTTON_RELEASED)
+ bstate |= (BUTTON1_RELEASED << shf);
+ else if (button == BUTTON_PRESSED)
+ bstate |= (BUTTON1_PRESSED << shf);
+ else if (button == BUTTON_CLICKED)
+ bstate |= (BUTTON1_CLICKED << shf);
+ else if (button == BUTTON_DOUBLE_CLICKED)
+ bstate |= (BUTTON1_DOUBLE_CLICKED << shf);
+
+ button = Mouse_status.button[i] & BUTTON_MODIFIER_MASK;
+
+ if (button & PDC_BUTTON_SHIFT)
+ bstate |= BUTTON_MODIFIER_SHIFT;
+ if (button & PDC_BUTTON_CONTROL)
+ bstate |= BUTTON_MODIFIER_CONTROL;
+ if (button & PDC_BUTTON_ALT)
+ bstate |= BUTTON_MODIFIER_ALT;
+ }
+ }
+
+ if (MOUSE_WHEEL_UP)
+ bstate |= BUTTON4_PRESSED;
+ else if (MOUSE_WHEEL_DOWN)
+ bstate |= BUTTON5_PRESSED;
+
+ /* extra filter pass -- mainly for button modifiers */
+
+ event->bstate = bstate & SP->_trap_mbe;
+
+ return OK;
+}
+
+int ungetmouse(MEVENT *event)
+{
+ int i;
+ unsigned long bstate;
+
+ PDC_LOG(("ungetmouse() - called\n"));
+
+ if (!event || ungot)
+ return ERR;
+
+ ungot = TRUE;
+
+ pdc_mouse_status.x = event->x;
+ pdc_mouse_status.y = event->y;
+
+ pdc_mouse_status.changes = 0;
+ bstate = event->bstate;
+
+ for (i = 0; i < 3; i++)
+ {
+ int shf = i * 5;
+ short button = 0;
+
+ if (bstate & ((BUTTON1_RELEASED | BUTTON1_PRESSED |
+ BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED) << shf))
+ {
+ pdc_mouse_status.changes |= 1 << i;
+
+ if (bstate & (BUTTON1_PRESSED << shf))
+ button = BUTTON_PRESSED;
+ if (bstate & (BUTTON1_CLICKED << shf))
+ button = BUTTON_CLICKED;
+ if (bstate & (BUTTON1_DOUBLE_CLICKED << shf))
+ button = BUTTON_DOUBLE_CLICKED;
+
+ if (bstate & BUTTON_MODIFIER_SHIFT)
+ button |= PDC_BUTTON_SHIFT;
+ if (bstate & BUTTON_MODIFIER_CONTROL)
+ button |= PDC_BUTTON_CONTROL;
+ if (bstate & BUTTON_MODIFIER_ALT)
+ button |= PDC_BUTTON_ALT;
+ }
+
+ pdc_mouse_status.button[i] = button;
+ }
+
+ if (bstate & BUTTON4_PRESSED)
+ pdc_mouse_status.changes |= PDC_MOUSE_WHEEL_UP;
+ else if (bstate & BUTTON5_PRESSED)
+ pdc_mouse_status.changes |= PDC_MOUSE_WHEEL_DOWN;
+
+ return ungetch(KEY_MOUSE);
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/move.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/move.c
new file mode 100644
index 0000000000..30e59084e2
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/move.c
@@ -0,0 +1,54 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: move.c,v 1.28 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: move
+
+ Synopsis:
+ int move(int y, int x);
+ int wmove(WINDOW *win, int y, int x);
+
+ Description:
+ The cursor associated with the window is moved to the given
+ location. This does not move the physical cursor of the
+ terminal until refresh() is called. The position specified is
+ relative to the upper left corner of the window, which is (0,0).
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ move Y Y Y
+ wmove Y Y Y
+
+**man-end****************************************************************/
+
+int move(int y, int x)
+{
+ PDC_LOG(("move() - called: y=%d x=%d\n", y, x));
+
+ if (!stdscr || x < 0 || y < 0 || x >= stdscr->_maxx || y >= stdscr->_maxy)
+ return ERR;
+
+ stdscr->_curx = x;
+ stdscr->_cury = y;
+
+ return OK;
+}
+
+int wmove(WINDOW *win, int y, int x)
+{
+ PDC_LOG(("wmove() - called: y=%d x=%d\n", y, x));
+
+ if (!win || x < 0 || y < 0 || x >= win->_maxx || y >= win->_maxy)
+ return ERR;
+
+ win->_curx = x;
+ win->_cury = y;
+
+ return OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/outopts.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/outopts.c
new file mode 100644
index 0000000000..0a8fd2d564
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/outopts.c
@@ -0,0 +1,156 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: outopts.c,v 1.39 2008/07/14 12:22:13 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: outopts
+
+ Synopsis:
+ int clearok(WINDOW *win, bool bf);
+ int idlok(WINDOW *win, bool bf);
+ void idcok(WINDOW *win, bool bf);
+ void immedok(WINDOW *win, bool bf);
+ int leaveok(WINDOW *win, bool bf);
+ int setscrreg(int top, int bot);
+ int wsetscrreg(WINDOW *win, int top, int bot);
+ int scrollok(WINDOW *win, bool bf);
+
+ int raw_output(bool bf);
+
+ Description:
+ With clearok(), if bf is TRUE, the next call to wrefresh() with
+ this window will clear the screen completely and redraw the
+ entire screen.
+
+ immedok(), called with a second argument of TRUE, causes an
+ automatic wrefresh() every time a change is made to the
+ specified window.
+
+ Normally, the hardware cursor is left at the location of the
+ window being refreshed. leaveok() allows the cursor to be
+ left wherever the update happens to leave it. It's useful
+ for applications where the cursor is not used, since it reduces
+ the need for cursor motions. If possible, the cursor is made
+ invisible when this option is enabled.
+
+ wsetscrreg() sets a scrolling region in a window; "top" and
+ "bot" are the line numbers for the top and bottom margins. If
+ this option and scrollok() are enabled, any attempt to move off
+ the bottom margin will cause all lines in the scrolling region
+ to scroll up one line. setscrreg() is the stdscr version.
+
+ idlok() and idcok() do nothing in PDCurses, but are provided for
+ compatibility with other curses implementations.
+
+ raw_output() enables the output of raw characters using the
+ standard *add* and *ins* curses functions (that is, it disables
+ translation of control characters).
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ clearok Y Y Y
+ idlok Y Y Y
+ idcok Y - 4.0
+ immedok Y - 4.0
+ leaveok Y Y Y
+ setscrreg Y Y Y
+ wsetscrreg Y Y Y
+ scrollok Y Y Y
+ raw_output - - -
+
+**man-end****************************************************************/
+
+int clearok(WINDOW *win, bool bf)
+{
+ PDC_LOG(("clearok() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ win->_clear = bf;
+
+ return OK;
+}
+
+int idlok(WINDOW *win, bool bf)
+{
+ PDC_LOG(("idlok() - called\n"));
+
+ return OK;
+}
+
+void idcok(WINDOW *win, bool bf)
+{
+ PDC_LOG(("idcok() - called\n"));
+}
+
+void immedok(WINDOW *win, bool bf)
+{
+ PDC_LOG(("immedok() - called\n"));
+
+ if (win)
+ win->_immed = bf;
+}
+
+int leaveok(WINDOW *win, bool bf)
+{
+ PDC_LOG(("leaveok() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ win->_leaveit = bf;
+
+ curs_set(!bf);
+
+ return OK;
+}
+
+int setscrreg(int top, int bottom)
+{
+ PDC_LOG(("setscrreg() - called: top %d bottom %d\n", top, bottom));
+
+ return wsetscrreg(stdscr, top, bottom);
+}
+
+int wsetscrreg(WINDOW *win, int top, int bottom)
+{
+ PDC_LOG(("wsetscrreg() - called: top %d bottom %d\n", top, bottom));
+
+ if (win && 0 <= top && top <= win->_cury &&
+ win->_cury <= bottom && bottom < win->_maxy)
+ {
+ win->_tmarg = top;
+ win->_bmarg = bottom;
+
+ return OK;
+ }
+ else
+ return ERR;
+}
+
+int scrollok(WINDOW *win, bool bf)
+{
+ PDC_LOG(("scrollok() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ win->_scroll = bf;
+
+ return OK;
+}
+
+int raw_output(bool bf)
+{
+ PDC_LOG(("raw_output() - called\n"));
+
+ SP->raw_out = bf;
+
+ return OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/overlay.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/overlay.c
new file mode 100644
index 0000000000..f9bba50fb9
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/overlay.c
@@ -0,0 +1,256 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: overlay.c,v 1.36 2008/07/14 12:35:23 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: overlay
+
+ Synopsis:
+ int overlay(const WINDOW *src_w, WINDOW *dst_w)
+ int overwrite(const WINDOW *src_w, WINDOW *dst_w)
+ int copywin(const WINDOW *src_w, WINDOW *dst_w, int src_tr,
+ int src_tc, int dst_tr, int dst_tc, int dst_br,
+ int dst_bc, bool overlay)
+
+ Description:
+ overlay() and overwrite() copy all the text from src_w into
+ dst_w. The windows need not be the same size. Those characters
+ in the source window that intersect with the destination window
+ are copied, so that the characters appear in the same physical
+ position on the screen. The difference between the two functions
+ is that overlay() is non-destructive (blanks are not copied)
+ while overwrite() is destructive (blanks are copied).
+
+ copywin() is similar, but doesn't require that the two windows
+ overlap. The arguments src_tc and src_tr specify the top left
+ corner of the region to be copied. dst_tc, dst_tr, dst_br, and
+ dst_bc specify the region within the destination window to copy
+ to. The argument "overlay", if TRUE, indicates that the copy is
+ done non-destructively (as in overlay()); blanks in the source
+ window are not copied to the destination window. When overlay is
+ FALSE, blanks are copied.
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ overlay Y Y Y
+ overwrite Y Y Y
+ copywin Y - 3.0
+
+**man-end****************************************************************/
+
+/* Thanks to Andreas Otte <venn@@uni-paderborn.de> for the
+ corrected overlay()/overwrite() behavior. */
+
+static int _copy_win(const WINDOW *src_w, WINDOW *dst_w, int src_tr,
+ int src_tc, int src_br, int src_bc, int dst_tr,
+ int dst_tc, bool overlay)
+{
+ int col, line, y1, fc, *minchng, *maxchng;
+ chtype *w1ptr, *w2ptr;
+
+ int lc = 0;
+ int xdiff = src_bc - src_tc;
+ int ydiff = src_br - src_tr;
+
+ if (!src_w || !dst_w)
+ return ERR;
+
+ minchng = dst_w->_firstch;
+ maxchng = dst_w->_lastch;
+
+ for (y1 = 0; y1 < dst_tr; y1++)
+ {
+ minchng++;
+ maxchng++;
+ }
+
+ for (line = 0; line < ydiff; line++)
+ {
+ w1ptr = src_w->_y[line + src_tr] + src_tc;
+ w2ptr = dst_w->_y[line + dst_tr] + dst_tc;
+
+ fc = _NO_CHANGE;
+
+ for (col = 0; col < xdiff; col++)
+ {
+ if ((*w1ptr) != (*w2ptr) &&
+ !((*w1ptr & A_CHARTEXT) == ' ' && overlay))
+ {
+ *w2ptr = *w1ptr;
+
+ if (fc == _NO_CHANGE)
+ fc = col + dst_tc;
+
+ lc = col + dst_tc;
+ }
+
+ w1ptr++;
+ w2ptr++;
+ }
+
+ if (*minchng == _NO_CHANGE)
+ {
+ *minchng = fc;
+ *maxchng = lc;
+ }
+ else if (fc != _NO_CHANGE)
+ {
+ if (fc < *minchng)
+ *minchng = fc;
+ if (lc > *maxchng)
+ *maxchng = lc;
+ }
+
+ minchng++;
+ maxchng++;
+ }
+
+ return OK;
+}
+
+int overlay(const WINDOW *src_w, WINDOW *dst_w)
+{
+ int first_line, first_col, last_line, last_col;
+ int src_start_x, src_start_y, dst_start_x, dst_start_y;
+ int xdiff, ydiff;
+
+ PDC_LOG(("overlay() - called\n"));
+
+ if (!src_w || !dst_w)
+ return ERR;
+
+ first_col = max(dst_w->_begx, src_w->_begx);
+ first_line = max(dst_w->_begy, src_w->_begy);
+
+ last_col = min(src_w->_begx + src_w->_maxx, dst_w->_begx + dst_w->_maxx);
+ last_line = min(src_w->_begy + src_w->_maxy, dst_w->_begy + dst_w->_maxy);
+
+ /* determine the overlapping region of the two windows in real
+ coordinates */
+
+ /* if no overlapping region, do nothing */
+
+ if ((last_col < first_col) || (last_line < first_line))
+ return OK;
+
+ /* size of overlapping region */
+
+ xdiff = last_col - first_col;
+ ydiff = last_line - first_line;
+
+ if (src_w->_begx <= dst_w->_begx)
+ {
+ src_start_x = dst_w->_begx - src_w->_begx;
+ dst_start_x = 0;
+ }
+ else
+ {
+ dst_start_x = src_w->_begx - dst_w->_begx;
+ src_start_x = 0;
+ }
+
+ if (src_w->_begy <= dst_w->_begy)
+ {
+ src_start_y = dst_w->_begy - src_w->_begy;
+ dst_start_y = 0;
+ }
+ else
+ {
+ dst_start_y = src_w->_begy - dst_w->_begy;
+ src_start_y = 0;
+ }
+
+ return _copy_win(src_w, dst_w, src_start_y, src_start_x,
+ src_start_y + ydiff, src_start_x + xdiff,
+ dst_start_y, dst_start_x, TRUE);
+}
+
+int overwrite(const WINDOW *src_w, WINDOW *dst_w)
+{
+ int first_line, first_col, last_line, last_col;
+ int src_start_x, src_start_y, dst_start_x, dst_start_y;
+ int xdiff, ydiff;
+
+ PDC_LOG(("overwrite() - called\n"));
+
+ if (!src_w || !dst_w)
+ return ERR;
+
+ first_col = max(dst_w->_begx, src_w->_begx);
+ first_line = max(dst_w->_begy, src_w->_begy);
+
+ last_col = min(src_w->_begx + src_w->_maxx, dst_w->_begx + dst_w->_maxx);
+ last_line = min(src_w->_begy + src_w->_maxy, dst_w->_begy + dst_w->_maxy);
+
+ /* determine the overlapping region of the two windows in real
+ coordinates */
+
+ /* if no overlapping region, do nothing */
+
+ if ((last_col < first_col) || (last_line < first_line))
+ return OK;
+
+ /* size of overlapping region */
+
+ xdiff = last_col - first_col;
+ ydiff = last_line - first_line;
+
+ if (src_w->_begx <= dst_w->_begx)
+ {
+ src_start_x = dst_w->_begx - src_w->_begx;
+ dst_start_x = 0;
+ }
+ else
+ {
+ dst_start_x = src_w->_begx - dst_w->_begx;
+ src_start_x = 0;
+ }
+
+ if (src_w->_begy <= dst_w->_begy)
+ {
+ src_start_y = dst_w->_begy - src_w->_begy;
+ dst_start_y = 0;
+ }
+ else
+ {
+ dst_start_y = src_w->_begy - dst_w->_begy;
+ src_start_y = 0;
+ }
+
+ return _copy_win(src_w, dst_w, src_start_y, src_start_x,
+ src_start_y + ydiff, src_start_x + xdiff,
+ dst_start_y, dst_start_x, FALSE);
+}
+
+int copywin(const WINDOW *src_w, WINDOW *dst_w, int src_tr, int src_tc,
+ int dst_tr, int dst_tc, int dst_br, int dst_bc, int overlay)
+{
+ int src_end_x, src_end_y;
+ int src_rows, src_cols, dst_rows, dst_cols;
+ int min_rows, min_cols;
+
+ PDC_LOG(("copywin() - called\n"));
+
+ if (!src_w || !dst_w || dst_w == curscr || dst_br > dst_w->_maxy
+ || dst_bc > dst_w->_maxx || dst_tr < 0 || dst_tc < 0)
+ return ERR;
+
+ src_rows = src_w->_maxy - src_tr;
+ src_cols = src_w->_maxx - src_tc;
+ dst_rows = dst_br - dst_tr + 1;
+ dst_cols = dst_bc - dst_tc + 1;
+
+ min_rows = min(src_rows, dst_rows);
+ min_cols = min(src_cols, dst_cols);
+
+ src_end_y = src_tr + min_rows;
+ src_end_x = src_tc + min_cols;
+
+ return _copy_win(src_w, dst_w, src_tr, src_tc, src_end_y, src_end_x,
+ dst_tr, dst_tc, overlay);
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/pad.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/pad.c
new file mode 100644
index 0000000000..ccc5db20d3
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/pad.c
@@ -0,0 +1,259 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: pad.c,v 1.50 2008/07/14 12:22:13 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: pad
+
+ Synopsis:
+ WINDOW *newpad(int nlines, int ncols);
+ WINDOW *subpad(WINDOW *orig, int nlines, int ncols,
+ int begy, int begx);
+ int prefresh(WINDOW *win, int py, int px, int sy1, int sx1,
+ int sy2, int sx2);
+ int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1,
+ int sy2, int sx2);
+ int pechochar(WINDOW *pad, chtype ch);
+ int pecho_wchar(WINDOW *pad, const cchar_t *wch);
+
+ Description:
+ A pad is a special kind of window, which is not restricted by
+ the screen size, and is not necessarily associated with a
+ particular part of the screen. You can use a pad when you need
+ a large window, and only a part of the window will be on the
+ screen at one time. Pads are not refreshed automatically (e.g.,
+ from scrolling or echoing of input). You can't call wrefresh()
+ with a pad as an argument; use prefresh() or pnoutrefresh()
+ instead. Note that these routines require additional parameters
+ to specify the part of the pad to be displayed, and the location
+ to use on the screen.
+
+ newpad() creates a new pad data structure.
+
+ subpad() creates a new sub-pad within a pad, at position (begy,
+ begx), with dimensions of nlines lines and ncols columns. This
+ position is relative to the pad, and not to the screen as with
+ subwin. Changes to either the parent pad or sub-pad will affect
+ both. When using sub-pads, you may need to call touchwin()
+ before calling prefresh().
+
+ pnoutrefresh() copies the specified pad to the virtual screen.
+
+ prefresh() calls pnoutrefresh(), followed by doupdate().
+
+ These routines are analogous to wnoutrefresh() and wrefresh().
+ (py, px) specifies the upper left corner of the part of the pad
+ to be displayed; (sy1, sx1) and (sy2, sx2) describe the screen
+ rectangle that will contain the selected part of the pad.
+
+ pechochar() is functionally equivalent to addch() followed by
+ a call to prefresh(), with the last-used coordinates and
+ dimensions. pecho_wchar() is the wide-character version.
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ newpad Y - Y
+ subpad Y - Y
+ prefresh Y - Y
+ pnoutrefresh Y - Y
+ pechochar Y - 3.0
+ pecho_wchar Y
+
+**man-end****************************************************************/
+
+#include <string.h>
+
+/* save values for pechochar() */
+
+static int save_pminrow, save_pmincol;
+static int save_sminrow, save_smincol, save_smaxrow, save_smaxcol;
+
+WINDOW *newpad(int nlines, int ncols)
+{
+ WINDOW *win;
+
+ PDC_LOG(("newpad() - called: lines=%d cols=%d\n", nlines, ncols));
+
+ if ( !(win = PDC_makenew(nlines, ncols, -1, -1))
+ || !(win = PDC_makelines(win)) )
+ return (WINDOW *)NULL;
+
+ werase(win);
+
+ win->_flags = _PAD;
+
+ /* save default values in case pechochar() is the first call to
+ prefresh(). */
+
+ save_pminrow = 0;
+ save_pmincol = 0;
+ save_sminrow = 0;
+ save_smincol = 0;
+ save_smaxrow = min(LINES, nlines) - 1;
+ save_smaxcol = min(COLS, ncols) - 1;
+
+ return win;
+}
+
+WINDOW *subpad(WINDOW *orig, int nlines, int ncols, int begy, int begx)
+{
+ WINDOW *win;
+ int i;
+ int j = begy;
+ int k = begx;
+
+ PDC_LOG(("subpad() - called: lines=%d cols=%d begy=%d begx=%d\n",
+ nlines, ncols, begy, begx));
+
+ if (!orig || !(orig->_flags & _PAD))
+ return (WINDOW *)NULL;
+
+ /* make sure window fits inside the original one */
+
+ if ((begy < orig->_begy) || (begx < orig->_begx) ||
+ (begy + nlines) > (orig->_begy + orig->_maxy) ||
+ (begx + ncols) > (orig->_begx + orig->_maxx))
+ return (WINDOW *)NULL;
+
+ if (!nlines)
+ nlines = orig->_maxy - 1 - j;
+
+ if (!ncols)
+ ncols = orig->_maxx - 1 - k;
+
+ if ( !(win = PDC_makenew(nlines, ncols, begy, begx)) )
+ return (WINDOW *)NULL;
+
+ /* initialize window variables */
+
+ win->_attrs = orig->_attrs;
+ win->_leaveit = orig->_leaveit;
+ win->_scroll = orig->_scroll;
+ win->_nodelay = orig->_nodelay;
+ win->_use_keypad = orig->_use_keypad;
+ win->_parent = orig;
+
+ for (i = 0; i < nlines; i++)
+ win->_y[i] = (orig->_y[j++]) + k;
+
+ win->_flags = _SUBPAD;
+
+ /* save default values in case pechochar() is the first call
+ to prefresh(). */
+
+ save_pminrow = 0;
+ save_pmincol = 0;
+ save_sminrow = 0;
+ save_smincol = 0;
+ save_smaxrow = min(LINES, nlines) - 1;
+ save_smaxcol = min(COLS, ncols) - 1;
+
+ return win;
+}
+
+int prefresh(WINDOW *win, int py, int px, int sy1, int sx1, int sy2, int sx2)
+{
+ PDC_LOG(("prefresh() - called\n"));
+
+ if (pnoutrefresh(win, py, px, sy1, sx1, sy2, sx2) == ERR)
+ return ERR;
+
+ doupdate();
+ return OK;
+}
+
+int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1, int sy2, int sx2)
+{
+ int num_cols;
+ int sline = sy1;
+ int pline = py;
+
+ PDC_LOG(("pnoutrefresh() - called\n"));
+
+ if (!w || !(w->_flags & (_PAD|_SUBPAD)) || (sy2 >= LINES) || (sy2 >= COLS))
+ return ERR;
+
+ if (py < 0)
+ py = 0;
+ if (px < 0)
+ px = 0;
+ if (sy1 < 0)
+ sy1 = 0;
+ if (sx1 < 0)
+ sx1 = 0;
+
+ if (sy2 < sy1 || sx2 < sx1)
+ return ERR;
+
+ num_cols = min((sx2 - sx1 + 1), (w->_maxx - px));
+
+ while (sline <= sy2)
+ {
+ if (pline < w->_maxy)
+ {
+ memcpy(curscr->_y[sline] + sx1, w->_y[pline] + px,
+ num_cols * sizeof(chtype));
+
+ if ((curscr->_firstch[sline] == _NO_CHANGE)
+ || (curscr->_firstch[sline] > sx1))
+ curscr->_firstch[sline] = sx1;
+
+ if (sx2 > curscr->_lastch[sline])
+ curscr->_lastch[sline] = sx2;
+
+ w->_firstch[pline] = _NO_CHANGE; /* updated now */
+ w->_lastch[pline] = _NO_CHANGE; /* updated now */
+ }
+
+ sline++;
+ pline++;
+ }
+
+ if (w->_clear)
+ {
+ w->_clear = FALSE;
+ curscr->_clear = TRUE;
+ }
+
+ /* position the cursor to the pad's current position if possible --
+ is the pad current position going to end up displayed? if not,
+ then don't move the cursor; if so, move it to the correct place */
+
+ if (!w->_leaveit && w->_cury >= py && w->_curx >= px &&
+ w->_cury <= py + (sy2 - sy1) && w->_curx <= px + (sx2 - sx1))
+ {
+ curscr->_cury = (w->_cury - py) + sy1;
+ curscr->_curx = (w->_curx - px) + sx1;
+ }
+
+ return OK;
+}
+
+int pechochar(WINDOW *pad, chtype ch)
+{
+ PDC_LOG(("pechochar() - called\n"));
+
+ if (waddch(pad, ch) == ERR)
+ return ERR;
+
+ return prefresh(pad, save_pminrow, save_pmincol, save_sminrow,
+ save_smincol, save_smaxrow, save_smaxcol);
+}
+
+#ifdef PDC_WIDE
+int pecho_wchar(WINDOW *pad, const cchar_t *wch)
+{
+ PDC_LOG(("pecho_wchar() - called\n"));
+
+ if (!wch || (waddch(pad, *wch) == ERR))
+ return ERR;
+
+ return prefresh(pad, save_pminrow, save_pmincol, save_sminrow,
+ save_smincol, save_smaxrow, save_smaxcol);
+}
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/panel.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/panel.c
new file mode 100644
index 0000000000..77028c6ffc
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/panel.c
@@ -0,0 +1,630 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: panel.c,v 1.8 2008/07/14 12:35:23 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: panel
+
+ Synopsis:
+ int bottom_panel(PANEL *pan);
+ int del_panel(PANEL *pan);
+ int hide_panel(PANEL *pan);
+ int move_panel(PANEL *pan, int starty, int startx);
+ PANEL *new_panel(WINDOW *win);
+ PANEL *panel_above(const PANEL *pan);
+ PANEL *panel_below(const PANEL *pan);
+ int panel_hidden(const PANEL *pan);
+ const void *panel_userptr(const PANEL *pan);
+ WINDOW *panel_window(const PANEL *pan);
+ int replace_panel(PANEL *pan, WINDOW *win);
+ int set_panel_userptr(PANEL *pan, const void *uptr);
+ int show_panel(PANEL *pan);
+ int top_panel(PANEL *pan);
+ void update_panels(void);
+
+ Description:
+ The panel library is built using the curses library, and any
+ program using panels routines must call one of the curses
+ initialization routines such as initscr(). A program using these
+ routines must be linked with the panels and curses libraries.
+ The header <panel.h> includes the header <curses.h>.
+
+ The panels package gives the applications programmer a way to
+ have depth relationships between curses windows; a curses window
+ is associated with every panel. The panels routines allow curses
+ windows to overlap without making visible the overlapped
+ portions of underlying windows. The initial curses window,
+ stdscr, lies beneath all panels. The set of currently visible
+ panels is the 'deck' of panels.
+
+ The panels package allows the applications programmer to create
+ panels, fetch and set their associated windows, shuffle panels
+ in the deck, and manipulate panels in other ways.
+
+ bottom_panel() places pan at the bottom of the deck. The size,
+ location and contents of the panel are unchanged.
+
+ del_panel() deletes pan, but not its associated winwow.
+
+ hide_panel() removes a panel from the deck and thus hides it
+ from view.
+
+ move_panel() moves the curses window associated with pan, so
+ that its upper lefthand corner is at the supplied coordinates.
+ (Do not use mvwin() on the window.)
+
+ new_panel() creates a new panel associated with win and returns
+ the panel pointer. The new panel is placed at the top of the
+ deck.
+
+ panel_above() returns a pointer to the panel in the deck above
+ pan, or NULL if pan is the top panel. If the value of pan passed
+ is NULL, this function returns a pointer to the bottom panel in
+ the deck.
+
+ panel_below() returns a pointer to the panel in the deck below
+ pan, or NULL if pan is the bottom panel. If the value of pan
+ passed is NULL, this function returns a pointer to the top panel
+ in the deck.
+
+ panel_hidden() returns OK if pan is hidden and ERR if it is not.
+
+ panel_userptr() - Each panel has a user pointer available for
+ maintaining relevant information. This function returns a
+ pointer to that information previously set up by
+ set_panel_userptr().
+
+ panel_window() returns a pointer to the curses window associated
+ with the panel.
+
+ replace_panel() replaces the current window of pan with win.
+
+ set_panel_userptr() - Each panel has a user pointer available
+ for maintaining relevant information. This function sets the
+ value of that information.
+
+ show_panel() makes a previously hidden panel visible and places
+ it back in the deck on top.
+
+ top_panel() places pan on the top of the deck. The size,
+ location and contents of the panel are unchanged.
+
+ update_panels() refreshes the virtual screen to reflect the
+ depth relationships between the panels in the deck. The user
+ must use doupdate() to refresh the physical screen.
+
+ Return Value:
+ Each routine that returns a pointer to an object returns NULL if
+ an error occurs. Each panel routine that returns an integer,
+ returns OK if it executes successfully and ERR if it does not.
+
+ Portability X/Open BSD SYS V
+ bottom_panel - - Y
+ del_panel - - Y
+ hide_panel - - Y
+ move_panel - - Y
+ new_panel - - Y
+ panel_above - - Y
+ panel_below - - Y
+ panel_hidden - - Y
+ panel_userptr - - Y
+ panel_window - - Y
+ replace_panel - - Y
+ set_panel_userptr - - Y
+ show_panel - - Y
+ top_panel - - Y
+ update_panels - - Y
+
+ Credits:
+ Original Author - Warren Tucker <wht@n4hgf.mt-park.ga.us>
+
+**man-end****************************************************************/
+
+#include <panel.h>
+#include <stdlib.h>
+
+PANEL *_bottom_panel = (PANEL *)0;
+PANEL *_top_panel = (PANEL *)0;
+PANEL _stdscr_pseudo_panel = { (WINDOW *)0 };
+
+#ifdef PANEL_DEBUG
+
+static void dPanel(char *text, PANEL *pan)
+{
+ PDC_LOG(("%s id=%s b=%s a=%s y=%d x=%d", text, pan->user,
+ pan->below ? pan->below->user : "--",
+ pan->above ? pan->above->user : "--",
+ pan->wstarty, pan->wstartx));
+}
+
+static void dStack(char *fmt, int num, PANEL *pan)
+{
+ char s80[80];
+
+ sprintf(s80, fmt, num, pan);
+ PDC_LOG(("%s b=%s t=%s", s80, _bottom_panel ? _bottom_panel->user : "--",
+ _top_panel ? _top_panel->user : "--"));
+
+ if (pan)
+ PDC_LOG(("pan id=%s", pan->user));
+
+ pan = _bottom_panel;
+
+ while (pan)
+ {
+ dPanel("stk", pan);
+ pan = pan->above;
+ }
+}
+
+/* debugging hook for wnoutrefresh */
+
+static void Wnoutrefresh(PANEL *pan)
+{
+ dPanel("wnoutrefresh", pan);
+ wnoutrefresh(pan->win);
+}
+
+static void Touchpan(PANEL *pan)
+{
+ dPanel("Touchpan", pan);
+ touchwin(pan->win);
+}
+
+static void Touchline(PANEL *pan, int start, int count)
+{
+ char s80[80];
+
+ sprintf(s80, "Touchline s=%d c=%d", start, count);
+ dPanel(s80, pan);
+ touchline(pan->win, start, count);
+}
+
+#else /* PANEL_DEBUG */
+
+#define dPanel(text, pan)
+#define dStack(fmt, num, pan)
+#define Wnoutrefresh(pan) wnoutrefresh((pan)->win)
+#define Touchpan(pan) touchwin((pan)->win)
+#define Touchline(pan, start, count) touchline((pan)->win, start, count)
+
+#endif /* PANEL_DEBUG */
+
+static bool _panels_overlapped(PANEL *pan1, PANEL *pan2)
+{
+ if (!pan1 || !pan2)
+ return FALSE;
+
+ return ((pan1->wstarty >= pan2->wstarty && pan1->wstarty < pan2->wendy)
+ || (pan2->wstarty >= pan1->wstarty && pan2->wstarty < pan1->wendy))
+ && ((pan1->wstartx >= pan2->wstartx && pan1->wstartx < pan2->wendx)
+ || (pan2->wstartx >= pan1->wstartx && pan2->wstartx < pan1->wendx));
+}
+
+static void _free_obscure(PANEL *pan)
+{
+ PANELOBS *tobs = pan->obscure; /* "this" one */
+ PANELOBS *nobs; /* "next" one */
+
+ while (tobs)
+ {
+ nobs = tobs->above;
+ free((char *)tobs);
+ tobs = nobs;
+ }
+ pan->obscure = (PANELOBS *)0;
+}
+
+static void _override(PANEL *pan, int show)
+{
+ int y;
+ PANEL *pan2;
+ PANELOBS *tobs = pan->obscure; /* "this" one */
+
+ if (show == 1)
+ Touchpan(pan);
+ else if (!show)
+ {
+ Touchpan(pan);
+ Touchpan(&_stdscr_pseudo_panel);
+ }
+ else if (show == -1)
+ while (tobs && (tobs->pan != pan))
+ tobs = tobs->above;
+
+ while (tobs)
+ {
+ if ((pan2 = tobs->pan) != pan)
+ for (y = pan->wstarty; y < pan->wendy; y++)
+ if ((y >= pan2->wstarty) && (y < pan2->wendy) &&
+ ((is_linetouched(pan->win, y - pan->wstarty)) ||
+ (is_linetouched(stdscr, y))))
+ Touchline(pan2, y - pan2->wstarty, 1);
+
+ tobs = tobs->above;
+ }
+}
+
+static void _calculate_obscure(void)
+{
+ PANEL *pan, *pan2;
+ PANELOBS *tobs; /* "this" one */
+ PANELOBS *lobs; /* last one */
+
+ pan = _bottom_panel;
+
+ while (pan)
+ {
+ if (pan->obscure)
+ _free_obscure(pan);
+
+ lobs = (PANELOBS *)0;
+ pan2 = _bottom_panel;
+
+ while (pan2)
+ {
+ if (_panels_overlapped(pan, pan2))
+ {
+ if ((tobs = malloc(sizeof(PANELOBS))) == NULL)
+ return;
+
+ tobs->pan = pan2;
+ dPanel("obscured", pan2);
+ tobs->above = (PANELOBS *)0;
+
+ if (lobs)
+ lobs->above = tobs;
+ else
+ pan->obscure = tobs;
+
+ lobs = tobs;
+ }
+
+ pan2 = pan2->above;
+ }
+
+ _override(pan, 1);
+ pan = pan->above;
+ }
+}
+
+/* check to see if panel is in the stack */
+
+static bool _panel_is_linked(const PANEL *pan)
+{
+ PANEL *pan2 = _bottom_panel;
+
+ while (pan2)
+ {
+ if (pan2 == pan)
+ return TRUE;
+
+ pan2 = pan2->above;
+ }
+
+ return FALSE;
+}
+
+/* link panel into stack at top */
+
+static void _panel_link_top(PANEL *pan)
+{
+#ifdef PANEL_DEBUG
+ dStack("<lt%d>", 1, pan);
+ if (_panel_is_linked(pan))
+ return;
+#endif
+ pan->above = (PANEL *)0;
+ pan->below = (PANEL *)0;
+
+ if (_top_panel)
+ {
+ _top_panel->above = pan;
+ pan->below = _top_panel;
+ }
+
+ _top_panel = pan;
+
+ if (!_bottom_panel)
+ _bottom_panel = pan;
+
+ _calculate_obscure();
+ dStack("<lt%d>", 9, pan);
+}
+
+/* link panel into stack at bottom */
+
+static void _panel_link_bottom(PANEL *pan)
+{
+#ifdef PANEL_DEBUG
+ dStack("<lb%d>", 1, pan);
+ if (_panel_is_linked(pan))
+ return;
+#endif
+ pan->above = (PANEL *)0;
+ pan->below = (PANEL *)0;
+
+ if (_bottom_panel)
+ {
+ _bottom_panel->below = pan;
+ pan->above = _bottom_panel;
+ }
+
+ _bottom_panel = pan;
+
+ if (!_top_panel)
+ _top_panel = pan;
+
+ _calculate_obscure();
+ dStack("<lb%d>", 9, pan);
+}
+
+static void _panel_unlink(PANEL *pan)
+{
+ PANEL *prev;
+ PANEL *next;
+
+#ifdef PANEL_DEBUG
+ dStack("<u%d>", 1, pan);
+ if (!_panel_is_linked(pan))
+ return;
+#endif
+ _override(pan, 0);
+ _free_obscure(pan);
+
+ prev = pan->below;
+ next = pan->above;
+
+ /* if non-zero, we will not update the list head */
+
+ if (prev)
+ {
+ prev->above = next;
+ if(next)
+ next->below = prev;
+ }
+ else if (next)
+ next->below = prev;
+
+ if (pan == _bottom_panel)
+ _bottom_panel = next;
+
+ if (pan == _top_panel)
+ _top_panel = prev;
+
+ _calculate_obscure();
+
+ pan->above = (PANEL *)0;
+ pan->below = (PANEL *)0;
+ dStack("<u%d>", 9, pan);
+
+}
+
+/************************************************************************
+ * The following are the public functions for the panels library. *
+ ************************************************************************/
+
+int bottom_panel(PANEL *pan)
+{
+ if (!pan)
+ return ERR;
+
+ if (pan == _bottom_panel)
+ return OK;
+
+ if (_panel_is_linked(pan))
+ hide_panel(pan);
+
+ _panel_link_bottom(pan);
+
+ return OK;
+}
+
+int del_panel(PANEL *pan)
+{
+ if (pan)
+ {
+ if (_panel_is_linked(pan))
+ hide_panel(pan);
+
+ free((char *)pan);
+ return OK;
+ }
+
+ return ERR;
+}
+
+int hide_panel(PANEL *pan)
+{
+ if (!pan)
+ return ERR;
+
+ if (!_panel_is_linked(pan))
+ {
+ pan->above = (PANEL *)0;
+ pan->below = (PANEL *)0;
+ return ERR;
+ }
+
+ _panel_unlink(pan);
+
+ return OK;
+}
+
+int move_panel(PANEL *pan, int starty, int startx)
+{
+ WINDOW *win;
+ int maxy, maxx;
+
+ if (!pan)
+ return ERR;
+
+ if (_panel_is_linked(pan))
+ _override(pan, 0);
+
+ win = pan->win;
+
+ if (mvwin(win, starty, startx) == ERR)
+ return ERR;
+
+ getbegyx(win, pan->wstarty, pan->wstartx);
+ getmaxyx(win, maxy, maxx);
+ pan->wendy = pan->wstarty + maxy;
+ pan->wendx = pan->wstartx + maxx;
+
+ if (_panel_is_linked(pan))
+ _calculate_obscure();
+
+ return OK;
+}
+
+PANEL *new_panel(WINDOW *win)
+{
+ PANEL *pan = malloc(sizeof(PANEL));
+
+ if (!_stdscr_pseudo_panel.win)
+ {
+ _stdscr_pseudo_panel.win = stdscr;
+ _stdscr_pseudo_panel.wstarty = 0;
+ _stdscr_pseudo_panel.wstartx = 0;
+ _stdscr_pseudo_panel.wendy = LINES;
+ _stdscr_pseudo_panel.wendx = COLS;
+ _stdscr_pseudo_panel.user = "stdscr";
+ _stdscr_pseudo_panel.obscure = (PANELOBS *)0;
+ }
+
+ if (pan)
+ {
+ int maxy, maxx;
+
+ pan->win = win;
+ pan->above = (PANEL *)0;
+ pan->below = (PANEL *)0;
+ getbegyx(win, pan->wstarty, pan->wstartx);
+ getmaxyx(win, maxy, maxx);
+ pan->wendy = pan->wstarty + maxy;
+ pan->wendx = pan->wstartx + maxx;
+#ifdef PANEL_DEBUG
+ pan->user = "new";
+#else
+ pan->user = (char *)0;
+#endif
+ pan->obscure = (PANELOBS *)0;
+ show_panel(pan);
+ }
+
+ return pan;
+}
+
+PANEL *panel_above(const PANEL *pan)
+{
+ return pan ? pan->above : _bottom_panel;
+}
+
+PANEL *panel_below(const PANEL *pan)
+{
+ return pan ? pan->below : _top_panel;
+}
+
+int panel_hidden(const PANEL *pan)
+{
+ if (!pan)
+ return ERR;
+
+ return _panel_is_linked(pan) ? ERR : OK;
+}
+
+const void *panel_userptr(const PANEL *pan)
+{
+ return pan ? pan->user : NULL;
+}
+
+WINDOW *panel_window(const PANEL *pan)
+{
+ PDC_LOG(("panel_window() - called\n"));
+
+ return pan->win;
+}
+
+int replace_panel(PANEL *pan, WINDOW *win)
+{
+ int maxy, maxx;
+
+ if (!pan)
+ return ERR;
+
+ if (_panel_is_linked(pan))
+ _override(pan, 0);
+
+ pan->win = win;
+ getbegyx(win, pan->wstarty, pan->wstartx);
+ getmaxyx(win, maxy, maxx);
+ pan->wendy = pan->wstarty + maxy;
+ pan->wendx = pan->wstartx + maxx;
+
+ if (_panel_is_linked(pan))
+ _calculate_obscure();
+
+ return OK;
+}
+
+int set_panel_userptr(PANEL *pan, const void *uptr)
+{
+ if (!pan)
+ return ERR;
+
+ pan->user = uptr;
+ return OK;
+}
+
+int show_panel(PANEL *pan)
+{
+ if (!pan)
+ return ERR;
+
+ if (pan == _top_panel)
+ return OK;
+
+ if (_panel_is_linked(pan))
+ hide_panel(pan);
+
+ _panel_link_top(pan);
+
+ return OK;
+}
+
+int top_panel(PANEL *pan)
+{
+ return show_panel(pan);
+}
+
+void update_panels(void)
+{
+ PANEL *pan;
+
+ PDC_LOG(("update_panels() - called\n"));
+
+ pan = _bottom_panel;
+
+ while (pan)
+ {
+ _override(pan, -1);
+ pan = pan->above;
+ }
+
+ if (is_wintouched(stdscr))
+ Wnoutrefresh(&_stdscr_pseudo_panel);
+
+ pan = _bottom_panel;
+
+ while (pan)
+ {
+ if (is_wintouched(pan->win) || !pan->above)
+ Wnoutrefresh(pan);
+
+ pan = pan->above;
+ }
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/printw.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/printw.c
new file mode 100644
index 0000000000..9be0c5fc20
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/printw.c
@@ -0,0 +1,123 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: printw.c,v 1.40 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: printw
+
+ Synopsis:
+ int printw(const char *fmt, ...);
+ int wprintw(WINDOW *win, const char *fmt, ...);
+ int mvprintw(int y, int x, const char *fmt, ...);
+ int mvwprintw(WINDOW *win, int y, int x, const char *fmt,...);
+ int vwprintw(WINDOW *win, const char *fmt, va_list varglist);
+ int vw_printw(WINDOW *win, const char *fmt, va_list varglist);
+
+ Description:
+ The printw() functions add a formatted string to the window at
+ the current or specified cursor position. The format strings are
+ the same as used in the standard C library's printf(). (printw()
+ can be used as a drop-in replacement for printf().)
+
+ Return Value:
+ All functions return the number of characters printed, or
+ ERR on error.
+
+ Portability X/Open BSD SYS V
+ printw Y Y Y
+ wprintw Y Y Y
+ mvprintw Y Y Y
+ mvwprintw Y Y Y
+ vwprintw Y - 4.0
+ vw_printw Y
+
+**man-end****************************************************************/
+
+#include <string.h>
+
+int vwprintw(WINDOW *win, const char *fmt, va_list varglist)
+{
+ char printbuf[513];
+ int len;
+
+ PDC_LOG(("vwprintw() - called\n"));
+
+#ifdef HAVE_VSNPRINTF
+ len = vsnprintf(printbuf, 512, fmt, varglist);
+#else
+ len = vsprintf(printbuf, fmt, varglist);
+#endif
+ return (waddstr(win, printbuf) == ERR) ? ERR : len;
+}
+
+int printw(const char *fmt, ...)
+{
+ va_list args;
+ int retval;
+
+ PDC_LOG(("printw() - called\n"));
+
+ va_start(args, fmt);
+ retval = vwprintw(stdscr, fmt, args);
+ va_end(args);
+
+ return retval;
+}
+
+int wprintw(WINDOW *win, const char *fmt, ...)
+{
+ va_list args;
+ int retval;
+
+ PDC_LOG(("wprintw() - called\n"));
+
+ va_start(args, fmt);
+ retval = vwprintw(win, fmt, args);
+ va_end(args);
+
+ return retval;
+}
+
+int mvprintw(int y, int x, const char *fmt, ...)
+{
+ va_list args;
+ int retval;
+
+ PDC_LOG(("mvprintw() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ va_start(args, fmt);
+ retval = vwprintw(stdscr, fmt, args);
+ va_end(args);
+
+ return retval;
+}
+
+int mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...)
+{
+ va_list args;
+ int retval;
+
+ PDC_LOG(("mvwprintw() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ va_start(args, fmt);
+ retval = vwprintw(win, fmt, args);
+ va_end(args);
+
+ return retval;
+}
+
+int vw_printw(WINDOW *win, const char *fmt, va_list varglist)
+{
+ PDC_LOG(("vw_printw() - called\n"));
+
+ return vwprintw(win, fmt, varglist);
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/refresh.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/refresh.c
new file mode 100644
index 0000000000..0b8e1ca5ed
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/refresh.c
@@ -0,0 +1,276 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: refresh.c,v 1.56 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: refresh
+
+ Synopsis:
+ int refresh(void);
+ int wrefresh(WINDOW *win);
+ int wnoutrefresh(WINDOW *win);
+ int doupdate(void);
+ int redrawwin(WINDOW *win);
+ int wredrawln(WINDOW *win, int beg_line, int num_lines);
+
+ Description:
+ wrefresh() copies the named window to the physical terminal
+ screen, taking into account what is already there in order to
+ optimize cursor movement. refresh() does the same, using stdscr.
+ These routines must be called to get any output on the terminal,
+ as other routines only manipulate data structures. Unless
+ leaveok() has been enabled, the physical cursor of the terminal
+ is left at the location of the window's cursor.
+
+ wnoutrefresh() and doupdate() allow multiple updates with more
+ efficiency than wrefresh() alone. wrefresh() works by first
+ calling wnoutrefresh(), which copies the named window to the
+ virtual screen. It then calls doupdate(), which compares the
+ virtual screen to the physical screen and does the actual
+ update. A series of calls to wrefresh() will result in
+ alternating calls to wnoutrefresh() and doupdate(), causing
+ several bursts of output to the screen. By first calling
+ wnoutrefresh() for each window, it is then possible to call
+ doupdate() only once.
+
+ In PDCurses, redrawwin() is equivalent to touchwin(), and
+ wredrawln() is the same as touchline(). In some other curses
+ implementations, there's a subtle distinction, but it has no
+ meaning in PDCurses.
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ refresh Y Y Y
+ wrefresh Y Y Y
+ wnoutrefresh Y Y Y
+ doupdate Y Y Y
+ redrawwin Y - 4.0
+ wredrawln Y - 4.0
+
+**man-end****************************************************************/
+
+#include <string.h>
+
+int wnoutrefresh(WINDOW *win)
+{
+ int begy, begx; /* window's place on screen */
+ int i, j;
+
+ PDC_LOG(("wnoutrefresh() - called: win=%p\n", win));
+
+ if ( !win || (win->_flags & (_PAD|_SUBPAD)) )
+ return ERR;
+
+ begy = win->_begy;
+ begx = win->_begx;
+
+ for (i = 0, j = begy; i < win->_maxy; i++, j++)
+ {
+ if (win->_firstch[i] != _NO_CHANGE)
+ {
+ chtype *src = win->_y[i];
+ chtype *dest = curscr->_y[j] + begx;
+
+ int first = win->_firstch[i]; /* first changed */
+ int last = win->_lastch[i]; /* last changed */
+
+ /* ignore areas on the outside that are marked as changed,
+ but really aren't */
+
+ while (first <= last && src[first] == dest[first])
+ first++;
+
+ while (last >= first && src[last] == dest[last])
+ last--;
+
+ /* if any have really changed... */
+
+ if (first <= last)
+ {
+ memcpy(dest + first, src + first,
+ (last - first + 1) * sizeof(chtype));
+
+ first += begx;
+ last += begx;
+
+ if (first < curscr->_firstch[j] ||
+ curscr->_firstch[j] == _NO_CHANGE)
+ curscr->_firstch[j] = first;
+
+ if (last > curscr->_lastch[j])
+ curscr->_lastch[j] = last;
+ }
+
+ win->_firstch[i] = _NO_CHANGE; /* updated now */
+ }
+
+ win->_lastch[i] = _NO_CHANGE; /* updated now */
+ }
+
+ if (win->_clear)
+ win->_clear = FALSE;
+
+ if (!win->_leaveit)
+ {
+ curscr->_cury = win->_cury + begy;
+ curscr->_curx = win->_curx + begx;
+ }
+
+ return OK;
+}
+
+int doupdate(void)
+{
+ int y;
+ bool clearall;
+
+ PDC_LOG(("doupdate() - called\n"));
+
+ if (!curscr)
+ return ERR;
+
+ if (isendwin()) /* coming back after endwin() called */
+ {
+ reset_prog_mode();
+ clearall = TRUE;
+ SP->alive = TRUE; /* so isendwin() result is correct */
+ }
+ else
+ clearall = curscr->_clear;
+
+ for (y = 0; y < SP->lines; y++)
+ {
+ PDC_LOG(("doupdate() - Transforming line %d of %d: %s\n",
+ y, SP->lines, (curscr->_firstch[y] != _NO_CHANGE) ?
+ "Yes" : "No"));
+
+ if (clearall || curscr->_firstch[y] != _NO_CHANGE)
+ {
+ int first, last;
+
+ chtype *src = curscr->_y[y];
+ chtype *dest = pdc_lastscr->_y[y];
+
+ if (clearall)
+ {
+ first = 0;
+ last = COLS - 1;
+ }
+ else
+ {
+ first = curscr->_firstch[y];
+ last = curscr->_lastch[y];
+ }
+
+ while (first <= last)
+ {
+ int len = 0;
+
+ /* build up a run of changed cells; if two runs are
+ separated by a single unchanged cell, ignore the
+ break */
+
+ if (clearall)
+ len = last - first + 1;
+ else
+ while (first + len <= last &&
+ (src[first + len] != dest[first + len] ||
+ (len && first + len < last &&
+ src[first + len + 1] != dest[first + len + 1])
+ )
+ )
+ len++;
+
+ /* update the screen, and pdc_lastscr */
+
+ if (len)
+ {
+ PDC_transform_line(y, first, len, src + first);
+ memcpy(dest + first, src + first, len * sizeof(chtype));
+ first += len;
+ }
+
+ /* skip over runs of unchanged cells */
+
+ while (first <= last && src[first] == dest[first])
+ first++;
+ }
+
+ curscr->_firstch[y] = _NO_CHANGE;
+ curscr->_lastch[y] = _NO_CHANGE;
+ }
+ }
+
+ curscr->_clear = FALSE;
+
+ if (SP->visibility)
+ PDC_gotoyx(curscr->_cury, curscr->_curx);
+
+ SP->cursrow = curscr->_cury;
+ SP->curscol = curscr->_curx;
+
+ return OK;
+}
+
+int wrefresh(WINDOW *win)
+{
+ bool save_clear;
+
+ PDC_LOG(("wrefresh() - called\n"));
+
+ if ( !win || (win->_flags & (_PAD|_SUBPAD)) )
+ return ERR;
+
+ save_clear = win->_clear;
+
+ if (win == curscr)
+ curscr->_clear = TRUE;
+ else
+ wnoutrefresh(win);
+
+ if (save_clear && win->_maxy == SP->lines && win->_maxx == SP->cols)
+ curscr->_clear = TRUE;
+
+ return doupdate();
+}
+
+int refresh(void)
+{
+ PDC_LOG(("refresh() - called\n"));
+
+ return wrefresh(stdscr);
+}
+
+int wredrawln(WINDOW *win, int start, int num)
+{
+ int i;
+
+ PDC_LOG(("wredrawln() - called: win=%p start=%d num=%d\n",
+ win, start, num));
+
+ if (!win || start > win->_maxy || start + num > win->_maxy)
+ return ERR;
+
+ for (i = start; i < start + num; i++)
+ {
+ win->_firstch[i] = 0;
+ win->_lastch[i] = win->_maxx - 1;
+ }
+
+ return OK;
+}
+
+int redrawwin(WINDOW *win)
+{
+ PDC_LOG(("redrawwin() - called: win=%p\n", win));
+
+ if (!win)
+ return ERR;
+
+ return wredrawln(win, 0, win->_maxy);
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/scanw.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/scanw.c
new file mode 100644
index 0000000000..af2bcb9e1b
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/scanw.c
@@ -0,0 +1,575 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: scanw.c,v 1.42 2008/07/14 12:22:13 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: scanw
+
+ Synopsis:
+ int scanw(const char *fmt, ...);
+ int wscanw(WINDOW *win, const char *fmt, ...);
+ int mvscanw(int y, int x, const char *fmt, ...);
+ int mvwscanw(WINDOW *win, int y, int x, const char *fmt, ...);
+ int vwscanw(WINDOW *win, const char *fmt, va_list varglist);
+ int vw_scanw(WINDOW *win, const char *fmt, va_list varglist);
+
+ Description:
+ These routines correspond to the standard C library's scanf()
+ family. Each gets a string from the window via wgetnstr(), and
+ uses the resulting line as input for the scan.
+
+ Return Value:
+ On successful completion, these functions return the number of
+ items successfully matched. Otherwise they return ERR.
+
+ Portability X/Open BSD SYS V
+ scanw Y Y Y
+ wscanw Y Y Y
+ mvscanw Y Y Y
+ mvwscanw Y Y Y
+ vwscanw Y - 4.0
+ vw_scanw Y
+
+**man-end****************************************************************/
+
+#include <string.h>
+
+#ifndef HAVE_VSSCANF
+# include <stdlib.h>
+# include <ctype.h>
+# include <limits.h>
+
+static int _pdc_vsscanf(const char *, const char *, va_list);
+
+# define vsscanf _pdc_vsscanf
+#endif
+
+int vwscanw(WINDOW *win, const char *fmt, va_list varglist)
+{
+ char scanbuf[256];
+
+ PDC_LOG(("vwscanw() - called\n"));
+
+ if (wgetnstr(win, scanbuf, 255) == ERR)
+ return ERR;
+
+ return vsscanf(scanbuf, fmt, varglist);
+}
+
+int scanw(const char *fmt, ...)
+{
+ va_list args;
+ int retval;
+
+ PDC_LOG(("scanw() - called\n"));
+
+ va_start(args, fmt);
+ retval = vwscanw(stdscr, fmt, args);
+ va_end(args);
+
+ return retval;
+}
+
+int wscanw(WINDOW *win, const char *fmt, ...)
+{
+ va_list args;
+ int retval;
+
+ PDC_LOG(("wscanw() - called\n"));
+
+ va_start(args, fmt);
+ retval = vwscanw(win, fmt, args);
+ va_end(args);
+
+ return retval;
+}
+
+int mvscanw(int y, int x, const char *fmt, ...)
+{
+ va_list args;
+ int retval;
+
+ PDC_LOG(("mvscanw() - called\n"));
+
+ if (move(y, x) == ERR)
+ return ERR;
+
+ va_start(args, fmt);
+ retval = vwscanw(stdscr, fmt, args);
+ va_end(args);
+
+ return retval;
+}
+
+int mvwscanw(WINDOW *win, int y, int x, const char *fmt, ...)
+{
+ va_list args;
+ int retval;
+
+ PDC_LOG(("mvscanw() - called\n"));
+
+ if (wmove(win, y, x) == ERR)
+ return ERR;
+
+ va_start(args, fmt);
+ retval = vwscanw(win, fmt, args);
+ va_end(args);
+
+ return retval;
+}
+
+int vw_scanw(WINDOW *win, const char *fmt, va_list varglist)
+{
+ PDC_LOG(("vw_scanw() - called\n"));
+
+ return vwscanw(win, fmt, varglist);
+}
+
+#ifndef HAVE_VSSCANF
+
+/* _pdc_vsscanf() - Internal routine to parse and format an input
+ buffer. It scans a series of input fields; each field is formatted
+ according to a supplied format string and the formatted input is
+ stored in the variable number of addresses passed. Returns the number
+ of input fields or EOF on error.
+
+ Don't compile this unless required. Some compilers (at least Borland
+ C++ 3.0) have to link with math libraries due to the use of floats.
+
+ Based on vsscanf.c and input.c from emx 0.8f library source,
+ Copyright (c) 1990-1992 by Eberhard Mattes, who has kindly agreed to
+ its inclusion in PDCurses. */
+
+#define WHITE(x) ((x) == ' ' || (x) == '\t' || (x) == '\n')
+
+#define NEXT(x) \
+ do { \
+ x = *buf++; \
+ if (!x) \
+ return (count ? count : EOF); \
+ ++chars; \
+ } while (0)
+
+#define UNGETC() \
+ do { \
+ --buf; --chars; \
+ } while (0)
+
+static int _pdc_vsscanf(const char *buf, const char *fmt, va_list arg_ptr)
+{
+ int count, chars, c, width, radix, d, i;
+ int *int_ptr;
+ long *long_ptr;
+ short *short_ptr;
+ char *char_ptr;
+ unsigned char f;
+ char neg, assign, ok, size;
+ long n;
+ char map[256], end;
+ double dx, dd, *dbl_ptr;
+ float *flt_ptr;
+ int exp;
+ char eneg;
+
+ count = 0;
+ chars = 0;
+ c = 0;
+ while ((f = *fmt) != 0)
+ {
+ if (WHITE(f))
+ {
+ do
+ {
+ ++fmt;
+ f = *fmt;
+ }
+ while (WHITE(f));
+ do
+ {
+ c = *buf++;
+ if (!c)
+ {
+ if (!f || count)
+ return count;
+ else
+ return EOF;
+ } else
+ ++chars;
+ }
+ while (WHITE(c));
+ UNGETC();
+ } else if (f != '%')
+ {
+ NEXT(c);
+ if (c != f)
+ return count;
+ ++fmt;
+ } else
+ {
+ assign = TRUE;
+ width = INT_MAX;
+ char_ptr = NULL;
+ ++fmt;
+ if (*fmt == '*')
+ {
+ assign = FALSE;
+ ++fmt;
+ }
+ if (isdigit(*fmt))
+ {
+ width = 0;
+ while (isdigit(*fmt))
+ width = width * 10 + (*fmt++ - '0');
+ if (!width)
+ width = INT_MAX;
+ }
+ size = 0;
+ if (*fmt == 'h' || *fmt == 'l')
+ size = *fmt++;
+ f = *fmt;
+ switch (f)
+ {
+ case 'c':
+ if (width == INT_MAX)
+ width = 1;
+ if (assign)
+ char_ptr = va_arg(arg_ptr, char *);
+ while (width > 0)
+ {
+ --width;
+ NEXT(c);
+ if (assign)
+ {
+ *char_ptr++ = (char) c;
+ ++count;
+ }
+ }
+ break;
+ case '[':
+ memset(map, 0, 256);
+ end = 0;
+ ++fmt;
+ if (*fmt == '^')
+ {
+ ++fmt;
+ end = 1;
+ }
+ i = 0;
+ for (;;)
+ {
+ f = (unsigned char) *fmt;
+ switch (f)
+ {
+ case 0:
+ /* avoid skipping past 0 */
+ --fmt;
+ NEXT(c);
+ goto string;
+ case ']':
+ if (i > 0)
+ {
+ NEXT(c);
+ goto string;
+ }
+ /* no break */
+ default:
+ if (fmt[1] == '-' && fmt[2]
+ && f < (unsigned char)fmt[2])
+ {
+ memset(map + f, 1, (unsigned char)fmt[2] - f);
+ fmt += 2;
+ }
+ else
+ map[f] = 1;
+ break;
+ }
+ ++fmt;
+ ++i;
+ }
+ case 's':
+ memset(map, 0, 256);
+ map[' '] = 1;
+ map['\n'] = 1;
+ map['\r'] = 1;
+ map['\t'] = 1;
+ end = 1;
+ do
+ {
+ NEXT(c);
+ }
+ while (WHITE(c));
+ string:
+ if (assign)
+ char_ptr = va_arg(arg_ptr, char *);
+ while (width > 0 && map[(unsigned char) c] != end)
+ {
+ --width;
+ if (assign)
+ *char_ptr++ = (char) c;
+ c = *buf++;
+ if (!c)
+ break;
+ else
+ ++chars;
+ }
+ if (assign)
+ {
+ *char_ptr = 0;
+ ++count;
+ }
+ if (!c)
+ return count;
+ else
+ UNGETC();
+ break;
+ case 'f':
+ case 'e':
+ case 'E':
+ case 'g':
+ case 'G':
+ neg = ok = FALSE;
+ dx = 0.0;
+ do
+ {
+ NEXT(c);
+ }
+ while (WHITE(c));
+ if (c == '+')
+ {
+ NEXT(c);
+ --width;
+ } else if (c == '-')
+ {
+ neg = TRUE;
+ NEXT(c);
+ --width;
+ }
+ while (width > 0 && isdigit(c))
+ {
+ --width;
+ dx = dx * 10.0 + (double) (c - '0');
+ ok = TRUE;
+ c = *buf++;
+ if (!c)
+ break;
+ else
+ ++chars;
+ }
+ if (width > 0 && c == '.')
+ {
+ --width;
+ dd = 10.0;
+ NEXT(c);
+ while (width > 0 && isdigit(c))
+ {
+ --width;
+ dx += (double) (c - '0') / dd;
+ dd *= 10.0;
+ ok = TRUE;
+ c = *buf++;
+ if (!c)
+ break;
+ else
+ ++chars;
+ }
+ }
+ if (!ok)
+ return count;
+ if (width > 0 && (c == 'e' || c == 'E'))
+ {
+ eneg = FALSE;
+ exp = 0;
+ NEXT(c);
+ --width;
+ if (width > 0 && c == '+')
+ {
+ NEXT(c);
+ --width;
+ } else if (width > 0 && c == '-')
+ {
+ eneg = TRUE;
+ NEXT(c);
+ --width;
+ }
+ if (!(width > 0 && isdigit(c)))
+ {
+ UNGETC();
+ return count;
+ }
+ while (width > 0 && isdigit(c))
+ {
+ --width;
+ exp = exp * 10 + (c - '0');
+ c = *buf++;
+ if (!c)
+ break;
+ else
+ ++chars;
+ }
+ if (eneg)
+ exp = -exp;
+ while (exp > 0)
+ {
+ dx *= 10.0;
+ --exp;
+ }
+ while (exp < 0)
+ {
+ dx /= 10.0;
+ ++exp;
+ }
+ }
+ if (assign)
+ {
+ if (neg)
+ dx = -dx;
+ if (size == 'l')
+ {
+ dbl_ptr = va_arg(arg_ptr, double *);
+ *dbl_ptr = dx;
+ }
+ else
+ {
+ flt_ptr = va_arg(arg_ptr, float *);
+ *flt_ptr = (float)dx;
+ }
+ ++count;
+ }
+ if (!c)
+ return count;
+ else
+ UNGETC();
+ break;
+ case 'i':
+ neg = FALSE;
+ radix = 10;
+ do
+ {
+ NEXT(c);
+ }
+ while (WHITE(c));
+ if (!(width > 0 && c == '0'))
+ goto scan_complete_number;
+ NEXT(c);
+ --width;
+ if (width > 0 && (c == 'x' || c == 'X'))
+ {
+ NEXT(c);
+ radix = 16;
+ --width;
+ }
+ else if (width > 0 && (c >= '0' && c <= '7'))
+ radix = 8;
+ goto scan_unsigned_number;
+ case 'd':
+ case 'u':
+ case 'o':
+ case 'x':
+ case 'X':
+ do
+ {
+ NEXT(c);
+ }
+ while (WHITE(c));
+ switch (f)
+ {
+ case 'o':
+ radix = 8;
+ break;
+ case 'x':
+ case 'X':
+ radix = 16;
+ break;
+ default:
+ radix = 10;
+ break;
+ }
+ scan_complete_number:
+ neg = FALSE;
+ if (width > 0 && c == '+')
+ {
+ NEXT(c);
+ --width;
+ }
+ else if (width > 0 && c == '-' && radix == 10)
+ {
+ neg = TRUE;
+ NEXT(c);
+ --width;
+ }
+ scan_unsigned_number:
+ n = 0;
+ ok = FALSE;
+ while (width > 0)
+ {
+ --width;
+ if (isdigit(c))
+ d = c - '0';
+ else if (isupper(c))
+ d = c - 'A' + 10;
+ else if (islower(c))
+ d = c - 'a' + 10;
+ else
+ break;
+ if (d < 0 || d >= radix)
+ break;
+ ok = TRUE;
+ n = n * radix + d;
+ c = *buf++;
+ if (!c)
+ break;
+ else
+ ++chars;
+ }
+ if (!ok)
+ return count;
+ if (assign)
+ {
+ if (neg)
+ n = -n;
+ switch (size)
+ {
+ case 'h':
+ short_ptr = va_arg(arg_ptr, short *);
+ *short_ptr = (short) n;
+ break;
+ case 'l':
+ long_ptr = va_arg(arg_ptr, long *);
+ *long_ptr = (long) n;
+ break;
+ default:
+ int_ptr = va_arg(arg_ptr, int *);
+ *int_ptr = (int) n;
+ }
+ ++count;
+ }
+ if (!c)
+ return count;
+ else
+ UNGETC();
+ break;
+ case 'n':
+ if (assign)
+ {
+ int_ptr = va_arg(arg_ptr, int *);
+ *int_ptr = chars;
+ ++count;
+ }
+ break;
+ default:
+ if (!f) /* % at end of string */
+ return count;
+ NEXT(c);
+ if (c != f)
+ return count;
+ break;
+ }
+ ++fmt;
+ }
+ }
+ return count;
+}
+#endif /* HAVE_VSSCANF */
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/scr_dump.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/scr_dump.c
new file mode 100644
index 0000000000..e02046e5ff
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/scr_dump.c
@@ -0,0 +1,210 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: scr_dump.c,v 1.30 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: scr_dump
+
+ Synopsis:
+ int putwin(WINDOW *win, FILE *filep);
+ WINDOW *getwin(FILE *filep);
+ int scr_dump(const char *filename);
+ int scr_init(const char *filename);
+ int scr_restore(const char *filename);
+ int scr_set(const char *filename);
+
+ Description:
+ getwin() reads window-related data previously stored in a file
+ by putwin(). It then creates and initialises a new window using
+ that data.
+
+ putwin() writes all data associated with a window into a file,
+ using an unspecified format. This information can be retrieved
+ later using getwin().
+
+ scr_dump() writes the current contents of the virtual screen to
+ the file named by filename in an unspecified format.
+
+ scr_restore() function sets the virtual screen to the contents
+ of the file named by filename, which must have been written
+ using scr_dump(). The next refresh operation restores the screen
+ to the way it looked in the dump file.
+
+ In PDCurses, scr_init() does nothing, and scr_set() is a synonym
+ for scr_restore(). Also, scr_dump() and scr_restore() save and
+ load from curscr. This differs from some other implementations,
+ where scr_init() works with curscr, and scr_restore() works with
+ newscr; but the effect should be the same. (PDCurses has no
+ newscr.)
+
+ Return Value:
+ On successful completion, getwin() returns a pointer to the
+ window it created. Otherwise, it returns a null pointer. Other
+ functions return OK or ERR.
+
+ Portability X/Open BSD SYS V
+ putwin Y
+ getwin Y
+ scr_dump Y
+ scr_init Y
+ scr_restore Y
+ scr_set Y
+
+**man-end****************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+
+#define DUMPVER 1 /* Should be updated whenever the WINDOW struct is
+ changed */
+
+int putwin(WINDOW *win, FILE *filep)
+{
+ static const char *marker = "PDC";
+ static const unsigned char version = DUMPVER;
+
+ PDC_LOG(("putwin() - called\n"));
+
+ /* write the marker and the WINDOW struct */
+
+ if (filep && fwrite(marker, strlen(marker), 1, filep)
+ && fwrite(&version, 1, 1, filep)
+ && fwrite(win, sizeof(WINDOW), 1, filep))
+ {
+ int i;
+
+ /* write each line */
+
+ for (i = 0; i < win->_maxy && win->_y[i]; i++)
+ if (!fwrite(win->_y[i], win->_maxx * sizeof(chtype), 1, filep))
+ return ERR;
+
+ return OK;
+ }
+
+ return ERR;
+}
+
+WINDOW *getwin(FILE *filep)
+{
+ WINDOW *win;
+ char marker[4];
+ int i, nlines, ncols;
+
+ PDC_LOG(("getwin() - called\n"));
+
+ if ( !(win = malloc(sizeof(WINDOW))) )
+ return (WINDOW *)NULL;
+
+ /* check for the marker, and load the WINDOW struct */
+
+ if (!filep || !fread(marker, 4, 1, filep) || strncmp(marker, "PDC", 3)
+ || marker[3] != DUMPVER || !fread(win, sizeof(WINDOW), 1, filep))
+ {
+ free(win);
+ return (WINDOW *)NULL;
+ }
+
+ nlines = win->_maxy;
+ ncols = win->_maxx;
+
+ /* allocate the line pointer array */
+
+ if ( !(win->_y = malloc(nlines * sizeof(chtype *))) )
+ {
+ free(win);
+ return (WINDOW *)NULL;
+ }
+
+ /* allocate the minchng and maxchng arrays */
+
+ if ( !(win->_firstch = malloc(nlines * sizeof(int))) )
+ {
+ free(win->_y);
+ free(win);
+ return (WINDOW *)NULL;
+ }
+
+ if ( !(win->_lastch = malloc(nlines * sizeof(int))) )
+ {
+ free(win->_firstch);
+ free(win->_y);
+ free(win);
+ return (WINDOW *)NULL;
+ }
+
+ /* allocate the lines */
+
+ if ( !(win = PDC_makelines(win)) )
+ return (WINDOW *)NULL;
+
+ /* read them */
+
+ for (i = 0; i < nlines; i++)
+ {
+ if (!fread(win->_y[i], ncols * sizeof(chtype), 1, filep))
+ {
+ delwin(win);
+ return (WINDOW *)NULL;
+ }
+ }
+
+ touchwin(win);
+
+ return win;
+}
+
+int scr_dump(const char *filename)
+{
+ FILE *filep;
+
+ PDC_LOG(("scr_dump() - called: filename %s\n", filename));
+
+ if (filename && (filep = fopen(filename, "wb")) != NULL)
+ {
+ int result = putwin(curscr, filep);
+ fclose(filep);
+ return result;
+ }
+
+ return ERR;
+}
+
+int scr_init(const char *filename)
+{
+ PDC_LOG(("scr_init() - called: filename %s\n", filename));
+
+ return OK;
+}
+
+int scr_restore(const char *filename)
+{
+ FILE *filep;
+
+ PDC_LOG(("scr_restore() - called: filename %s\n", filename));
+
+ if (filename && (filep = fopen(filename, "rb")) != NULL)
+ {
+ WINDOW *replacement = getwin(filep);
+ fclose(filep);
+
+ if (replacement)
+ {
+ int result = overwrite(replacement, curscr);
+ delwin(replacement);
+ return result;
+ }
+ }
+
+ return ERR;
+}
+
+int scr_set(const char *filename)
+{
+ PDC_LOG(("scr_set() - called: filename %s\n", filename));
+
+ return scr_restore(filename);
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/scroll.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/scroll.c
new file mode 100644
index 0000000000..c53e295468
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/scroll.c
@@ -0,0 +1,98 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: scroll.c,v 1.36 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: scroll
+
+ Synopsis:
+ int scroll(WINDOW *win);
+ int scrl(int n);
+ int wscrl(WINDOW *win, int n);
+
+ Description:
+ scroll() causes the window to scroll up one line. This involves
+ moving the lines in the window data strcture.
+
+ With a positive n, scrl() and wscrl() scroll the window up n
+ lines (line i + n becomes i); otherwise they scroll the window
+ down n lines.
+
+ For these functions to work, scrolling must be enabled via
+ scrollok(). Note also that scrolling is not allowed if the
+ supplied window is a pad.
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ scroll Y Y Y
+ scrl Y - 4.0
+ wscrl Y - 4.0
+
+**man-end****************************************************************/
+
+int wscrl(WINDOW *win, int n)
+{
+ int i, l, dir, start, end;
+ chtype blank, *temp;
+
+ /* Check if window scrolls. Valid for window AND pad */
+
+ if (!win || !win->_scroll || !n)
+ return ERR;
+
+ blank = win->_bkgd;
+
+ if (n > 0)
+ {
+ start = win->_tmarg;
+ end = win->_bmarg;
+ dir = 1;
+ }
+ else
+ {
+ start = win->_bmarg;
+ end = win->_tmarg;
+ dir = -1;
+ }
+
+ for (l = 0; l < (n * dir); l++)
+ {
+ temp = win->_y[start];
+
+ /* re-arrange line pointers */
+
+ for (i = start; i != end; i += dir)
+ win->_y[i] = win->_y[i + dir];
+
+ win->_y[end] = temp;
+
+ /* make a blank line */
+
+ for (i = 0; i < win->_maxx; i++)
+ *temp++ = blank;
+ }
+
+ touchline(win, win->_tmarg, win->_bmarg - win->_tmarg + 1);
+
+ PDC_sync(win);
+ return OK;
+}
+
+int scrl(int n)
+{
+ PDC_LOG(("scrl() - called\n"));
+
+ return wscrl(stdscr, n);
+}
+
+int scroll(WINDOW *win)
+{
+ PDC_LOG(("scroll() - called\n"));
+
+ return wscrl(win, 1);
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/slk.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/slk.c
new file mode 100644
index 0000000000..f97f406e37
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/slk.c
@@ -0,0 +1,643 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: slk.c,v 1.61 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: slk
+
+ Synopsis:
+ int slk_init(int fmt);
+ int slk_set(int labnum, const char *label, int justify);
+ int slk_refresh(void);
+ int slk_noutrefresh(void);
+ char *slk_label(int labnum);
+ int slk_clear(void);
+ int slk_restore(void);
+ int slk_touch(void);
+ int slk_attron(const chtype attrs);
+ int slk_attr_on(const attr_t attrs, void *opts);
+ int slk_attrset(const chtype attrs);
+ int slk_attr_set(const attr_t attrs, short color_pair, void *opts);
+ int slk_attroff(const chtype attrs);
+ int slk_attr_off(const attr_t attrs, void *opts);
+ int slk_color(short color_pair);
+
+ int slk_wset(int labnum, const wchar_t *label, int justify);
+
+ int PDC_mouse_in_slk(int y, int x);
+ void PDC_slk_free(void);
+ void PDC_slk_initialize(void);
+
+ wchar_t *slk_wlabel(int labnum)
+
+ Description:
+ These functions manipulate a window that contain Soft Label Keys
+ (SLK). To use the SLK functions, a call to slk_init() must be
+ made BEFORE initscr() or newterm(). slk_init() removes 1 or 2
+ lines from the useable screen, depending on the format selected.
+
+ The line(s) removed from the screen are used as a separate
+ window, in which SLKs are displayed.
+
+ slk_init() requires a single parameter which describes the
+ format of the SLKs as follows:
+
+ 0 3-2-3 format
+ 1 4-4 format
+ 2 4-4-4 format (ncurses extension)
+ 3 4-4-4 format with index line (ncurses extension)
+ 2 lines used
+ 55 5-5 format (pdcurses format)
+
+ slk_refresh(), slk_noutrefresh() and slk_touch() are analogous
+ to refresh(), noutrefresh() and touch().
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ slk_init Y - Y
+ slk_set Y - Y
+ slk_refresh Y - Y
+ slk_noutrefresh Y - Y
+ slk_label Y - Y
+ slk_clear Y - Y
+ slk_restore Y - Y
+ slk_touch Y - Y
+ slk_attron Y - Y
+ slk_attrset Y - Y
+ slk_attroff Y - Y
+ slk_attr_on Y
+ slk_attr_set Y
+ slk_attr_off Y
+ slk_wset Y
+ PDC_mouse_in_slk - - -
+ PDC_slk_free - - -
+ PDC_slk_initialize - - -
+ slk_wlabel - - -
+
+**man-end****************************************************************/
+
+#include <stdlib.h>
+
+enum { LABEL_NORMAL = 8, LABEL_EXTENDED = 10, LABEL_NCURSES_EXTENDED = 12 };
+
+static int label_length = 0;
+static int labels = 0;
+static int label_fmt = 0;
+static int label_line = 0;
+static bool hidden = FALSE;
+
+static struct SLK {
+ chtype label[32];
+ int len;
+ int format;
+ int start_col;
+} *slk = (struct SLK *)NULL;
+
+/* slk_init() is the slk initialization routine.
+ This must be called before initscr().
+
+ label_fmt = 0, 1 or 55.
+ 0 = 3-2-3 format
+ 1 = 4 - 4 format
+ 2 = 4-4-4 format (ncurses extension for PC 12 function keys)
+ 3 = 4-4-4 format (ncurses extension for PC 12 function keys -
+ with index line)
+ 55 = 5 - 5 format (extended for PC, 10 function keys) */
+
+int slk_init(int fmt)
+{
+ PDC_LOG(("slk_init() - called\n"));
+
+ if (SP)
+ return ERR;
+
+ switch (fmt)
+ {
+ case 0: /* 3 - 2 - 3 */
+ labels = LABEL_NORMAL;
+ break;
+
+ case 1: /* 4 - 4 */
+ labels = LABEL_NORMAL;
+ break;
+
+ case 2: /* 4 4 4 */
+ labels = LABEL_NCURSES_EXTENDED;
+ break;
+
+ case 3: /* 4 4 4 with index */
+ labels = LABEL_NCURSES_EXTENDED;
+ break;
+
+ case 55: /* 5 - 5 */
+ labels = LABEL_EXTENDED;
+ break;
+
+ default:
+ return ERR;
+ }
+
+ label_fmt = fmt;
+
+ slk = calloc(labels, sizeof(struct SLK));
+
+ if (!slk)
+ labels = 0;
+
+ return slk ? OK : ERR;
+}
+
+/* draw a single button */
+
+static void _drawone(int num)
+{
+ int i, col, slen;
+
+ if (hidden)
+ return;
+
+ slen = slk[num].len;
+
+ switch (slk[num].format)
+ {
+ case 0: /* LEFT */
+ col = 0;
+ break;
+
+ case 1: /* CENTER */
+ col = (label_length - slen) / 2;
+
+ if (col + slen > label_length)
+ --col;
+ break;
+
+ default: /* RIGHT */
+ col = label_length - slen;
+ }
+
+ wmove(SP->slk_winptr, label_line, slk[num].start_col);
+
+ for (i = 0; i < label_length; ++i)
+ waddch(SP->slk_winptr, (i >= col && i < (col + slen)) ?
+ slk[num].label[i - col] : ' ');
+}
+
+/* redraw each button */
+
+static void _redraw(void)
+{
+ int i;
+
+ for (i = 0; i < labels; ++i)
+ _drawone(i);
+}
+
+/* slk_set() Used to set a slk label to a string.
+
+ labnum = 1 - 8 (or 10) (number of the label)
+ label = string (8 or 7 bytes total), or NULL
+ justify = 0 : left, 1 : center, 2 : right */
+
+int slk_set(int labnum, const char *label, int justify)
+{
+#ifdef PDC_WIDE
+ wchar_t wlabel[32];
+
+ PDC_mbstowcs(wlabel, label, 31);
+ return slk_wset(labnum, wlabel, justify);
+#else
+ PDC_LOG(("slk_set() - called\n"));
+
+ if (labnum < 1 || labnum > labels || justify < 0 || justify > 2)
+ return ERR;
+
+ labnum--;
+
+ if (!label || !(*label))
+ {
+ /* Clear the label */
+
+ *slk[labnum].label = 0;
+ slk[labnum].format = 0;
+ slk[labnum].len = 0;
+ }
+ else
+ {
+ int i, j = 0;
+
+ /* Skip leading spaces */
+
+ while (label[j] == ' ')
+ j++;
+
+ /* Copy it */
+
+ for (i = 0; i < label_length; i++)
+ {
+ chtype ch = label[i + j];
+
+ slk[labnum].label[i] = ch;
+
+ if (!ch)
+ break;
+ }
+
+ /* Drop trailing spaces */
+
+ while ((i + j) && (label[i + j - 1] == ' '))
+ i--;
+
+ slk[labnum].label[i] = 0;
+ slk[labnum].format = justify;
+ slk[labnum].len = i;
+ }
+
+ _drawone(labnum);
+
+ return OK;
+#endif
+}
+
+int slk_refresh(void)
+{
+ PDC_LOG(("slk_refresh() - called\n"));
+
+ return (slk_noutrefresh() == ERR) ? ERR : doupdate();
+}
+
+int slk_noutrefresh(void)
+{
+ PDC_LOG(("slk_noutrefresh() - called\n"));
+
+ return wnoutrefresh(SP->slk_winptr);
+}
+
+char *slk_label(int labnum)
+{
+ static char temp[33];
+#ifdef PDC_WIDE
+ wchar_t *wtemp = slk_wlabel(labnum);
+
+ PDC_wcstombs(temp, wtemp, 32);
+#else
+ chtype *p;
+ int i;
+
+ PDC_LOG(("slk_label() - called\n"));
+
+ if (labnum < 1 || labnum > labels)
+ return (char *)0;
+
+ for (i = 0, p = slk[labnum - 1].label; *p; i++)
+ temp[i] = *p++;
+
+ temp[i] = '\0';
+#endif
+ return temp;
+}
+
+int slk_clear(void)
+{
+ PDC_LOG(("slk_clear() - called\n"));
+
+ hidden = TRUE;
+ werase(SP->slk_winptr);
+ return wrefresh(SP->slk_winptr);
+}
+
+int slk_restore(void)
+{
+ PDC_LOG(("slk_restore() - called\n"));
+
+ hidden = FALSE;
+ _redraw();
+ return wrefresh(SP->slk_winptr);
+}
+
+int slk_touch(void)
+{
+ PDC_LOG(("slk_touch() - called\n"));
+
+ return touchwin(SP->slk_winptr);
+}
+
+int slk_attron(const chtype attrs)
+{
+ int rc;
+
+ PDC_LOG(("slk_attron() - called\n"));
+
+ rc = wattron(SP->slk_winptr, attrs);
+ _redraw();
+
+ return rc;
+}
+
+int slk_attr_on(const attr_t attrs, void *opts)
+{
+ PDC_LOG(("slk_attr_on() - called\n"));
+
+ return slk_attron(attrs);
+}
+
+int slk_attroff(const chtype attrs)
+{
+ int rc;
+
+ PDC_LOG(("slk_attroff() - called\n"));
+
+ rc = wattroff(SP->slk_winptr, attrs);
+ _redraw();
+
+ return rc;
+}
+
+int slk_attr_off(const attr_t attrs, void *opts)
+{
+ PDC_LOG(("slk_attr_off() - called\n"));
+
+ return slk_attroff(attrs);
+}
+
+int slk_attrset(const chtype attrs)
+{
+ int rc;
+
+ PDC_LOG(("slk_attrset() - called\n"));
+
+ rc = wattrset(SP->slk_winptr, attrs);
+ _redraw();
+
+ return rc;
+}
+
+int slk_color(short color_pair)
+{
+ int rc;
+
+ PDC_LOG(("slk_color() - called\n"));
+
+ rc = wcolor_set(SP->slk_winptr, color_pair, NULL);
+ _redraw();
+
+ return rc;
+}
+
+int slk_attr_set(const attr_t attrs, short color_pair, void *opts)
+{
+ PDC_LOG(("slk_attr_set() - called\n"));
+
+ return slk_attrset(attrs | COLOR_PAIR(color_pair));
+}
+
+static void _slk_calc(void)
+{
+ int i, center, col = 0;
+ label_length = COLS / labels;
+
+ if (label_length > 31)
+ label_length = 31;
+
+ switch (label_fmt)
+ {
+ case 0: /* 3 - 2 - 3 F-Key layout */
+
+ --label_length;
+
+ slk[0].start_col = col;
+ slk[1].start_col = (col += label_length);
+ slk[2].start_col = (col += label_length);
+
+ center = COLS / 2;
+
+ slk[3].start_col = center - label_length + 1;
+ slk[4].start_col = center + 1;
+
+ col = COLS - (label_length * 3) + 1;
+
+ slk[5].start_col = col;
+ slk[6].start_col = (col += label_length);
+ slk[7].start_col = (col += label_length);
+ break;
+
+ case 1: /* 4 - 4 F-Key layout */
+
+ for (i = 0; i < 8; i++)
+ {
+ slk[i].start_col = col;
+ col += label_length;
+
+ if (i == 3)
+ col = COLS - (label_length * 4) + 1;
+ }
+
+ break;
+
+ case 2: /* 4 4 4 F-Key layout */
+ case 3: /* 4 4 4 F-Key layout with index */
+
+ for (i = 0; i < 4; i++)
+ {
+ slk[i].start_col = col;
+ col += label_length;
+ }
+
+ center = COLS/2;
+
+ slk[4].start_col = center - (label_length * 2) + 1;
+ slk[5].start_col = center - label_length - 1;
+ slk[6].start_col = center + 1;
+ slk[7].start_col = center + label_length + 1;
+
+ col = COLS - (label_length * 4) + 1;
+
+ for (i = 8; i < 12; i++)
+ {
+ slk[i].start_col = col;
+ col += label_length;
+ }
+
+ break;
+
+ default: /* 5 - 5 F-Key layout */
+
+ for (i = 0; i < 10; i++)
+ {
+ slk[i].start_col = col;
+ col += label_length;
+
+ if (i == 4)
+ col = COLS - (label_length * 5) + 1;
+ }
+ }
+
+ --label_length;
+
+ /* make sure labels are all in window */
+
+ _redraw();
+}
+
+void PDC_slk_initialize(void)
+{
+ if (slk)
+ {
+ if (label_fmt == 3)
+ {
+ SP->slklines = 2;
+ label_line = 1;
+ }
+ else
+ SP->slklines = 1;
+
+ if (!SP->slk_winptr)
+ {
+ if ( !(SP->slk_winptr = newwin(SP->slklines, COLS,
+ LINES - SP->slklines, 0)) )
+ return;
+
+ wattrset(SP->slk_winptr, A_REVERSE);
+ }
+
+ _slk_calc();
+
+ /* if we have an index line, display it now */
+
+ if (label_fmt == 3)
+ {
+ chtype save_attr;
+ int i;
+
+ save_attr = SP->slk_winptr->_attrs;
+ wattrset(SP->slk_winptr, A_NORMAL);
+ wmove(SP->slk_winptr, 0, 0);
+ whline(SP->slk_winptr, 0, COLS);
+
+ for (i = 0; i < labels; i++)
+ mvwprintw(SP->slk_winptr, 0, slk[i].start_col, "F%d", i + 1);
+
+ SP->slk_winptr->_attrs = save_attr;
+ }
+
+ touchwin(SP->slk_winptr);
+ }
+}
+
+void PDC_slk_free(void)
+{
+ if (slk)
+ {
+ if (SP->slk_winptr)
+ {
+ delwin(SP->slk_winptr);
+ SP->slk_winptr = (WINDOW *)NULL;
+ }
+
+ free(slk);
+ slk = (struct SLK *)NULL;
+
+ label_length = 0;
+ labels = 0;
+ label_fmt = 0;
+ label_line = 0;
+ hidden = FALSE;
+ }
+}
+
+int PDC_mouse_in_slk(int y, int x)
+{
+ int i;
+
+ PDC_LOG(("PDC_mouse_in_slk() - called: y->%d x->%d\n", y, x));
+
+ /* If the line on which the mouse was clicked is NOT the last line
+ of the screen, we are not interested in it. */
+
+ if (!slk || !SP->slk_winptr || (y != SP->slk_winptr->_begy + label_line))
+ return 0;
+
+ for (i = 0; i < labels; i++)
+ if (x >= slk[i].start_col && x < (slk[i].start_col + label_length))
+ return i + 1;
+
+ return 0;
+}
+
+#ifdef PDC_WIDE
+int slk_wset(int labnum, const wchar_t *label, int justify)
+{
+ PDC_LOG(("slk_wset() - called\n"));
+
+ if (labnum < 1 || labnum > labels || justify < 0 || justify > 2)
+ return ERR;
+
+ labnum--;
+
+ if (!label || !(*label))
+ {
+ /* Clear the label */
+
+ *slk[labnum].label = 0;
+ slk[labnum].format = 0;
+ slk[labnum].len = 0;
+ }
+ else
+ {
+ int i, j = 0;
+
+ /* Skip leading spaces */
+
+ while (label[j] == L' ')
+ j++;
+
+ /* Copy it */
+
+ for (i = 0; i < label_length; i++)
+ {
+ chtype ch = label[i + j];
+
+ slk[labnum].label[i] = ch;
+
+ if (!ch)
+ break;
+ }
+
+ /* Drop trailing spaces */
+
+ while ((i + j) && (label[i + j - 1] == L' '))
+ i--;
+
+ slk[labnum].label[i] = 0;
+ slk[labnum].format = justify;
+ slk[labnum].len = i;
+ }
+
+ _drawone(labnum);
+
+ return OK;
+}
+
+wchar_t *slk_wlabel(int labnum)
+{
+ static wchar_t temp[33];
+ chtype *p;
+ int i;
+
+ PDC_LOG(("slk_wlabel() - called\n"));
+
+ if (labnum < 1 || labnum > labels)
+ return (wchar_t *)0;
+
+ for (i = 0, p = slk[labnum - 1].label; *p; i++)
+ temp[i] = *p++;
+
+ temp[i] = '\0';
+
+ return temp;
+}
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/termattr.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/termattr.c
new file mode 100644
index 0000000000..06e9ee856e
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/termattr.c
@@ -0,0 +1,176 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: termattr.c,v 1.54 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: termattr
+
+ Synopsis:
+ int baudrate(void);
+ char erasechar(void);
+ bool has_ic(void);
+ bool has_il(void);
+ char killchar(void);
+ char *longname(void);
+ chtype termattrs(void);
+ attr_t term_attrs(void);
+ char *termname(void);
+
+ int erasewchar(wchar_t *ch);
+ int killwchar(wchar_t *ch);
+
+ char wordchar(void);
+
+ Description:
+ baudrate() is supposed to return the output speed of the
+ terminal. In PDCurses, it simply returns INT_MAX.
+
+ has_ic and has_il() return TRUE. These functions have meaning in
+ some other implementations of curses.
+
+ erasechar() and killchar() return ^H and ^U, respectively -- the
+ ERASE and KILL characters. In other curses implementations,
+ these may vary by terminal type. erasewchar() and killwchar()
+ are the wide-character versions; they take a pointer to a
+ location in which to store the character, and return OK or ERR.
+
+ longname() returns a pointer to a static area containing a
+ verbose description of the current terminal. The maximum length
+ of the string is 128 characters. It is defined only after the
+ call to initscr() or newterm().
+
+ termname() returns a pointer to a static area containing a
+ short description of the current terminal (14 characters).
+
+ termattrs() returns a logical OR of all video attributes
+ supported by the terminal.
+
+ wordchar() is a PDCurses extension of the concept behind the
+ functions erasechar() and killchar(), returning the "delete
+ word" character, ^W.
+
+ Portability X/Open BSD SYS V
+ baudrate Y Y Y
+ erasechar Y Y Y
+ has_ic Y Y Y
+ has_il Y Y Y
+ killchar Y Y Y
+ longname Y Y Y
+ termattrs Y Y Y
+ termname Y Y Y
+ erasewchar Y
+ killwchar Y
+ term_attrs Y
+ wordchar - - -
+
+**man-end****************************************************************/
+
+#include <string.h>
+#include <limits.h>
+
+int baudrate(void)
+{
+ PDC_LOG(("baudrate() - called\n"));
+
+ return INT_MAX;
+}
+
+char erasechar(void)
+{
+ PDC_LOG(("erasechar() - called\n"));
+
+ return _ECHAR; /* character delete char (^H) */
+}
+
+bool has_ic(void)
+{
+ PDC_LOG(("has_ic() - called\n"));
+
+ return TRUE;
+}
+
+bool has_il(void)
+{
+ PDC_LOG(("has_il() - called\n"));
+
+ return TRUE;
+}
+
+char killchar(void)
+{
+ PDC_LOG(("killchar() - called\n"));
+
+ return _DLCHAR; /* line delete char (^U) */
+}
+
+char *longname(void)
+{
+ PDC_LOG(("longname() - called\n"));
+
+ return ttytype + 9; /* skip "pdcurses|" */
+}
+
+chtype termattrs(void)
+{
+ chtype temp = A_BLINK | A_BOLD | A_INVIS | A_REVERSE | A_UNDERLINE;
+
+ /* note: blink is bold background on some platforms */
+
+ PDC_LOG(("termattrs() - called\n"));
+
+ if (!SP->mono)
+ temp |= A_COLOR;
+
+ return temp;
+}
+
+attr_t term_attrs(void)
+{
+ PDC_LOG(("term_attrs() - called\n"));
+
+ return WA_BLINK | WA_BOLD | WA_INVIS | WA_LEFT | WA_REVERSE |
+ WA_RIGHT | WA_UNDERLINE;
+}
+
+char *termname(void)
+{
+ PDC_LOG(("termname() - called\n"));
+
+ return "pdcurses";
+}
+
+char wordchar(void)
+{
+ PDC_LOG(("wordchar() - called\n"));
+
+ return _DWCHAR; /* word delete char */
+}
+
+#ifdef PDC_WIDE
+int erasewchar(wchar_t *ch)
+{
+ PDC_LOG(("erasewchar() - called\n"));
+
+ if (!ch)
+ return ERR;
+
+ *ch = (wchar_t)_ECHAR;
+
+ return OK;
+}
+
+int killwchar(wchar_t *ch)
+{
+ PDC_LOG(("killwchar() - called\n"));
+
+ if (!ch)
+ return ERR;
+
+ *ch = (wchar_t)_DLCHAR;
+
+ return OK;
+}
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/terminfo.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/terminfo.c
new file mode 100644
index 0000000000..c099ada728
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/terminfo.c
@@ -0,0 +1,215 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: terminfo.c,v 1.37 2008/07/21 12:29:20 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: terminfo
+
+ Synopsis:
+ int mvcur(int oldrow, int oldcol, int newrow, int newcol);
+ int vidattr(chtype attr);
+ int vid_attr(attr_t attr, short color_pair, void *opt);
+ int vidputs(chtype attr, int (*putfunc)(int));
+ int vid_puts(attr_t attr, short color_pair, void *opt,
+ int (*putfunc)(int));
+
+ int del_curterm(TERMINAL *);
+ int putp(const char *);
+ int restartterm(const char *, int, int *);
+ TERMINAL *set_curterm(TERMINAL *);
+ int setterm(const char *term);
+ int setupterm(const char *, int, int *);
+ int tgetent(char *, const char *);
+ int tgetflag(const char *);
+ int tgetnum(const char *);
+ char *tgetstr(const char *, char **);
+ char *tgoto(const char *, int, int);
+ int tigetflag(const char *);
+ int tigetnum(const char *);
+ char *tigetstr(const char *);
+ char *tparm(const char *,long, long, long, long, long, long,
+ long, long, long);
+ int tputs(const char *, int, int (*)(int));
+
+ Description:
+ mvcur() lets you move the physical cursor without updating any
+ window cursor positions. It returns OK or ERR.
+
+ The rest of these functions are currently implemented as stubs,
+ returning the appropriate errors and doing nothing else.
+
+ Portability X/Open BSD SYS V
+ mvcur Y Y Y
+
+**man-end****************************************************************/
+
+#include <term.h>
+
+TERMINAL *cur_term = NULL;
+
+int mvcur(int oldrow, int oldcol, int newrow, int newcol)
+{
+ PDC_LOG(("mvcur() - called: oldrow %d oldcol %d newrow %d newcol %d\n",
+ oldrow, oldcol, newrow, newcol));
+
+ if ((newrow >= LINES) || (newcol >= COLS) || (newrow < 0) || (newcol < 0))
+ return ERR;
+
+ PDC_gotoyx(newrow, newcol);
+ SP->cursrow = newrow;
+ SP->curscol = newcol;
+
+ return OK;
+}
+
+int vidattr(chtype attr)
+{
+ PDC_LOG(("vidattr() - called: attr %d\n", attr));
+
+ return ERR;
+}
+
+int vid_attr(attr_t attr, short color_pair, void *opt)
+{
+ PDC_LOG(("vid_attr() - called\n"));
+
+ return ERR;
+}
+
+int vidputs(chtype attr, int (*putfunc)(int))
+{
+ PDC_LOG(("vidputs() - called: attr %d\n", attr));
+
+ return ERR;
+}
+
+int vid_puts(attr_t attr, short color_pair, void *opt, int (*putfunc)(int))
+{
+ PDC_LOG(("vid_puts() - called\n"));
+
+ return ERR;
+}
+
+int del_curterm(TERMINAL *oterm)
+{
+ PDC_LOG(("del_curterm() - called\n"));
+
+ return ERR;
+}
+
+int putp(const char *str)
+{
+ PDC_LOG(("putp() - called: str %s\n", str));
+
+ return ERR;
+}
+
+int restartterm(const char *term, int filedes, int *errret)
+{
+ PDC_LOG(("restartterm() - called\n"));
+
+ if (errret)
+ *errret = -1;
+
+ return ERR;
+}
+
+TERMINAL *set_curterm(TERMINAL *nterm)
+{
+ PDC_LOG(("set_curterm() - called\n"));
+
+ return (TERMINAL *)NULL;
+}
+
+int setterm(const char *term)
+{
+ PDC_LOG(("setterm() - called\n"));
+
+ return ERR;
+}
+
+int setupterm(const char *term, int filedes, int *errret)
+{
+ PDC_LOG(("setupterm() - called\n"));
+
+ if (errret)
+ *errret = -1;
+ else
+ fprintf(stderr, "There is no terminfo database\n");
+
+ return ERR;
+}
+
+int tgetent(char *bp, const char *name)
+{
+ PDC_LOG(("tgetent() - called: name %s\n", name));
+
+ return ERR;
+}
+
+int tgetflag(const char *id)
+{
+ PDC_LOG(("tgetflag() - called: id %s\n", id));
+
+ return ERR;
+}
+
+int tgetnum(const char *id)
+{
+ PDC_LOG(("tgetnum() - called: id %s\n", id));
+
+ return ERR;
+}
+
+char *tgetstr(const char *id, char **area)
+{
+ PDC_LOG(("tgetstr() - called: id %s\n", id));
+
+ return (char *)NULL;
+}
+
+char *tgoto(const char *cap, int col, int row)
+{
+ PDC_LOG(("tgoto() - called\n"));
+
+ return (char *)NULL;
+}
+
+int tigetflag(const char *capname)
+{
+ PDC_LOG(("tigetflag() - called: capname %s\n", capname));
+
+ return -1;
+}
+
+int tigetnum(const char *capname)
+{
+ PDC_LOG(("tigetnum() - called: capname %s\n", capname));
+
+ return -2;
+}
+
+char *tigetstr(const char *capname)
+{
+ PDC_LOG(("tigetstr() - called: capname %s\n", capname));
+
+ return (char *)(-1);
+}
+
+char *tparm(const char *cap, long p1, long p2, long p3, long p4,
+ long p5, long p6, long p7, long p8, long p9)
+{
+ PDC_LOG(("tparm() - called: cap %s\n", cap));
+
+ return (char *)NULL;
+}
+
+int tputs(const char *str, int affcnt, int (*putfunc)(int))
+{
+ PDC_LOG(("tputs() - called\n"));
+
+ return ERR;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/touch.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/touch.c
new file mode 100644
index 0000000000..9355aa1f40
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/touch.c
@@ -0,0 +1,160 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: touch.c,v 1.29 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: touch
+
+ Synopsis:
+ int touchwin(WINDOW *win);
+ int touchline(WINDOW *win, int start, int count);
+ int untouchwin(WINDOW *win);
+ int wtouchln(WINDOW *win, int y, int n, int changed);
+ bool is_linetouched(WINDOW *win, int line);
+ bool is_wintouched(WINDOW *win);
+
+ Description:
+ touchwin() and touchline() throw away all information about
+ which parts of the window have been touched, pretending that the
+ entire window has been drawn on. This is sometimes necessary
+ when using overlapping windows, since a change to one window
+ will affect the other window, but the records of which lines
+ have been changed in the other window will not reflect the
+ change.
+
+ untouchwin() marks all lines in the window as unchanged since
+ the last call to wrefresh().
+
+ wtouchln() makes n lines in the window, starting at line y, look
+ as if they have (changed == 1) or have not (changed == 0) been
+ changed since the last call to wrefresh().
+
+ is_linetouched() returns TRUE if the specified line in the
+ specified window has been changed since the last call to
+ wrefresh().
+
+ is_wintouched() returns TRUE if the specified window
+ has been changed since the last call to wrefresh().
+
+ Return Value:
+ All functions return OK on success and ERR on error except
+ is_wintouched() and is_linetouched().
+
+ Portability X/Open BSD SYS V
+ touchwin Y Y Y
+ touchline Y - 3.0
+ untouchwin Y - 4.0
+ wtouchln Y Y Y
+ is_linetouched Y - 4.0
+ is_wintouched Y - 4.0
+
+**man-end****************************************************************/
+
+int touchwin(WINDOW *win)
+{
+ int i;
+
+ PDC_LOG(("touchwin() - called: Win=%x\n", win));
+
+ if (!win)
+ return ERR;
+
+ for (i = 0; i < win->_maxy; i++)
+ {
+ win->_firstch[i] = 0;
+ win->_lastch[i] = win->_maxx - 1;
+ }
+
+ return OK;
+}
+
+int touchline(WINDOW *win, int start, int count)
+{
+ int i;
+
+ PDC_LOG(("touchline() - called: win=%p start %d count %d\n",
+ win, start, count));
+
+ if (!win || start > win->_maxy || start + count > win->_maxy)
+ return ERR;
+
+ for (i = start; i < start + count; i++)
+ {
+ win->_firstch[i] = 0;
+ win->_lastch[i] = win->_maxx - 1;
+ }
+
+ return OK;
+}
+
+int untouchwin(WINDOW *win)
+{
+ int i;
+
+ PDC_LOG(("untouchwin() - called: win=%p", win));
+
+ if (!win)
+ return ERR;
+
+ for (i = 0; i < win->_maxy; i++)
+ {
+ win->_firstch[i] = _NO_CHANGE;
+ win->_lastch[i] = _NO_CHANGE;
+ }
+
+ return OK;
+}
+
+int wtouchln(WINDOW *win, int y, int n, int changed)
+{
+ int i;
+
+ PDC_LOG(("wtouchln() - called: win=%p y=%d n=%d changed=%d\n",
+ win, y, n, changed));
+
+ if (!win || y > win->_maxy || y + n > win->_maxy)
+ return ERR;
+
+ for (i = y; i < y + n; i++)
+ {
+ if (changed)
+ {
+ win->_firstch[i] = 0;
+ win->_lastch[i] = win->_maxx - 1;
+ }
+ else
+ {
+ win->_firstch[i] = _NO_CHANGE;
+ win->_lastch[i] = _NO_CHANGE;
+ }
+ }
+
+ return OK;
+}
+
+bool is_linetouched(WINDOW *win, int line)
+{
+ PDC_LOG(("is_linetouched() - called: win=%p line=%d\n", win, line));
+
+ if (!win || line > win->_maxy || line < 0)
+ return FALSE;
+
+ return (win->_firstch[line] != _NO_CHANGE) ? TRUE : FALSE;
+}
+
+bool is_wintouched(WINDOW *win)
+{
+ int i;
+
+ PDC_LOG(("is_wintouched() - called: win=%p\n", win));
+
+ if (win)
+ for (i = 0; i < win->_maxy; i++)
+ if (win->_firstch[i] != _NO_CHANGE)
+ return TRUE;
+
+ return FALSE;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/util.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/util.c
new file mode 100644
index 0000000000..f0673fca4a
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/util.c
@@ -0,0 +1,309 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: util.c,v 1.71 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: util
+
+ Synopsis:
+ char *unctrl(chtype c);
+ void filter(void);
+ void use_env(bool x);
+ int delay_output(int ms);
+
+ int getcchar(const cchar_t *wcval, wchar_t *wch, attr_t *attrs,
+ short *color_pair, void *opts);
+ int setcchar(cchar_t *wcval, const wchar_t *wch, const attr_t attrs,
+ short color_pair, const void *opts);
+ wchar_t *wunctrl(cchar_t *wc);
+
+ int PDC_mbtowc(wchar_t *pwc, const char *s, size_t n);
+ size_t PDC_mbstowcs(wchar_t *dest, const char *src, size_t n);
+ size_t PDC_wcstombs(char *dest, const wchar_t *src, size_t n);
+
+ Description:
+ unctrl() expands the text portion of the chtype c into a
+ printable string. Control characters are changed to the "^X"
+ notation; others are passed through. wunctrl() is the wide-
+ character version of the function.
+
+ filter() and use_env() are no-ops in PDCurses.
+
+ delay_output() inserts an ms millisecond pause in output.
+
+ getcchar() works in two modes: When wch is not NULL, it reads
+ the cchar_t pointed to by wcval and stores the attributes in
+ attrs, the color pair in color_pair, and the text in the
+ wide-character string wch. When wch is NULL, getcchar() merely
+ returns the number of wide characters in wcval. In either mode,
+ the opts argument is unused.
+
+ setcchar constructs a cchar_t at wcval from the wide-character
+ text at wch, the attributes in attr and the color pair in
+ color_pair. The opts argument is unused.
+
+ Currently, the length returned by getcchar() is always 1 or 0.
+ Similarly, setcchar() will only take the first wide character
+ from wch, and ignore any others that it "should" take (i.e.,
+ combining characters). Nor will it correctly handle any
+ character outside the basic multilingual plane (UCS-2).
+
+ Return Value:
+ unctrl() and wunctrl() return NULL on failure. delay_output()
+ always returns OK.
+
+ getcchar() returns the number of wide characters wcval points to
+ when wch is NULL; when it's not, getcchar() returns OK or ERR.
+
+ setcchar() returns OK or ERR.
+
+ Portability X/Open BSD SYS V
+ unctrl Y Y Y
+ filter Y - 3.0
+ use_env Y - 4.0
+ delay_output Y Y Y
+ getcchar Y
+ setcchar Y
+ wunctrl Y
+ PDC_mbtowc - - -
+ PDC_mbstowcs - - -
+ PDC_wcstombs - - -
+
+**man-end****************************************************************/
+
+#ifdef PDC_WIDE
+# ifdef PDC_FORCE_UTF8
+# include <string.h>
+# else
+# include <stdlib.h>
+# endif
+#endif
+
+char *unctrl(chtype c)
+{
+ static char strbuf[3] = {0, 0, 0};
+
+ chtype ic;
+
+ PDC_LOG(("unctrl() - called\n"));
+
+ ic = c & A_CHARTEXT;
+
+ if (ic >= 0x20 && ic != 0x7f) /* normal characters */
+ {
+ strbuf[0] = (char)ic;
+ strbuf[1] = '\0';
+ return strbuf;
+ }
+
+ strbuf[0] = '^'; /* '^' prefix */
+
+ if (ic == 0x7f) /* 0x7f == DEL */
+ strbuf[1] = '?';
+ else /* other control */
+ strbuf[1] = (char)(ic + '@');
+
+ return strbuf;
+}
+
+void filter(void)
+{
+ PDC_LOG(("filter() - called\n"));
+}
+
+void use_env(bool x)
+{
+ PDC_LOG(("use_env() - called: x %d\n", x));
+}
+
+int delay_output(int ms)
+{
+ PDC_LOG(("delay_output() - called: ms %d\n", ms));
+
+ return napms(ms);
+}
+
+#ifdef PDC_WIDE
+int getcchar(const cchar_t *wcval, wchar_t *wch, attr_t *attrs,
+ short *color_pair, void *opts)
+{
+ if (!wcval)
+ return ERR;
+
+ if (wch)
+ {
+ if (!attrs || !color_pair)
+ return ERR;
+
+ *wch = (*wcval & A_CHARTEXT);
+ *attrs = (*wcval & (A_ATTRIBUTES & ~A_COLOR));
+ *color_pair = PAIR_NUMBER(*wcval & A_COLOR);
+
+ if (*wch)
+ *++wch = L'\0';
+
+ return OK;
+ }
+ else
+ return ((*wcval & A_CHARTEXT) != L'\0');
+}
+
+int setcchar(cchar_t *wcval, const wchar_t *wch, const attr_t attrs,
+ short color_pair, const void *opts)
+{
+ if (!wcval || !wch)
+ return ERR;
+
+ *wcval = *wch | attrs | COLOR_PAIR(color_pair);
+
+ return OK;
+}
+
+wchar_t *wunctrl(cchar_t *wc)
+{
+ static wchar_t strbuf[3] = {0, 0, 0};
+
+ cchar_t ic;
+
+ PDC_LOG(("wunctrl() - called\n"));
+
+ ic = *wc & A_CHARTEXT;
+
+ if (ic >= 0x20 && ic != 0x7f) /* normal characters */
+ {
+ strbuf[0] = (wchar_t)ic;
+ strbuf[1] = L'\0';
+ return strbuf;
+ }
+
+ strbuf[0] = '^'; /* '^' prefix */
+
+ if (ic == 0x7f) /* 0x7f == DEL */
+ strbuf[1] = '?';
+ else /* other control */
+ strbuf[1] = (wchar_t)(ic + '@');
+
+ return strbuf;
+}
+
+int PDC_mbtowc(wchar_t *pwc, const char *s, size_t n)
+{
+# ifdef PDC_FORCE_UTF8
+ wchar_t key;
+ int i = -1;
+ const unsigned char *string;
+
+ if (!s || (n < 1))
+ return -1;
+
+ if (!*s)
+ return 0;
+
+ string = (const unsigned char *)s;
+
+ key = string[0];
+
+ /* Simplistic UTF-8 decoder -- only does the BMP, minimal validation */
+
+ if (key & 0x80)
+ {
+ if ((key & 0xe0) == 0xc0)
+ {
+ if (1 < n)
+ {
+ key = ((key & 0x1f) << 6) | (string[1] & 0x3f);
+ i = 2;
+ }
+ }
+ else if ((key & 0xe0) == 0xe0)
+ {
+ if (2 < n)
+ {
+ key = ((key & 0x0f) << 12) | ((string[1] & 0x3f) << 6) |
+ (string[2] & 0x3f);
+ i = 3;
+ }
+ }
+ }
+ else
+ i = 1;
+
+ if (i)
+ *pwc = key;
+
+ return i;
+# else
+ return mbtowc(pwc, s, n);
+# endif
+}
+
+size_t PDC_mbstowcs(wchar_t *dest, const char *src, size_t n)
+{
+# ifdef PDC_FORCE_UTF8
+ size_t i = 0, len;
+
+ if (!src || !dest)
+ return 0;
+
+ len = strlen(src);
+
+ while (*src && i < n)
+ {
+ int retval = PDC_mbtowc(dest + i, src, len);
+
+ if (retval < 1)
+ return -1;
+
+ src += retval;
+ len -= retval;
+ i++;
+ }
+# else
+ size_t i = mbstowcs(dest, src, n);
+# endif
+ dest[i] = 0;
+ return i;
+}
+
+size_t PDC_wcstombs(char *dest, const wchar_t *src, size_t n)
+{
+# ifdef PDC_FORCE_UTF8
+ size_t i = 0;
+
+ if (!src || !dest)
+ return 0;
+
+ while (*src && i < n)
+ {
+ chtype code = *src++;
+
+ if (code < 0x80)
+ {
+ dest[i] = code;
+ i++;
+ }
+ else
+ if (code < 0x800)
+ {
+ dest[i] = ((code & 0x07c0) >> 6) | 0xc0;
+ dest[i + 1] = (code & 0x003f) | 0x80;
+ i += 2;
+ }
+ else
+ {
+ dest[i] = ((code & 0xf000) >> 12) | 0xe0;
+ dest[i + 1] = ((code & 0x0fc0) >> 6) | 0x80;
+ dest[i + 2] = (code & 0x003f) | 0x80;
+ i += 3;
+ }
+ }
+# else
+ size_t i = wcstombs(dest, src, n);
+# endif
+ dest[i] = '\0';
+ return i;
+}
+#endif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/window.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/window.c
new file mode 100644
index 0000000000..dbfd58494c
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/window.c
@@ -0,0 +1,562 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: window.c,v 1.62 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: window
+
+ Synopsis:
+ WINDOW *newwin(int nlines, int ncols, int begy, int begx);
+ WINDOW *derwin(WINDOW* orig, int nlines, int ncols,
+ int begy, int begx);
+ WINDOW *subwin(WINDOW* orig, int nlines, int ncols,
+ int begy, int begx);
+ WINDOW *dupwin(WINDOW *win);
+ int delwin(WINDOW *win);
+ int mvwin(WINDOW *win, int y, int x);
+ int mvderwin(WINDOW *win, int pary, int parx);
+ int syncok(WINDOW *win, bool bf);
+ void wsyncup(WINDOW *win);
+ void wcursyncup(WINDOW *win);
+ void wsyncdown(WINDOW *win);
+
+ WINDOW *resize_window(WINDOW *win, int nlines, int ncols);
+ int wresize(WINDOW *win, int nlines, int ncols);
+ WINDOW *PDC_makelines(WINDOW *win);
+ WINDOW *PDC_makenew(int nlines, int ncols, int begy, int begx);
+ void PDC_sync(WINDOW *win);
+
+ Description:
+ newwin() creates a new window with the given number of lines,
+ nlines and columns, ncols. The upper left corner of the window
+ is at line begy, column begx. If nlines is zero, it defaults to
+ LINES - begy; ncols to COLS - begx. Create a new full-screen
+ window by calling newwin(0, 0, 0, 0).
+
+ delwin() deletes the named window, freeing all associated
+ memory. In the case of overlapping windows, subwindows should be
+ deleted before the main window.
+
+ mvwin() moves the window so that the upper left-hand corner is
+ at position (y,x). If the move would cause the window to be off
+ the screen, it is an error and the window is not moved. Moving
+ subwindows is allowed.
+
+ subwin() creates a new subwindow within a window. The
+ dimensions of the subwindow are nlines lines and ncols columns.
+ The subwindow is at position (begy, begx) on the screen. This
+ position is relative to the screen, and not to the window orig.
+ Changes made to either window will affect both. When using this
+ routine, you will often need to call touchwin() before calling
+ wrefresh().
+
+ derwin() is the same as subwin(), except that begy and begx are
+ relative to the origin of the window orig rather than the
+ screen. There is no difference between subwindows and derived
+ windows.
+
+ mvderwin() moves a derived window (or subwindow) inside its
+ parent window. The screen-relative parameters of the window are
+ not changed. This routine is used to display different parts of
+ the parent window at the same physical position on the screen.
+
+ dupwin() creates an exact duplicate of the window win.
+
+ wsyncup() causes a touchwin() of all of the window's parents.
+
+ If wsyncok() is called with a second argument of TRUE, this
+ causes a wsyncup() to be called every time the window is
+ changed.
+
+ wcursyncup() causes the current cursor position of all of a
+ window's ancestors to reflect the current cursor position of the
+ current window.
+
+ wsyncdown() causes a touchwin() of the current window if any of
+ its parent's windows have been touched.
+
+ resize_window() allows the user to resize an existing window. It
+ returns the pointer to the new window, or NULL on failure.
+
+ wresize() is an ncurses-compatible wrapper for resize_window().
+ Note that, unlike ncurses, it will NOT process any subwindows of
+ the window. (However, you still can call it _on_ subwindows.) It
+ returns OK or ERR.
+
+ PDC_makenew() allocates all data for a new WINDOW * except the
+ actual lines themselves. If it's unable to allocate memory for
+ the window structure, it will free all allocated memory and
+ return a NULL pointer.
+
+ PDC_makelines() allocates the memory for the lines.
+
+ PDC_sync() handles wrefresh() and wsyncup() calls when a window
+ is changed.
+
+ Return Value:
+ newwin(), subwin(), derwin() and dupwin() return a pointer
+ to the new window, or NULL on failure. delwin(), mvwin(),
+ mvderwin() and syncok() return OK or ERR. wsyncup(),
+ wcursyncup() and wsyncdown() return nothing.
+
+ Errors:
+ It is an error to call resize_window() before calling initscr().
+ Also, an error will be generated if we fail to create a newly
+ sized replacement window for curscr, or stdscr. This could
+ happen when increasing the window size. NOTE: If this happens,
+ the previously successfully allocated windows are left alone;
+ i.e., the resize is NOT cancelled for those windows.
+
+ Portability X/Open BSD SYS V
+ newwin Y Y Y
+ delwin Y Y Y
+ mvwin Y Y Y
+ subwin Y Y Y
+ derwin Y - Y
+ mvderwin Y - Y
+ dupwin Y - 4.0
+ wsyncup Y - 4.0
+ syncok Y - 4.0
+ wcursyncup Y - 4.0
+ wsyncdown Y - 4.0
+ resize_window - - -
+ wresize - - -
+ PDC_makelines - - -
+ PDC_makenew - - -
+ PDC_sync - - -
+
+**man-end****************************************************************/
+
+#include <stdlib.h>
+
+WINDOW *PDC_makenew(int nlines, int ncols, int begy, int begx)
+{
+ WINDOW *win;
+
+ PDC_LOG(("PDC_makenew() - called: lines %d cols %d begy %d begx %d\n",
+ nlines, ncols, begy, begx));
+
+ /* allocate the window structure itself */
+
+ if ((win = calloc(1, sizeof(WINDOW))) == (WINDOW *)NULL)
+ return win;
+
+ /* allocate the line pointer array */
+
+ if ((win->_y = malloc(nlines * sizeof(chtype *))) == NULL)
+ {
+ free(win);
+ return (WINDOW *)NULL;
+ }
+
+ /* allocate the minchng and maxchng arrays */
+
+ if ((win->_firstch = malloc(nlines * sizeof(int))) == NULL)
+ {
+ free(win->_y);
+ free(win);
+ return (WINDOW *)NULL;
+ }
+
+ if ((win->_lastch = malloc(nlines * sizeof(int))) == NULL)
+ {
+ free(win->_firstch);
+ free(win->_y);
+ free(win);
+ return (WINDOW *)NULL;
+ }
+
+ /* initialize window variables */
+
+ win->_maxy = nlines; /* real max screen size */
+ win->_maxx = ncols; /* real max screen size */
+ win->_begy = begy;
+ win->_begx = begx;
+ win->_bkgd = ' '; /* wrs 4/10/93 -- initialize background to blank */
+ win->_clear = (bool) ((nlines == LINES) && (ncols == COLS));
+ win->_bmarg = nlines - 1;
+ win->_parx = win->_pary = -1;
+
+ /* init to say window all changed */
+
+ touchwin(win);
+
+ return win;
+}
+
+WINDOW *PDC_makelines(WINDOW *win)
+{
+ int i, j, nlines, ncols;
+
+ PDC_LOG(("PDC_makelines() - called: lines %d cols %d\n", nlines, ncols));
+
+ if (!win)
+ return (WINDOW *)NULL;
+
+ nlines = win->_maxy;
+ ncols = win->_maxx;
+
+ for (i = 0; i < nlines; i++)
+ {
+ if ((win->_y[i] = malloc(ncols * sizeof(chtype))) == NULL)
+ {
+ /* if error, free all the data */
+
+ for (j = 0; j < i; j++)
+ free(win->_y[j]);
+
+ free(win->_firstch);
+ free(win->_lastch);
+ free(win->_y);
+ free(win);
+
+ return (WINDOW *)NULL;
+ }
+ }
+
+ return win;
+}
+
+void PDC_sync(WINDOW *win)
+{
+ PDC_LOG(("PDC_sync() - called:\n"));
+
+ if (win->_immed)
+ wrefresh(win);
+ if (win->_sync)
+ wsyncup(win);
+}
+
+WINDOW *newwin(int nlines, int ncols, int begy, int begx)
+{
+ WINDOW *win;
+
+ PDC_LOG(("newwin() - called:lines=%d cols=%d begy=%d begx=%d\n",
+ nlines, ncols, begy, begx));
+
+ if (!nlines)
+ nlines = LINES - begy;
+ if (!ncols)
+ ncols = COLS - begx;
+
+ if ( (begy + nlines > SP->lines || begx + ncols > SP->cols)
+ || !(win = PDC_makenew(nlines, ncols, begy, begx))
+ || !(win = PDC_makelines(win)) )
+ return (WINDOW *)NULL;
+
+ werase(win);
+
+ return win;
+}
+
+int delwin(WINDOW *win)
+{
+ int i;
+
+ PDC_LOG(("delwin() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ /* subwindows use parents' lines */
+
+ if (!(win->_flags & (_SUBWIN|_SUBPAD)))
+ for (i = 0; i < win->_maxy && win->_y[i]; i++)
+ if (win->_y[i])
+ free(win->_y[i]);
+
+ free(win->_firstch);
+ free(win->_lastch);
+ free(win->_y);
+ free(win);
+
+ return OK;
+}
+
+int mvwin(WINDOW *win, int y, int x)
+{
+ PDC_LOG(("mvwin() - called\n"));
+
+ if (!win || (y + win->_maxy > LINES || y < 0)
+ || (x + win->_maxx > COLS || x < 0))
+ return ERR;
+
+ win->_begy = y;
+ win->_begx = x;
+ touchwin(win);
+
+ return OK;
+}
+
+WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begy, int begx)
+{
+ WINDOW *win;
+ int i;
+ int j = begy - orig->_begy;
+ int k = begx - orig->_begx;
+
+ PDC_LOG(("subwin() - called: lines %d cols %d begy %d begx %d\n",
+ nlines, ncols, begy, begx));
+
+ /* make sure window fits inside the original one */
+
+ if (!orig || (begy < orig->_begy) || (begx < orig->_begx) ||
+ (begy + nlines) > (orig->_begy + orig->_maxy) ||
+ (begx + ncols) > (orig->_begx + orig->_maxx))
+ return (WINDOW *)NULL;
+
+ if (!nlines)
+ nlines = orig->_maxy - 1 - j;
+ if (!ncols)
+ ncols = orig->_maxx - 1 - k;
+
+ if ( !(win = PDC_makenew(nlines, ncols, begy, begx)) )
+ return (WINDOW *)NULL;
+
+ /* initialize window variables */
+
+ win->_attrs = orig->_attrs;
+ win->_bkgd = orig->_bkgd;
+ win->_leaveit = orig->_leaveit;
+ win->_scroll = orig->_scroll;
+ win->_nodelay = orig->_nodelay;
+ win->_use_keypad = orig->_use_keypad;
+ win->_immed = orig->_immed;
+ win->_sync = orig->_sync;
+ win->_pary = j;
+ win->_parx = k;
+ win->_parent = orig;
+
+ for (i = 0; i < nlines; i++, j++)
+ win->_y[i] = orig->_y[j] + k;
+
+ win->_flags |= _SUBWIN;
+
+ return win;
+}
+
+WINDOW *derwin(WINDOW *orig, int nlines, int ncols, int begy, int begx)
+{
+ return subwin(orig, nlines, ncols, begy + orig->_begy, begx + orig->_begx);
+}
+
+int mvderwin(WINDOW *win, int pary, int parx)
+{
+ int i, j;
+ WINDOW *mypar;
+
+ if (!win || !(win->_parent))
+ return ERR;
+
+ mypar = win->_parent;
+
+ if (pary < 0 || parx < 0 || (pary + win->_maxy) > mypar->_maxy ||
+ (parx + win->_maxx) > mypar->_maxx)
+ return ERR;
+
+ j = pary;
+
+ for (i = 0; i < win->_maxy; i++)
+ win->_y[i] = (mypar->_y[j++]) + parx;
+
+ win->_pary = pary;
+ win->_parx = parx;
+
+ return OK;
+}
+
+WINDOW *dupwin(WINDOW *win)
+{
+ WINDOW *new;
+ chtype *ptr, *ptr1;
+ int nlines, ncols, begy, begx, i;
+
+ if (!win)
+ return (WINDOW *)NULL;
+
+ nlines = win->_maxy;
+ ncols = win->_maxx;
+ begy = win->_begy;
+ begx = win->_begx;
+
+ if ( !(new = PDC_makenew(nlines, ncols, begy, begx))
+ || !(new = PDC_makelines(new)) )
+ return (WINDOW *)NULL;
+
+ /* copy the contents of win into new */
+
+ for (i = 0; i < nlines; i++)
+ {
+ for (ptr = new->_y[i], ptr1 = win->_y[i];
+ ptr < new->_y[i] + ncols; ptr++, ptr1++)
+ *ptr = *ptr1;
+
+ new->_firstch[i] = 0;
+ new->_lastch[i] = ncols - 1;
+ }
+
+ new->_curx = win->_curx;
+ new->_cury = win->_cury;
+ new->_maxy = win->_maxy;
+ new->_maxx = win->_maxx;
+ new->_begy = win->_begy;
+ new->_begx = win->_begx;
+ new->_flags = win->_flags;
+ new->_attrs = win->_attrs;
+ new->_clear = win->_clear;
+ new->_leaveit = win->_leaveit;
+ new->_scroll = win->_scroll;
+ new->_nodelay = win->_nodelay;
+ new->_use_keypad = win->_use_keypad;
+ new->_tmarg = win->_tmarg;
+ new->_bmarg = win->_bmarg;
+ new->_parx = win->_parx;
+ new->_pary = win->_pary;
+ new->_parent = win->_parent;
+ new->_bkgd = win->_bkgd;
+ new->_flags = win->_flags;
+
+ return new;
+}
+
+WINDOW *resize_window(WINDOW *win, int nlines, int ncols)
+{
+ WINDOW *new;
+ int i, save_cury, save_curx, new_begy, new_begx;
+
+ PDC_LOG(("resize_window() - called: nlines %d ncols %d\n",
+ nlines, ncols));
+
+ if (!win)
+ return (WINDOW *)NULL;
+
+ if (win->_flags & _SUBPAD)
+ {
+ if ( !(new = subpad(win->_parent, nlines, ncols,
+ win->_begy, win->_begx)) )
+ return (WINDOW *)NULL;
+ }
+ else if (win->_flags & _SUBWIN)
+ {
+ if ( !(new = subwin(win->_parent, nlines, ncols,
+ win->_begy, win->_begx)) )
+ return (WINDOW *)NULL;
+ }
+ else
+ {
+ if (win == SP->slk_winptr)
+ {
+ new_begy = SP->lines - SP->slklines;
+ new_begx = 0;
+ }
+ else
+ {
+ new_begy = win->_begy;
+ new_begx = win->_begx;
+ }
+
+ if ( !(new = PDC_makenew(nlines, ncols, new_begy, new_begx)) )
+ return (WINDOW *)NULL;
+ }
+
+ save_curx = min(win->_curx, new->_maxx);
+ save_cury = min(win->_cury, new->_maxy);
+
+ if (!(win->_flags & (_SUBPAD|_SUBWIN)))
+ {
+ if ( !(new = PDC_makelines(new)) )
+ return (WINDOW *)NULL;
+
+ werase(new);
+
+ copywin(win, new, 0, 0, 0, 0, min(win->_maxy, new->_maxy) - 1,
+ min(win->_maxx, new->_maxx) - 1, FALSE);
+
+ for (i = 0; i < win->_maxy && win->_y[i]; i++)
+ if (win->_y[i])
+ free(win->_y[i]);
+ }
+
+ new->_flags = win->_flags;
+ new->_attrs = win->_attrs;
+ new->_clear = win->_clear;
+ new->_leaveit = win->_leaveit;
+ new->_scroll = win->_scroll;
+ new->_nodelay = win->_nodelay;
+ new->_use_keypad = win->_use_keypad;
+ new->_tmarg = (win->_tmarg > new->_maxy - 1) ? 0 : win->_tmarg;
+ new->_bmarg = (win->_bmarg == win->_maxy - 1) ?
+ new->_maxy - 1 : min(win->_bmarg, (new->_maxy - 1));
+ new->_parent = win->_parent;
+ new->_immed = win->_immed;
+ new->_sync = win->_sync;
+ new->_bkgd = win->_bkgd;
+
+ new->_curx = save_curx;
+ new->_cury = save_cury;
+
+ free(win->_firstch);
+ free(win->_lastch);
+ free(win->_y);
+
+ *win = *new;
+ free(new);
+
+ return win;
+}
+
+int wresize(WINDOW *win, int nlines, int ncols)
+{
+ return (resize_window(win, nlines, ncols) ? OK : ERR);
+}
+
+void wsyncup(WINDOW *win)
+{
+ WINDOW *tmp;
+
+ PDC_LOG(("wsyncup() - called\n"));
+
+ for (tmp = win; tmp; tmp = tmp->_parent)
+ touchwin(tmp);
+}
+
+int syncok(WINDOW *win, bool bf)
+{
+ PDC_LOG(("syncok() - called\n"));
+
+ if (!win)
+ return ERR;
+
+ win->_sync = bf;
+
+ return OK;
+}
+
+void wcursyncup(WINDOW *win)
+{
+ WINDOW *tmp;
+
+ PDC_LOG(("wcursyncup() - called\n"));
+
+ for (tmp = win; tmp && tmp->_parent; tmp = tmp->_parent)
+ wmove(tmp->_parent, tmp->_pary + tmp->_cury, tmp->_parx + tmp->_curx);
+}
+
+void wsyncdown(WINDOW *win)
+{
+ WINDOW *tmp;
+
+ PDC_LOG(("wsyncdown() - called\n"));
+
+ for (tmp = win; tmp; tmp = tmp->_parent)
+ {
+ if (is_wintouched(tmp))
+ {
+ touchwin(win);
+ break;
+ }
+ }
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/sdl1/Makefile b/payloads/libpayload/curses/PDCurses-3.4/sdl1/Makefile
new file mode 100644
index 0000000000..a8393f0b90
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/sdl1/Makefile
@@ -0,0 +1,101 @@
+# Makefile for PDCurses library for SDL
+
+O = o
+
+ifndef PDCURSES_SRCDIR
+ PDCURSES_SRCDIR = ..
+endif
+
+include $(PDCURSES_SRCDIR)/libobjs.mif
+
+osdir = $(PDCURSES_SRCDIR)/sdl1
+
+PDCURSES_SDL_H = $(osdir)/pdcsdl.h
+
+SFLAGS = $(shell sdl-config --cflags)
+SLIBS = $(shell sdl-config --libs)
+
+# If your system doesn't have these, remove the defines here
+SFLAGS += -DHAVE_VSNPRINTF -DHAVE_VSSCANF
+
+ifeq ($(DEBUG),Y)
+ CFLAGS = -g -Wall -DPDCDEBUG
+else
+ CFLAGS = -O2 -Wall
+endif
+
+BUILD = $(CC) $(CFLAGS) -I$(PDCURSES_SRCDIR)
+
+ifeq ($(shell uname),Darwin)
+ DEMOFLAGS = -Dmain=SDL_main
+endif
+
+LINK = $(CC)
+LDFLAGS = $(LIBCURSES) $(SLIBS)
+RANLIB = ranlib
+LIBCURSES = libpdcurses.a
+
+DEMOS = firework newdemo ptest rain testcurs tuidemo worm xmas \
+sdltest
+
+.PHONY: all libs clean demos
+
+all: libs demos
+
+libs: $(LIBCURSES)
+
+clean:
+ -rm -rf *.o trace $(LIBCURSES) $(DEMOS)
+
+demos: $(DEMOS)
+ strip $(DEMOS)
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ ar rv $@ $?
+ -$(RANLIB) $@
+
+$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
+$(PDCOBJS) : $(PDCURSES_SDL_H)
+$(DEMOS) : $(PDCURSES_CURSES_H) $(LIBCURSES)
+tui.o tuidemo.o : $(PDCURSES_CURSES_H)
+terminfo.o: $(TERM_HEADER)
+panel.o ptest: $(PANEL_HEADER)
+
+$(LIBOBJS) : %.o: $(srcdir)/%.c
+ $(BUILD) $(SFLAGS) -c $<
+
+$(PDCOBJS) : %.o: $(osdir)/%.c
+ $(BUILD) $(SFLAGS) -c $<
+
+firework: $(demodir)/firework.c
+ $(BUILD) $(DEMOFLAGS) -o $@ $< $(LDFLAGS)
+
+newdemo: $(demodir)/newdemo.c
+ $(BUILD) $(DEMOFLAGS) -o $@ $< $(LDFLAGS)
+
+ptest: $(demodir)/ptest.c
+ $(BUILD) $(DEMOFLAGS) -o $@ $< $(LDFLAGS)
+
+rain: $(demodir)/rain.c
+ $(BUILD) $(DEMOFLAGS) -o $@ $< $(LDFLAGS)
+
+testcurs: $(demodir)/testcurs.c
+ $(BUILD) $(DEMOFLAGS) -o $@ $< $(LDFLAGS)
+
+tuidemo: tuidemo.o tui.o
+ $(LINK) tui.o tuidemo.o -o $@ $(LDFLAGS)
+
+worm: $(demodir)/worm.c
+ $(BUILD) $(DEMOFLAGS) -o $@ $< $(LDFLAGS)
+
+xmas: $(demodir)/xmas.c
+ $(BUILD) $(DEMOFLAGS) -o $@ $< $(LDFLAGS)
+
+sdltest: $(osdir)/sdltest.c
+ $(BUILD) $(DEMOFLAGS) -o $@ $< $(LDFLAGS)
+
+tui.o: $(demodir)/tui.c $(demodir)/tui.h
+ $(BUILD) -c $(DEMOFLAGS) $(demodir)/tui.c
+
+tuidemo.o: $(demodir)/tuidemo.c
+ $(BUILD) -c $(DEMOFLAGS) $(demodir)/tuidemo.c
diff --git a/payloads/libpayload/curses/PDCurses-3.4/sdl1/Makefile.mng b/payloads/libpayload/curses/PDCurses-3.4/sdl1/Makefile.mng
new file mode 100644
index 0000000000..427edc670b
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/sdl1/Makefile.mng
@@ -0,0 +1,105 @@
+# Makefile for PDCurses library for SDL
+
+O = o
+
+ifndef PDCURSES_SRCDIR
+ PDCURSES_SRCDIR = ..
+endif
+
+include $(PDCURSES_SRCDIR)/libobjs.mif
+
+osdir = $(PDCURSES_SRCDIR)/sdl1
+
+PDCURSES_SDL_H = $(osdir)/pdcsdl.h
+
+ifeq ($(DEBUG),Y)
+ CFLAGS = -g -Wall -DPDCDEBUG
+else
+ CFLAGS = -O2 -Wall
+endif
+
+CC = gcc
+BUILD = $(CC) $(CFLAGS) -I$(PDCURSES_SRCDIR)
+LDFLAGS = -mwindows $(LIBCURSES)
+
+BASEDEF = $(PDCURSES_SRCDIR)\exp-base.def
+
+DEFDEPS = $(BASEDEF)
+
+DEFFILE = pdcurses.def
+
+ifeq ($(DLL),Y)
+ BUILD += -DPDC_DLL_BUILD
+ LIBEXE = gcc $(DEFFILE)
+ LIBFLAGS = -Wl,--out-implib,libpdcurses.a -shared -o
+ LIBCURSES = pdcurses.dll
+ CLEAN = $(LIBCURSES) *.a $(DEFFILE)
+ POST = -lSDL
+else
+ LIBEXE = ar
+ LIBFLAGS = rcv
+ LIBCURSES = libpdcurses.a
+ CLEAN = *.a
+ LDFLAGS += -lSDL
+endif
+
+DEMOS += sdltest.exe
+
+.PHONY: all libs clean demos
+
+all: libs demos
+
+libs: $(LIBCURSES)
+
+clean:
+ -del *.o $(CLEAN) *.exe
+
+demos: $(DEMOS)
+ strip *.exe
+
+pdcurses.dll: $(DEFFILE)
+
+$(DEFFILE): $(DEFDEPS)
+ echo LIBRARY pdcurses > $@
+ echo EXPORTS >> $@
+ type $(BASEDEF) >> $@
+ echo pdc_screen >> $@
+ echo pdc_font >> $@
+ echo pdc_icon >> $@
+ echo pdc_back >> $@
+ echo pdc_sheight >> $@
+ echo pdc_swidth >> $@
+ echo pdc_yoffset >> $@
+ echo pdc_xoffset >> $@
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ $(LIBEXE) $(LIBFLAGS) $@ $? $(POST)
+
+$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
+$(PDCOBJS) : $(PDCURSES_SDL_H)
+$(DEMOS) : $(PDCURSES_CURSES_H) $(LIBCURSES)
+tui.o tuidemo.o : $(PDCURSES_CURSES_H)
+terminfo.o: $(TERM_HEADER)
+panel.o ptest.exe: $(PANEL_HEADER)
+
+$(LIBOBJS) : %.o: $(srcdir)/%.c
+ $(BUILD) -c $<
+
+$(PDCOBJS) : %.o: $(osdir)/%.c
+ $(BUILD) -c $<
+
+firework.exe newdemo.exe rain.exe testcurs.exe worm.exe xmas.exe \
+ptest.exe: %.exe: $(demodir)/%.c
+ $(BUILD) -o $@ $< $(LDFLAGS)
+
+tuidemo.exe: tuidemo.o tui.o
+ $(CC) -o $@ tuidemo.o tui.o $(LDFLAGS)
+
+tui.o: $(demodir)/tui.c $(demodir)/tui.h
+ $(BUILD) -c $<
+
+tuidemo.o: $(demodir)/tuidemo.c $(demodir)/tui.h
+ $(BUILD) -c $<
+
+sdltest.exe: $(osdir)/sdltest.c
+ $(BUILD) -o $@ $< -mwindows $(LIBCURSES) -lmingw32 -lSDLmain -lSDL
diff --git a/payloads/libpayload/curses/PDCurses-3.4/sdl1/README b/payloads/libpayload/curses/PDCurses-3.4/sdl1/README
new file mode 100644
index 0000000000..35234d397d
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/sdl1/README
@@ -0,0 +1,33 @@
+PDCurses for SDL
+================
+
+This is a port of PDCurses for SDL.
+
+
+Building
+--------
+
+. On *nix (including Linux and Mac OS X), run "make" in the sdl1
+ directory. There is no configure script (yet?) for this port. This
+ assumes a working sdl-config, and GNU make. It builds the library
+ libpdcurses.a (dynamic lib not implemented).
+
+ With MinGW, run "make -f Makefile.mng". This assumes SDL is installed
+ in the standard directories. The MinGW makefile accepts the optional
+ parameters "DLL=Y" and "DEBUG=Y", as with the console version. (Wide-
+ character support is not yet implemented for SDL.) Both makefiles
+ recognize the optional PDCURSES_SRCDIR environment variable, as with
+ the console ports. Makefile.mng builds libpdcurses.a, along with
+ pdcurses.dll, if specified.
+
+
+Distribution Status
+-------------------
+
+The files in this directory are released to the Public Domain.
+
+
+Acknowledgements
+----------------
+
+SDL port was provided by William McBrine <wmcbrine@users.sf.net>
diff --git a/payloads/libpayload/curses/PDCurses-3.4/sdl1/deffont.h b/payloads/libpayload/curses/PDCurses-3.4/sdl1/deffont.h
new file mode 100644
index 0000000000..cf9cab193a
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/sdl1/deffont.h
@@ -0,0 +1,385 @@
+/* Default font -- this is simply a 256x128x1 BMP, in #include'able form.
+ The font is 8x16, code page 437, and is based on the pc8x16s.bdf font
+ from the vgafonts.tar.gz package, by "Myrlin". */
+
+unsigned char deffont[] =
+{
+ 0x42, 0x4d, 0x3e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e,
+ 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0x00, 0x00, 0x12, 0x0b, 0x00, 0x00, 0x12, 0x0b,
+ 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00,
+ 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x60,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x76, 0xf8, 0xc0, 0x6c, 0xfe, 0x70, 0x7c, 0x18,
+ 0x7e, 0x38, 0xee, 0x3c, 0x00, 0xc0, 0x1c, 0xc6, 0x00, 0x7e, 0x7e,
+ 0x7e, 0x18, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00,
+ 0x00, 0x00, 0xdc, 0xcc, 0xc0, 0x6c, 0xc6, 0xd8, 0x66, 0x18, 0x18,
+ 0x6c, 0x6c, 0x66, 0x00, 0x60, 0x30, 0xc6, 0xfe, 0x00, 0x00, 0x00,
+ 0x18, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x7e,
+ 0x00, 0xd8, 0xcc, 0xc0, 0x6c, 0x60, 0xd8, 0x66, 0x18, 0x3c, 0xc6,
+ 0x6c, 0x66, 0x7e, 0x7e, 0x60, 0xc6, 0x00, 0x00, 0x30, 0x0c, 0x18,
+ 0xd8, 0x18, 0xdc, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x7e, 0x00,
+ 0xd8, 0xcc, 0xc0, 0x6c, 0x30, 0xd8, 0x66, 0x18, 0x66, 0xc6, 0x6c,
+ 0x66, 0xdb, 0xf3, 0x60, 0xc6, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18,
+ 0x00, 0x76, 0x00, 0x18, 0x00, 0x6c, 0x00, 0x00, 0x7e, 0x00, 0xd8,
+ 0xc8, 0xc0, 0x6c, 0x18, 0xd8, 0x66, 0x18, 0x66, 0xc6, 0x6c, 0x66,
+ 0xdb, 0xdb, 0x60, 0xc6, 0xfe, 0x18, 0x0c, 0x30, 0x18, 0x18, 0x7e,
+ 0x00, 0x00, 0x18, 0x18, 0xec, 0x00, 0x00, 0x7e, 0x00, 0xdc, 0xdc,
+ 0xc0, 0x6c, 0x18, 0xd8, 0x66, 0x18, 0x66, 0xfe, 0xc6, 0x3e, 0xdb,
+ 0xdb, 0x7c, 0xc6, 0x00, 0x7e, 0x06, 0x60, 0x18, 0x18, 0x00, 0xdc,
+ 0x00, 0x00, 0x00, 0x0c, 0x36, 0x7e, 0x7e, 0x00, 0x76, 0xce, 0xc0,
+ 0xfe, 0x30, 0x7e, 0x66, 0xdc, 0x66, 0xc6, 0xc6, 0x0c, 0x7e, 0x7e,
+ 0x60, 0xc6, 0x00, 0x18, 0x0c, 0x30, 0x18, 0x18, 0x18, 0x76, 0x00,
+ 0x00, 0x00, 0x0c, 0x36, 0x32, 0x7e, 0x00, 0x00, 0xc6, 0xc6, 0x00,
+ 0x60, 0x00, 0x00, 0x76, 0x3c, 0xc6, 0xc6, 0x18, 0x00, 0x06, 0x60,
+ 0xc6, 0xfe, 0x18, 0x18, 0x18, 0x1b, 0x18, 0x00, 0x00, 0x38, 0x00,
+ 0x00, 0x0c, 0x36, 0x18, 0x7e, 0x00, 0x00, 0xce, 0xc6, 0x00, 0xc6,
+ 0x00, 0x00, 0x00, 0x18, 0x6c, 0x6c, 0x30, 0x00, 0x03, 0x30, 0x7c,
+ 0x00, 0x00, 0x30, 0x0c, 0x1b, 0x18, 0x00, 0x00, 0x6c, 0x00, 0x00,
+ 0x0c, 0x36, 0x0c, 0x00, 0x00, 0x00, 0x7c, 0xfe, 0x00, 0xfe, 0x00,
+ 0x00, 0x00, 0x7e, 0x38, 0x38, 0x1e, 0x00, 0x00, 0x1c, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x0e, 0x18, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x0c,
+ 0x36, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0f, 0x6c,
+ 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x36, 0x00,
+ 0x36, 0x00, 0x36, 0x36, 0x00, 0x36, 0x00, 0x00, 0x18, 0x36, 0x00,
+ 0x00, 0x18, 0x36, 0x36, 0x18, 0x00, 0x18, 0xff, 0xff, 0xf0, 0x0f,
+ 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x36, 0x00, 0x36,
+ 0x00, 0x36, 0x36, 0x00, 0x36, 0x00, 0x00, 0x18, 0x36, 0x00, 0x00,
+ 0x18, 0x36, 0x36, 0x18, 0x00, 0x18, 0xff, 0xff, 0xf0, 0x0f, 0x00,
+ 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x36, 0x00, 0x36, 0x00,
+ 0x36, 0x36, 0x00, 0x36, 0x00, 0x00, 0x18, 0x36, 0x00, 0x00, 0x18,
+ 0x36, 0x36, 0x18, 0x00, 0x18, 0xff, 0xff, 0xf0, 0x0f, 0x00, 0x00,
+ 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x36, 0x00, 0x36, 0x00, 0x36,
+ 0x36, 0x00, 0x36, 0x00, 0x00, 0x18, 0x36, 0x00, 0x00, 0x18, 0x36,
+ 0x36, 0x18, 0x00, 0x18, 0xff, 0xff, 0xf0, 0x0f, 0x00, 0x00, 0x00,
+ 0x18, 0x18, 0x00, 0x18, 0x18, 0x36, 0x00, 0x36, 0x00, 0x36, 0x36,
+ 0x00, 0x36, 0x00, 0x00, 0x18, 0x36, 0x00, 0x00, 0x18, 0x36, 0x36,
+ 0x18, 0x00, 0x18, 0xff, 0xff, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x18,
+ 0x18, 0x00, 0x18, 0x18, 0x36, 0x00, 0x36, 0x00, 0x36, 0x36, 0x00,
+ 0x36, 0x00, 0x00, 0x18, 0x36, 0x00, 0x00, 0x18, 0x36, 0x36, 0x18,
+ 0x00, 0x18, 0xff, 0xff, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x18, 0x18,
+ 0x00, 0x18, 0x18, 0x36, 0x00, 0x36, 0x00, 0x36, 0x36, 0x00, 0x36,
+ 0x00, 0x00, 0x18, 0x36, 0x00, 0x00, 0x18, 0x36, 0x36, 0x18, 0x00,
+ 0x18, 0xff, 0xff, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00,
+ 0x18, 0x18, 0x36, 0x00, 0x36, 0x00, 0x36, 0x36, 0x00, 0x36, 0x00,
+ 0x00, 0x18, 0x36, 0x00, 0x00, 0x18, 0x36, 0x36, 0x18, 0x00, 0x18,
+ 0xff, 0xff, 0xf0, 0x0f, 0x00, 0x1f, 0xff, 0xff, 0x1f, 0xff, 0xff,
+ 0x1f, 0x37, 0x3f, 0x37, 0xff, 0xf7, 0x37, 0xff, 0xf7, 0xff, 0xff,
+ 0xff, 0xff, 0x3f, 0x1f, 0x1f, 0x3f, 0xff, 0xff, 0xf8, 0x1f, 0xff,
+ 0xff, 0xf0, 0x0f, 0x00, 0x18, 0x18, 0x00, 0x18, 0x00, 0x18, 0x18,
+ 0x36, 0x30, 0x30, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x36, 0x00,
+ 0x00, 0x36, 0x18, 0x18, 0x00, 0x36, 0x18, 0x18, 0x00, 0xff, 0x00,
+ 0xf0, 0x0f, 0xff, 0x18, 0x18, 0x00, 0x18, 0x00, 0x18, 0x1f, 0x36,
+ 0x37, 0x3f, 0xf7, 0xff, 0x37, 0xff, 0xf7, 0xff, 0x36, 0xff, 0x00,
+ 0x36, 0x1f, 0x1f, 0x00, 0x36, 0xff, 0x18, 0x00, 0xff, 0x00, 0xf0,
+ 0x0f, 0xff, 0x18, 0x18, 0x00, 0x18, 0x00, 0x18, 0x18, 0x36, 0x36,
+ 0x00, 0x36, 0x00, 0x36, 0x00, 0x36, 0x18, 0x36, 0x00, 0x00, 0x36,
+ 0x18, 0x00, 0x00, 0x36, 0x18, 0x18, 0x00, 0xff, 0x00, 0xf0, 0x0f,
+ 0xff, 0x18, 0x18, 0x00, 0x18, 0x00, 0x18, 0x18, 0x36, 0x36, 0x00,
+ 0x36, 0x00, 0x36, 0x00, 0x36, 0x18, 0x36, 0x00, 0x00, 0x36, 0x18,
+ 0x00, 0x00, 0x36, 0x18, 0x18, 0x00, 0xff, 0x00, 0xf0, 0x0f, 0xff,
+ 0x18, 0x18, 0x00, 0x18, 0x00, 0x18, 0x18, 0x36, 0x36, 0x00, 0x36,
+ 0x00, 0x36, 0x00, 0x36, 0x18, 0x36, 0x00, 0x00, 0x36, 0x18, 0x00,
+ 0x00, 0x36, 0x18, 0x18, 0x00, 0xff, 0x00, 0xf0, 0x0f, 0xff, 0x18,
+ 0x18, 0x00, 0x18, 0x00, 0x18, 0x18, 0x36, 0x36, 0x00, 0x36, 0x00,
+ 0x36, 0x00, 0x36, 0x18, 0x36, 0x00, 0x00, 0x36, 0x18, 0x00, 0x00,
+ 0x36, 0x18, 0x18, 0x00, 0xff, 0x00, 0xf0, 0x0f, 0xff, 0x18, 0x18,
+ 0x00, 0x18, 0x00, 0x18, 0x18, 0x36, 0x36, 0x00, 0x36, 0x00, 0x36,
+ 0x00, 0x36, 0x18, 0x36, 0x00, 0x00, 0x36, 0x18, 0x00, 0x00, 0x36,
+ 0x18, 0x18, 0x00, 0xff, 0x00, 0xf0, 0x0f, 0xff, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x44, 0xaa, 0x77, 0x18, 0x18, 0x18, 0x36, 0x36, 0x18,
+ 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x11, 0x55, 0xdd, 0x18, 0x18, 0x18, 0x36, 0x36, 0x18, 0x36,
+ 0x36, 0x36, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x06, 0x00, 0x00, 0x00,
+ 0x44, 0xaa, 0x77, 0x18, 0x18, 0x18, 0x36, 0x36, 0x18, 0x36, 0x36,
+ 0x36, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x06, 0x00, 0x00, 0x00, 0x11,
+ 0x55, 0xdd, 0x18, 0x18, 0x18, 0x36, 0x36, 0x18, 0x36, 0x36, 0x36,
+ 0x00, 0x00, 0x00, 0x18, 0x76, 0x18, 0x7c, 0x78, 0x66, 0xc6, 0x00,
+ 0x00, 0x7c, 0x00, 0x00, 0x0c, 0x3f, 0x18, 0x00, 0x00, 0x44, 0xaa,
+ 0x77, 0x18, 0x18, 0x18, 0x36, 0x36, 0x18, 0x36, 0x36, 0x36, 0x00,
+ 0x00, 0x00, 0x18, 0xcc, 0x18, 0xc6, 0xcc, 0x66, 0xc6, 0x00, 0x00,
+ 0xc6, 0xc0, 0x06, 0x86, 0x9a, 0x3c, 0x00, 0x00, 0x11, 0x55, 0xdd,
+ 0x18, 0x18, 0x18, 0x36, 0x36, 0x18, 0x36, 0x36, 0x36, 0x00, 0x00,
+ 0x00, 0x18, 0xcc, 0x18, 0xc6, 0xcc, 0x66, 0xc6, 0x00, 0x00, 0xc6,
+ 0xc0, 0x06, 0xdc, 0xce, 0x3c, 0x36, 0xd8, 0x44, 0xaa, 0x77, 0x18,
+ 0x18, 0x18, 0x36, 0x36, 0x18, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00,
+ 0x18, 0xcc, 0x18, 0xc6, 0xcc, 0x66, 0xce, 0x00, 0x00, 0xc0, 0xc0,
+ 0x06, 0x60, 0x66, 0x3c, 0x6c, 0x6c, 0x11, 0x55, 0xdd, 0x18, 0x18,
+ 0x18, 0x36, 0x36, 0x18, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x18,
+ 0x7c, 0x18, 0xc6, 0xcc, 0x66, 0xde, 0x7e, 0x7c, 0x60, 0xc0, 0x06,
+ 0x30, 0x30, 0x18, 0xd8, 0x36, 0x44, 0xaa, 0x77, 0x18, 0xf8, 0xf8,
+ 0xf6, 0xfe, 0xf8, 0xf6, 0x36, 0xf6, 0xfe, 0xfe, 0xf8, 0xf8, 0x0c,
+ 0x18, 0xc6, 0xcc, 0x66, 0xfe, 0x00, 0x00, 0x30, 0xfe, 0xfe, 0x18,
+ 0x18, 0x18, 0x6c, 0x6c, 0x11, 0x55, 0xdd, 0x18, 0x18, 0x18, 0x36,
+ 0x00, 0x18, 0x06, 0x36, 0x06, 0x06, 0x36, 0x18, 0x00, 0x78, 0x38,
+ 0x7c, 0xcc, 0x5c, 0xf6, 0x3e, 0x38, 0x30, 0x00, 0x00, 0x6c, 0x6c,
+ 0x18, 0x36, 0xd8, 0x44, 0xaa, 0x77, 0x18, 0x18, 0xf8, 0x36, 0x00,
+ 0xf8, 0xf6, 0x36, 0xfe, 0xf6, 0x36, 0xf8, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xe6, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00,
+ 0x00, 0x00, 0x11, 0x55, 0xdd, 0x18, 0x18, 0x18, 0x36, 0x00, 0x00,
+ 0x36, 0x36, 0x00, 0x36, 0x36, 0x18, 0x00, 0x60, 0x30, 0x60, 0x60,
+ 0xdc, 0xc6, 0x6c, 0x6c, 0x30, 0x00, 0x00, 0x62, 0x62, 0x18, 0x00,
+ 0x00, 0x44, 0xaa, 0x77, 0x18, 0x18, 0x18, 0x36, 0x00, 0x00, 0x36,
+ 0x36, 0x00, 0x36, 0x36, 0x18, 0x00, 0x30, 0x18, 0x30, 0x30, 0x76,
+ 0x00, 0x3c, 0x38, 0x30, 0x00, 0x00, 0xe0, 0xe0, 0x18, 0x00, 0x00,
+ 0x11, 0x55, 0xdd, 0x18, 0x18, 0x18, 0x36, 0x00, 0x00, 0x36, 0x36,
+ 0x00, 0x36, 0x36, 0x18, 0x00, 0x18, 0x0c, 0x18, 0x18, 0x00, 0xdc,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x44,
+ 0xaa, 0x77, 0x18, 0x18, 0x18, 0x36, 0x00, 0x00, 0x36, 0x36, 0x00,
+ 0x36, 0x36, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x55,
+ 0xdd, 0x18, 0x18, 0x18, 0x36, 0x00, 0x00, 0x36, 0x36, 0x00, 0x36,
+ 0x36, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
+ 0x78, 0x7c, 0x76, 0x76, 0x76, 0x76, 0x7c, 0x7c, 0x7c, 0x7c, 0x18,
+ 0x18, 0x18, 0xc6, 0xc6, 0xfc, 0x6e, 0xce, 0x7c, 0x7c, 0x7c, 0x78,
+ 0x78, 0x76, 0x7c, 0x7c, 0x18, 0xfe, 0x18, 0xc6, 0x70, 0x3c, 0xcc,
+ 0xc2, 0xcc, 0xcc, 0xcc, 0xcc, 0xc6, 0xc2, 0xc2, 0xc2, 0x18, 0x18,
+ 0x18, 0xc6, 0xc6, 0xc0, 0xd8, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0xcc,
+ 0xce, 0xc6, 0xc6, 0x18, 0x60, 0x7e, 0xcc, 0xd8, 0x66, 0xcc, 0xc0,
+ 0xcc, 0xcc, 0xcc, 0xcc, 0xc0, 0xc0, 0xc0, 0xc0, 0x18, 0x18, 0x18,
+ 0xc6, 0xc6, 0xc0, 0xd8, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0xcc, 0xc6,
+ 0xc6, 0xc6, 0x7c, 0x60, 0x18, 0xcc, 0x18, 0xc6, 0xcc, 0xc0, 0xcc,
+ 0xcc, 0xcc, 0xcc, 0xc0, 0xc0, 0xc0, 0xc0, 0x18, 0x18, 0x18, 0xfe,
+ 0xc6, 0xc0, 0x7e, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0xcc, 0xc6, 0xc6,
+ 0xc6, 0xc6, 0x60, 0x7e, 0xcc, 0x18, 0xc0, 0xcc, 0xfe, 0x7c, 0x7c,
+ 0x7c, 0x7c, 0xc0, 0xfe, 0xfe, 0xfe, 0x18, 0x18, 0x18, 0xc6, 0xfe,
+ 0xf0, 0x36, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0xcc, 0xc6, 0xc6, 0xc6,
+ 0xc0, 0x60, 0x18, 0xde, 0x18, 0xc0, 0xcc, 0xc6, 0x0c, 0x0c, 0x0c,
+ 0x0c, 0xc6, 0xc6, 0xc6, 0xc6, 0x18, 0x18, 0x18, 0xc6, 0xc6, 0xc0,
+ 0x36, 0xfe, 0xc6, 0xc6, 0xc6, 0xcc, 0xcc, 0xc6, 0xc6, 0xc6, 0xc0,
+ 0xf8, 0x3c, 0xcc, 0x7e, 0xc0, 0xcc, 0x7c, 0x78, 0x78, 0x78, 0x78,
+ 0x7c, 0x7c, 0x7c, 0x7c, 0x38, 0x38, 0x38, 0x6c, 0x6c, 0xc0, 0xec,
+ 0xcc, 0x7c, 0x7c, 0x7c, 0xcc, 0xcc, 0xc6, 0xc6, 0xc6, 0xc0, 0x60,
+ 0x66, 0xc4, 0x18, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0xc0, 0x00, 0xcc,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0x60, 0x66,
+ 0xf8, 0x18, 0x3c, 0xcc, 0x30, 0x6c, 0x00, 0x18, 0x38, 0x00, 0x6c,
+ 0x00, 0x18, 0x00, 0x66, 0x18, 0x10, 0x10, 0xfc, 0x00, 0x6c, 0x6c,
+ 0x00, 0x18, 0xcc, 0x18, 0x00, 0x7c, 0xc6, 0x7c, 0x62, 0x66, 0xcc,
+ 0x18, 0x00, 0xcc, 0x18, 0x38, 0xcc, 0x30, 0x6c, 0x00, 0x38, 0xc6,
+ 0x30, 0x66, 0x3c, 0x30, 0x00, 0x38, 0x00, 0x00, 0x3e, 0x38, 0xc6,
+ 0x30, 0x78, 0x30, 0xc6, 0x00, 0x00, 0x18, 0x3c, 0x66, 0xcc, 0x1b,
+ 0x00, 0x00, 0x0c, 0x10, 0x00, 0x60, 0x38, 0x00, 0x10, 0x00, 0x60,
+ 0x00, 0x18, 0x60, 0xc6, 0x6c, 0x30, 0x00, 0x00, 0x10, 0x00, 0x60,
+ 0x30, 0x60, 0x00, 0xc6, 0xc6, 0x18, 0x00, 0x00, 0xf8, 0x0e, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x38, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc0, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0c, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xf8, 0x78, 0x7c, 0x7c,
+ 0x30, 0x7c, 0xcc, 0x18, 0x0c, 0xcc, 0x18, 0xc6, 0xcc, 0x78, 0xf8,
+ 0x7c, 0xc0, 0x7c, 0x30, 0x78, 0x10, 0x6c, 0xc6, 0x76, 0xfe, 0x0e,
+ 0x18, 0x70, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xc4, 0xcc, 0xc2, 0x30,
+ 0xcc, 0xcc, 0x18, 0x0c, 0xcc, 0x18, 0xd6, 0xcc, 0xcc, 0xcc, 0xcc,
+ 0xc0, 0x86, 0x30, 0xcc, 0x6c, 0xfe, 0x6c, 0xce, 0xc0, 0x18, 0x18,
+ 0x18, 0x00, 0xfe, 0x00, 0xcc, 0xcc, 0xc0, 0xcc, 0xc0, 0x30, 0xcc,
+ 0xcc, 0x18, 0x0c, 0xd8, 0x18, 0xd6, 0xcc, 0xcc, 0xcc, 0xcc, 0xc0,
+ 0x06, 0x30, 0xcc, 0xc6, 0xd6, 0x38, 0xc6, 0x60, 0x18, 0x18, 0x18,
+ 0x00, 0xc6, 0x00, 0xcc, 0xcc, 0xc0, 0xcc, 0xc0, 0x30, 0xcc, 0xcc,
+ 0x18, 0x0c, 0xf0, 0x18, 0xd6, 0xcc, 0xcc, 0xcc, 0xcc, 0xc0, 0x1c,
+ 0x30, 0xcc, 0xc6, 0xd6, 0x38, 0xc6, 0x30, 0x18, 0x18, 0x18, 0x00,
+ 0xc6, 0x00, 0x7c, 0xcc, 0xc0, 0xcc, 0xfe, 0x30, 0xcc, 0xcc, 0x18,
+ 0x0c, 0xf0, 0x18, 0xd6, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x70, 0x30,
+ 0xcc, 0xc6, 0xd6, 0x38, 0xc6, 0x18, 0x18, 0x18, 0x18, 0x00, 0xc6,
+ 0x00, 0x0c, 0xcc, 0xc4, 0xcc, 0xc6, 0x78, 0xcc, 0xec, 0x18, 0x0c,
+ 0xd8, 0x18, 0xfe, 0xcc, 0xcc, 0xcc, 0xcc, 0xec, 0xc2, 0x30, 0xcc,
+ 0xc6, 0xc6, 0x6c, 0xc6, 0x0c, 0x70, 0x18, 0x0e, 0x00, 0x6c, 0x00,
+ 0x78, 0xf8, 0x78, 0x7c, 0x7c, 0x30, 0x7c, 0xd8, 0x38, 0x0c, 0xcc,
+ 0x18, 0xec, 0xb8, 0x78, 0xf8, 0x7c, 0xb8, 0x7c, 0xfc, 0xcc, 0xc6,
+ 0xc6, 0xc6, 0xc6, 0xfe, 0x18, 0x18, 0x18, 0x00, 0x38, 0x00, 0x00,
+ 0xc0, 0x00, 0x0c, 0x00, 0x32, 0x00, 0xc0, 0x00, 0x00, 0xc0, 0x18,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x00, 0x10, 0x0c, 0x00, 0xc0,
+ 0x00, 0x0c, 0x00, 0x36, 0x00, 0xc0, 0x18, 0x0c, 0xc0, 0x18, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x00, 0xc0, 0x00,
+ 0x0c, 0x00, 0x1c, 0x00, 0xc0, 0x18, 0x0c, 0xc0, 0x38, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0e, 0x18, 0x70, 0xdc, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x7c, 0xc6, 0xfc, 0x3c, 0xf8, 0xfc, 0xc0, 0x3e, 0xc6, 0x18, 0x78,
+ 0xc2, 0xfc, 0xc6, 0xc6, 0x7c, 0xc0, 0x7c, 0xc6, 0x7c, 0x18, 0x7c,
+ 0x10, 0x6c, 0xc6, 0x18, 0xfe, 0x3c, 0x02, 0x3c, 0x00, 0x00, 0xc0,
+ 0xc6, 0xc6, 0x66, 0xdc, 0xc0, 0xc0, 0x66, 0xc6, 0x18, 0xcc, 0xc6,
+ 0xc0, 0xc6, 0xc6, 0xc6, 0xc0, 0xde, 0xc6, 0x86, 0x18, 0xc6, 0x38,
+ 0xee, 0xc6, 0x18, 0xc0, 0x30, 0x06, 0x0c, 0x00, 0x00, 0xdc, 0xc6,
+ 0xc6, 0xc2, 0xce, 0xc0, 0xc0, 0xc6, 0xc6, 0x18, 0xcc, 0xcc, 0xc0,
+ 0xc6, 0xc6, 0xc6, 0xc0, 0xd6, 0xcc, 0x06, 0x18, 0xc6, 0x6c, 0xfe,
+ 0x6c, 0x18, 0xc0, 0x30, 0x0e, 0x0c, 0x00, 0x00, 0xde, 0xc6, 0xc6,
+ 0xc0, 0xc6, 0xc0, 0xc0, 0xc6, 0xc6, 0x18, 0xcc, 0xd8, 0xc0, 0xc6,
+ 0xc6, 0xc6, 0xc0, 0xc6, 0xcc, 0x06, 0x18, 0xc6, 0xc6, 0xd6, 0x7c,
+ 0x18, 0x60, 0x30, 0x1c, 0x0c, 0x00, 0x00, 0xde, 0xfe, 0xc6, 0xc0,
+ 0xc6, 0xc0, 0xc0, 0xde, 0xc6, 0x18, 0x0c, 0xf0, 0xc0, 0xc6, 0xce,
+ 0xc6, 0xc0, 0xc6, 0xd8, 0x0c, 0x18, 0xc6, 0xc6, 0xd6, 0x38, 0x18,
+ 0x30, 0x30, 0x38, 0x0c, 0x00, 0x00, 0xde, 0xc6, 0xfc, 0xc0, 0xc6,
+ 0xf8, 0xf8, 0xc0, 0xfe, 0x18, 0x0c, 0xf0, 0xc0, 0xd6, 0xde, 0xc6,
+ 0xfc, 0xc6, 0xfc, 0x38, 0x18, 0xc6, 0xc6, 0xd6, 0x38, 0x3c, 0x18,
+ 0x30, 0x70, 0x0c, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc0, 0xc6, 0xc0,
+ 0xc0, 0xc0, 0xc6, 0x18, 0x0c, 0xd8, 0xc0, 0xfe, 0xfe, 0xc6, 0xc6,
+ 0xc6, 0xc6, 0x60, 0x18, 0xc6, 0xc6, 0xc6, 0x7c, 0x66, 0x0c, 0x30,
+ 0xe0, 0x0c, 0x00, 0x00, 0xc6, 0x6c, 0xc6, 0xc2, 0xce, 0xc0, 0xc0,
+ 0xc0, 0xc6, 0x18, 0x0c, 0xcc, 0xc0, 0xfe, 0xf6, 0xc6, 0xc6, 0xc6,
+ 0xc6, 0xc0, 0x18, 0xc6, 0xc6, 0xc6, 0x6c, 0x66, 0x06, 0x30, 0xc0,
+ 0x0c, 0x00, 0x00, 0x7c, 0x38, 0xc6, 0x66, 0xdc, 0xc0, 0xc0, 0x62,
+ 0xc6, 0x18, 0x0c, 0xc6, 0xc0, 0xee, 0xe6, 0xc6, 0xc6, 0xc6, 0xc6,
+ 0xc2, 0x7e, 0xc6, 0xc6, 0xc6, 0xc6, 0x66, 0x06, 0x30, 0x80, 0x0c,
+ 0xc6, 0x00, 0x00, 0x10, 0xfc, 0x3c, 0xf8, 0xfc, 0xfc, 0x3c, 0xc6,
+ 0x18, 0x1e, 0xc2, 0xc0, 0xc6, 0xc6, 0x7c, 0xfc, 0x7c, 0xfc, 0x7c,
+ 0x7e, 0xc6, 0xc6, 0xc6, 0xc6, 0x66, 0xfe, 0x3c, 0x00, 0x3c, 0x6c,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x6c, 0x7c,
+ 0x86, 0x76, 0x00, 0x0c, 0x30, 0x00, 0x00, 0x18, 0x00, 0x18, 0x80,
+ 0x38, 0x18, 0xfe, 0x7c, 0x0c, 0x7c, 0x7c, 0x30, 0x7c, 0x78, 0x00,
+ 0x30, 0x06, 0x00, 0x60, 0x18, 0x00, 0x18, 0x00, 0x6c, 0xc6, 0xc6,
+ 0xcc, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x00, 0x18, 0xc0, 0x6c,
+ 0x18, 0xc0, 0x86, 0x0c, 0x86, 0xc6, 0x30, 0xc6, 0x8c, 0x18, 0x18,
+ 0x0c, 0x00, 0x30, 0x18, 0x00, 0x00, 0x00, 0xfe, 0x86, 0x60, 0xcc,
+ 0x00, 0x30, 0x0c, 0x66, 0x18, 0x18, 0x00, 0x00, 0x60, 0xc6, 0x18,
+ 0xc0, 0x06, 0x0c, 0x06, 0xc6, 0x30, 0xc6, 0x06, 0x18, 0x18, 0x18,
+ 0x00, 0x18, 0x00, 0x00, 0x18, 0x00, 0x6c, 0x06, 0x30, 0xcc, 0x00,
+ 0x30, 0x0c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x30, 0xe6, 0x18, 0x60,
+ 0x06, 0x0c, 0x06, 0xc6, 0x30, 0xc6, 0x06, 0x00, 0x00, 0x30, 0x7e,
+ 0x0c, 0x18, 0x00, 0x18, 0x00, 0x6c, 0x06, 0x18, 0xdc, 0x00, 0x30,
+ 0x0c, 0xff, 0x7e, 0x00, 0xfe, 0x00, 0x18, 0xf6, 0x18, 0x30, 0x06,
+ 0xfe, 0x06, 0xe6, 0x18, 0xc6, 0x06, 0x00, 0x00, 0x60, 0x00, 0x06,
+ 0x18, 0x00, 0x18, 0x00, 0x6c, 0x7c, 0x0c, 0x76, 0x00, 0x30, 0x0c,
+ 0x3c, 0x18, 0x00, 0x00, 0x00, 0x0c, 0xde, 0x18, 0x18, 0x3c, 0xcc,
+ 0xfc, 0xdc, 0x0c, 0x7c, 0x7e, 0x00, 0x00, 0x30, 0x00, 0x0c, 0x18,
+ 0x00, 0x3c, 0x00, 0xfe, 0xc0, 0xc6, 0x38, 0x00, 0x30, 0x0c, 0x66,
+ 0x18, 0x00, 0x00, 0x00, 0x06, 0xce, 0x18, 0x0c, 0x06, 0x6c, 0xc0,
+ 0xc0, 0x06, 0xc6, 0xc6, 0x18, 0x18, 0x18, 0x7e, 0x18, 0x0c, 0x00,
+ 0x3c, 0x24, 0x6c, 0xc2, 0xc2, 0x6c, 0x60, 0x30, 0x0c, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x02, 0xc6, 0x78, 0x06, 0x06, 0x3c, 0xc0, 0xc0,
+ 0x06, 0xc6, 0xc6, 0x18, 0x18, 0x0c, 0x00, 0x30, 0xc6, 0x00, 0x3c,
+ 0x66, 0x6c, 0xc6, 0x00, 0x6c, 0x30, 0x18, 0x18, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x6c, 0x38, 0xc6, 0x86, 0x1c, 0xc0, 0x60, 0x06,
+ 0xc6, 0xc6, 0x00, 0x00, 0x06, 0x00, 0x60, 0xc6, 0x00, 0x18, 0x66,
+ 0x00, 0x7c, 0x00, 0x38, 0x30, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x38, 0x18, 0x7c, 0x7c, 0x0c, 0xfe, 0x3c, 0xfe, 0x7c,
+ 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x66, 0x00,
+ 0x18, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x7e, 0x7e, 0x10, 0x00, 0x3c, 0x3c, 0x00, 0xff, 0x00,
+ 0xff, 0x78, 0x18, 0xe0, 0xe6, 0x18, 0x80, 0x02, 0x00, 0x66, 0x1b,
+ 0xc6, 0xfe, 0x7e, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x81, 0xff, 0x38, 0x10, 0x18, 0x18, 0x00, 0xff, 0x3c, 0xc3,
+ 0xcc, 0x18, 0xf0, 0xe7, 0x18, 0xc0, 0x06, 0x18, 0x66, 0x1b, 0x0c,
+ 0xfe, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x10, 0x00,
+ 0x81, 0xff, 0x7c, 0x38, 0x18, 0x18, 0x18, 0xe7, 0x66, 0x99, 0xcc,
+ 0x7e, 0x70, 0x67, 0xdb, 0xe0, 0x0e, 0x3c, 0x00, 0x1b, 0x38, 0xfe,
+ 0x3c, 0x18, 0x7e, 0x18, 0x30, 0xfe, 0x28, 0xfe, 0x38, 0x00, 0x99,
+ 0xe7, 0xfe, 0x7c, 0xe7, 0x7e, 0x3c, 0xc3, 0x42, 0xbd, 0xcc, 0x18,
+ 0x30, 0x63, 0x3c, 0xf0, 0x1e, 0x7e, 0x66, 0x1b, 0x6c, 0xfe, 0x7e,
+ 0x18, 0x18, 0x0c, 0x60, 0xc0, 0x6c, 0x7c, 0x38, 0x00, 0xbd, 0xc3,
+ 0xfe, 0xfe, 0xe7, 0xff, 0x3c, 0xc3, 0x42, 0xbd, 0xcc, 0x3c, 0x30,
+ 0x63, 0xe7, 0xf8, 0x3e, 0x18, 0x66, 0x1b, 0xc6, 0x00, 0x18, 0x18,
+ 0x18, 0xfe, 0xfe, 0xc0, 0xfe, 0x7c, 0x7c, 0x00, 0x81, 0xff, 0xfe,
+ 0x7c, 0xe7, 0xff, 0x18, 0xe7, 0x66, 0x99, 0x78, 0x66, 0x30, 0x63,
+ 0x3c, 0xfe, 0xfe, 0x18, 0x66, 0x7b, 0xc6, 0x00, 0x18, 0x18, 0x18,
+ 0x0c, 0x60, 0xc0, 0x6c, 0x38, 0x7c, 0x00, 0x81, 0xff, 0xfe, 0x38,
+ 0x3c, 0x7e, 0x00, 0xff, 0x3c, 0xc3, 0x32, 0x66, 0x30, 0x63, 0xdb,
+ 0xf8, 0x3e, 0x18, 0x66, 0xdb, 0x6c, 0x00, 0x18, 0x18, 0x18, 0x18,
+ 0x30, 0x00, 0x28, 0x38, 0xfe, 0x00, 0xa5, 0xdb, 0x6c, 0x10, 0x3c,
+ 0x3c, 0x00, 0xff, 0x00, 0xff, 0x1a, 0x66, 0x3f, 0x7f, 0x18, 0xf0,
+ 0x1e, 0x7e, 0x66, 0xdb, 0x38, 0x00, 0x7e, 0x7e, 0x18, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0xfe, 0x00, 0x81, 0xff, 0x00, 0x00, 0x18, 0x18,
+ 0x00, 0xff, 0x00, 0xff, 0x0e, 0x66, 0x33, 0x63, 0x18, 0xe0, 0x0e,
+ 0x3c, 0x66, 0xdb, 0x60, 0x00, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0x00, 0xff, 0x1e, 0x3c, 0x3f, 0x7f, 0x00, 0xc0, 0x06, 0x18,
+ 0x66, 0x7f, 0xc6, 0x00, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
+ 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00,
+ 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
diff --git a/payloads/libpayload/curses/PDCurses-3.4/sdl1/deficon.h b/payloads/libpayload/curses/PDCurses-3.4/sdl1/deficon.h
new file mode 100644
index 0000000000..7248ab5094
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/sdl1/deficon.h
@@ -0,0 +1,23 @@
+/* The PDCurses logo as #include'able BMP (from ../x11/little_icon.xbm) */
+
+unsigned char deficon[] =
+{
+ 0x42, 0x4d, 0xbe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e,
+ 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+ 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x13, 0x0b,
+ 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xce, 0x6f, 0x9c,
+ 0xe7, 0xb5, 0xaf, 0x6b, 0x5b, 0xbd, 0xaf, 0xeb, 0xfb, 0xbd, 0xaf,
+ 0x98, 0xe7, 0xbd, 0xaf, 0x7b, 0x5f, 0xb5, 0xa5, 0x6b, 0x5b, 0xcd,
+ 0xab, 0x9c, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xcf, 0x03, 0xff, 0xff, 0xce, 0x03, 0xff, 0xff, 0xcc, 0x73,
+ 0xff, 0xff, 0xcc, 0xf3, 0xff, 0xff, 0xcc, 0xf3, 0xff, 0xff, 0xcc,
+ 0x73, 0xff, 0xff, 0xc6, 0x33, 0xff, 0xff, 0xc3, 0x13, 0xff, 0xff,
+ 0xc1, 0x83, 0xff, 0xff, 0xc8, 0xc3, 0xff, 0xff, 0xcc, 0x63, 0xff,
+ 0xff, 0xce, 0x33, 0xff, 0xff, 0xcf, 0x33, 0xff, 0xff, 0xcf, 0x33,
+ 0xff, 0xff, 0xce, 0x33, 0xff, 0xff, 0xc0, 0x73, 0xff, 0xff, 0xc0,
+ 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff
+};
diff --git a/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcclip.c b/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcclip.c
new file mode 100644
index 0000000000..203c975d24
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcclip.c
@@ -0,0 +1,128 @@
+/* Public Domain Curses */
+
+#include "pdcsdl.h"
+
+RCSID("$Id: pdcclip.c,v 1.6 2008/07/14 04:24:52 wmcbrine Exp $")
+
+#include <stdlib.h>
+
+/*man-start**************************************************************
+
+ Name: clipboard
+
+ Synopsis:
+ int PDC_getclipboard(char **contents, long *length);
+ int PDC_setclipboard(const char *contents, long length);
+ int PDC_freeclipboard(char *contents);
+ int PDC_clearclipboard(void);
+
+ Description:
+ PDC_getclipboard() gets the textual contents of the system's
+ clipboard. This function returns the contents of the clipboard
+ in the contents argument. It is the responsibilitiy of the
+ caller to free the memory returned, via PDC_freeclipboard().
+ The length of the clipboard contents is returned in the length
+ argument.
+
+ PDC_setclipboard copies the supplied text into the system's
+ clipboard, emptying the clipboard prior to the copy.
+
+ PDC_clearclipboard() clears the internal clipboard.
+
+ Return Values:
+ indicator of success/failure of call.
+ PDC_CLIP_SUCCESS the call was successful
+ PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for
+ the clipboard contents
+ PDC_CLIP_EMPTY the clipboard contains no text
+ PDC_CLIP_ACCESS_ERROR no clipboard support
+
+ Portability X/Open BSD SYS V
+ PDC_getclipboard - - -
+ PDC_setclipboard - - -
+ PDC_freeclipboard - - -
+ PDC_clearclipboard - - -
+
+**man-end****************************************************************/
+
+/* global clipboard contents, should be NULL if none set */
+
+static char *pdc_SDL_clipboard = NULL;
+
+int PDC_getclipboard(char **contents, long *length)
+{
+ int len;
+
+ PDC_LOG(("PDC_getclipboard() - called\n"));
+
+ if (!pdc_SDL_clipboard)
+ return PDC_CLIP_EMPTY;
+
+ len = strlen(pdc_SDL_clipboard);
+ if ((*contents = malloc(len + 1)) == NULL)
+ return PDC_CLIP_MEMORY_ERROR;
+
+ strcpy(*contents, pdc_SDL_clipboard);
+ *length = len;
+
+ return PDC_CLIP_SUCCESS;
+}
+
+int PDC_setclipboard(const char *contents, long length)
+{
+ PDC_LOG(("PDC_setclipboard() - called\n"));
+
+ if (pdc_SDL_clipboard)
+ {
+ free(pdc_SDL_clipboard);
+ pdc_SDL_clipboard = NULL;
+ }
+
+ if (contents)
+ {
+ if ((pdc_SDL_clipboard = malloc(length + 1)) == NULL)
+ return PDC_CLIP_MEMORY_ERROR;
+
+ strcpy(pdc_SDL_clipboard, contents);
+ }
+
+ return PDC_CLIP_SUCCESS;
+}
+
+int PDC_freeclipboard(char *contents)
+{
+ PDC_LOG(("PDC_freeclipboard() - called\n"));
+
+ /* should we also free empty the system clipboard? probably not */
+
+ if (contents)
+ {
+ /* NOTE: We free the memory, but we can not set caller's pointer
+ to NULL, so if caller calls again then will try to access
+ free'd memory. We 1st overwrite memory with a string so if
+ caller tries to use free memory they won't get what they
+ expect & hopefully notice. */
+
+ /* memset(contents, 0xFD, strlen(contents)); */
+
+ if (strlen(contents) >= strlen("PDCURSES"))
+ strcpy(contents, "PDCURSES");
+
+ free(contents);
+ }
+
+ return PDC_CLIP_SUCCESS;
+}
+
+int PDC_clearclipboard(void)
+{
+ PDC_LOG(("PDC_clearclipboard() - called\n"));
+
+ if (pdc_SDL_clipboard)
+ {
+ free(pdc_SDL_clipboard);
+ pdc_SDL_clipboard = NULL;
+ }
+
+ return PDC_CLIP_SUCCESS;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcdisp.c b/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcdisp.c
new file mode 100644
index 0000000000..3712e6622e
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcdisp.c
@@ -0,0 +1,301 @@
+/* Public Domain Curses */
+
+#include "pdcsdl.h"
+
+RCSID("$Id: pdcdisp.c,v 1.35 2008/07/14 04:24:52 wmcbrine Exp $")
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef CHTYPE_LONG
+
+# define A(x) ((chtype)x | A_ALTCHARSET)
+
+chtype acs_map[128] =
+{
+ A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9),
+ A(10), A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18),
+ A(19), A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27),
+ A(28), A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&',
+ '\'', '(', ')', '*',
+
+ A(0x1a), A(0x1b), A(0x18), A(0x19),
+
+ '/',
+
+ 0xdb,
+
+ '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
+ '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
+ 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
+
+ A(0x04), 0xb1,
+
+ 'b', 'c', 'd', 'e',
+
+ 0xf8, 0xf1, 0xb0, A(0x0f), 0xd9, 0xbf, 0xda, 0xc0, 0xc5, 0x2d,
+ 0x2d, 0xc4, 0x2d, 0x5f, 0xc3, 0xb4, 0xc1, 0xc2, 0xb3, 0xf3,
+ 0xf2, 0xe3, 0xd8, 0x9c, 0xf9,
+
+ A(127)
+};
+
+# undef A
+
+#endif
+
+Uint32 pdc_lastupdate = 0;
+
+#define MAXRECT 200 /* maximum number of rects to queue up before
+ an update is forced; the number was chosen
+ arbitrarily */
+
+static SDL_Rect uprect[MAXRECT]; /* table of rects to update */
+static chtype oldch = (chtype)(-1); /* current attribute */
+static int rectcount = 0; /* index into uprect */
+static short foregr = -2, backgr = -2; /* current foreground, background */
+
+/* do the real updates on a delay */
+
+void PDC_update_rects(void)
+{
+ if (rectcount)
+ {
+ /* if the maximum number of rects has been reached, we're
+ probably better off doing a full screen update */
+
+ if (rectcount == MAXRECT)
+ SDL_Flip(pdc_screen);
+ else
+ SDL_UpdateRects(pdc_screen, rectcount, uprect);
+
+ pdc_lastupdate = SDL_GetTicks();
+ rectcount = 0;
+ }
+}
+
+/* set the font colors to match the chtype's attribute */
+
+static void _set_attr(chtype ch)
+{
+ ch &= (A_COLOR|A_BOLD|A_BLINK|A_REVERSE);
+
+ if (oldch != ch)
+ {
+ short newfg, newbg;
+
+ if (SP->mono)
+ return;
+
+ PDC_pair_content(PAIR_NUMBER(ch), &newfg, &newbg);
+
+ newfg |= (ch & A_BOLD) ? 8 : 0;
+ newbg |= (ch & A_BLINK) ? 8 : 0;
+
+ if (ch & A_REVERSE)
+ {
+ short tmp = newfg;
+ newfg = newbg;
+ newbg = tmp;
+ }
+
+ if (newfg != foregr)
+ {
+ SDL_SetPalette(pdc_font, SDL_LOGPAL,
+ pdc_color + newfg, pdc_flastc, 1);
+ foregr = newfg;
+ }
+
+ if (newbg != backgr)
+ {
+ if (newbg == -1)
+ SDL_SetColorKey(pdc_font, SDL_SRCCOLORKEY, 0);
+ else
+ {
+ if (backgr == -1)
+ SDL_SetColorKey(pdc_font, 0, 0);
+
+ SDL_SetPalette(pdc_font, SDL_LOGPAL,
+ pdc_color + newbg, 0, 1);
+ }
+
+ backgr = newbg;
+ }
+
+ oldch = ch;
+ }
+}
+
+/* draw a cursor at (y, x) */
+
+void PDC_gotoyx(int row, int col)
+{
+ SDL_Rect src, dest;
+ chtype ch;
+ int oldrow, oldcol;
+
+ PDC_LOG(("PDC_gotoyx() - called: row %d col %d from row %d col %d\n",
+ row, col, SP->cursrow, SP->curscol));
+
+ if (SP->mono)
+ return;
+
+ oldrow = SP->cursrow;
+ oldcol = SP->curscol;
+
+ /* clear the old cursor */
+
+ PDC_transform_line(oldrow, oldcol, 1, curscr->_y[oldrow] + oldcol);
+
+ if (!SP->visibility)
+ return;
+
+ /* draw a new cursor by overprinting the existing character in
+ reverse, either the full cell (when visibility == 2) or the
+ lowest quarter of it (when visibility == 1) */
+
+ ch = curscr->_y[row][col] ^ A_REVERSE;
+
+ _set_attr(ch);
+
+#ifdef CHTYPE_LONG
+ if (ch & A_ALTCHARSET && !(ch & 0xff80))
+ ch = acs_map[ch & 0x7f];
+#endif
+ src.h = (SP->visibility == 1) ? pdc_fheight >> 2 : pdc_fheight;
+ src.w = pdc_fwidth;
+
+ dest.y = (row + 1) * pdc_fheight - src.h + pdc_yoffset;
+ dest.x = col * pdc_fwidth + pdc_xoffset;
+
+ src.x = (ch & 0xff) % 32 * pdc_fwidth;
+ src.y = (ch & 0xff) / 32 * pdc_fheight + (pdc_fheight - src.h);
+
+ SDL_BlitSurface(pdc_font, &src, pdc_screen, &dest);
+
+ if (oldrow != row || oldcol != col)
+ {
+ if (rectcount == MAXRECT)
+ PDC_update_rects();
+
+ uprect[rectcount++] = dest;
+ }
+}
+
+/* handle the A_*LINE attributes */
+
+static void _highlight(SDL_Rect *src, SDL_Rect *dest, chtype ch)
+{
+ short col = SP->line_color;
+
+ if (SP->mono)
+ return;
+
+ if (ch & A_UNDERLINE)
+ {
+ if (col != -1)
+ SDL_SetPalette(pdc_font, SDL_LOGPAL,
+ pdc_color + col, pdc_flastc, 1);
+
+ src->x = '_' % 32 * pdc_fwidth;
+ src->y = '_' / 32 * pdc_fheight;
+
+ if (backgr != -1)
+ SDL_SetColorKey(pdc_font, SDL_SRCCOLORKEY, 0);
+
+ SDL_BlitSurface(pdc_font, src, pdc_screen, dest);
+
+ if (backgr != -1)
+ SDL_SetColorKey(pdc_font, 0, 0);
+
+ if (col != -1)
+ SDL_SetPalette(pdc_font, SDL_LOGPAL,
+ pdc_color + foregr, pdc_flastc, 1);
+ }
+
+ if (ch & (A_LEFTLINE|A_RIGHTLINE))
+ {
+ if (col == -1)
+ col = foregr;
+
+ dest->w = 1;
+
+ if (ch & A_LEFTLINE)
+ SDL_FillRect(pdc_screen, dest, pdc_mapped[col]);
+
+ if (ch & A_RIGHTLINE)
+ {
+ dest->x += pdc_fwidth - 1;
+ SDL_FillRect(pdc_screen, dest, pdc_mapped[col]);
+ dest->x -= pdc_fwidth - 1;
+ }
+
+ dest->w = pdc_fwidth;
+ }
+}
+
+/* update the given physical line to look like the corresponding line in
+ curscr */
+
+void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
+{
+ SDL_Rect src, dest, lastrect;
+ int j;
+
+ PDC_LOG(("PDC_transform_line() - called: lineno=%d\n", lineno));
+
+ if (rectcount == MAXRECT)
+ PDC_update_rects();
+
+ src.h = pdc_fheight;
+ src.w = pdc_fwidth;
+
+ dest.y = pdc_fheight * lineno + pdc_yoffset;
+ dest.x = pdc_fwidth * x + pdc_xoffset;
+ dest.h = pdc_fheight;
+ dest.w = pdc_fwidth * len;
+
+ /* if the previous rect was just above this one, with the same width
+ and horizontal position, then merge the new one with it instead
+ of adding a new entry */
+
+ if (rectcount)
+ lastrect = uprect[rectcount - 1];
+
+ if (rectcount && lastrect.x == dest.x && lastrect.w == dest.w)
+ {
+ if (lastrect.y + lastrect.h == dest.y)
+ uprect[rectcount - 1].h = lastrect.h + pdc_fheight;
+ else
+ if (lastrect.y != dest.y)
+ uprect[rectcount++] = dest;
+ }
+ else
+ uprect[rectcount++] = dest;
+
+ dest.w = pdc_fwidth;
+
+ for (j = 0; j < len; j++)
+ {
+ chtype ch = srcp[j];
+
+ _set_attr(ch);
+#ifdef CHTYPE_LONG
+ if (ch & A_ALTCHARSET && !(ch & 0xff80))
+ ch = (ch & (A_ATTRIBUTES ^ A_ALTCHARSET)) | acs_map[ch & 0x7f];
+#endif
+ if (backgr == -1)
+ SDL_LowerBlit(pdc_tileback, &dest, pdc_screen, &dest);
+
+ src.x = (ch & 0xff) % 32 * pdc_fwidth;
+ src.y = (ch & 0xff) / 32 * pdc_fheight;
+
+ SDL_LowerBlit(pdc_font, &src, pdc_screen, &dest);
+
+ if (ch & (A_UNDERLINE|A_LEFTLINE|A_RIGHTLINE))
+ _highlight(&src, &dest, ch);
+
+ dest.x += pdc_fwidth;
+ }
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcgetsc.c b/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcgetsc.c
new file mode 100644
index 0000000000..4319235072
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcgetsc.c
@@ -0,0 +1,32 @@
+/* Public Domain Curses */
+
+#include "pdcsdl.h"
+
+RCSID("$Id: pdcgetsc.c,v 1.8 2008/07/14 04:24:52 wmcbrine Exp $")
+
+/* get the cursor size/shape */
+
+int PDC_get_cursor_mode(void)
+{
+ PDC_LOG(("PDC_get_cursor_mode() - called\n"));
+
+ return 0;
+}
+
+/* return number of screen rows */
+
+int PDC_get_rows(void)
+{
+ PDC_LOG(("PDC_get_rows() - called\n"));
+
+ return pdc_sheight / pdc_fheight;
+}
+
+/* return width of screen/viewport */
+
+int PDC_get_columns(void)
+{
+ PDC_LOG(("PDC_get_columns() - called\n"));
+
+ return pdc_swidth / pdc_fwidth;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdckbd.c b/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdckbd.c
new file mode 100644
index 0000000000..56bf1e470d
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdckbd.c
@@ -0,0 +1,389 @@
+/* Public Domain Curses */
+
+#include "pdcsdl.h"
+
+RCSID("$Id: pdckbd.c,v 1.20 2008/07/14 04:24:52 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: pdckbd
+
+ Synopsis:
+ unsigned long PDC_get_input_fd(void);
+
+ Description:
+ PDC_get_input_fd() returns the file descriptor that PDCurses
+ reads its input from. It can be used for select().
+
+ Portability X/Open BSD SYS V
+ PDC_get_input_fd - - -
+
+**man-end****************************************************************/
+
+#include <string.h>
+
+unsigned long pdc_key_modifiers = 0L;
+
+static SDL_Event event;
+static SDLKey oldkey;
+static MOUSE_STATUS old_mouse_status;
+
+static struct
+{
+ SDLKey keycode;
+ bool numkeypad;
+ unsigned short normal;
+ unsigned short shifted;
+ unsigned short control;
+ unsigned short alt;
+} key_table[] =
+{
+/* keycode keypad normal shifted control alt*/
+ {SDLK_LEFT, FALSE, KEY_LEFT, KEY_SLEFT, CTL_LEFT, ALT_LEFT},
+ {SDLK_RIGHT, FALSE, KEY_RIGHT, KEY_SRIGHT, CTL_RIGHT, ALT_RIGHT},
+ {SDLK_UP, FALSE, KEY_UP, KEY_SUP, CTL_UP, ALT_UP},
+ {SDLK_DOWN, FALSE, KEY_DOWN, KEY_SDOWN, CTL_DOWN, ALT_DOWN},
+ {SDLK_HOME, FALSE, KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME},
+ {SDLK_END, FALSE, KEY_END, KEY_SEND, CTL_END, ALT_END},
+ {SDLK_PAGEUP, FALSE, KEY_PPAGE, KEY_SPREVIOUS,CTL_PGUP, ALT_PGUP},
+ {SDLK_PAGEDOWN,FALSE, KEY_NPAGE, KEY_SNEXT, CTL_PGDN, ALT_PGDN},
+ {SDLK_INSERT, FALSE, KEY_IC, KEY_SIC, CTL_INS, ALT_INS},
+ {SDLK_DELETE, FALSE, KEY_DC, KEY_SDC, CTL_DEL, ALT_DEL},
+ {SDLK_F1, FALSE, KEY_F(1), KEY_F(13), KEY_F(25), KEY_F(37)},
+ {SDLK_F2, FALSE, KEY_F(2), KEY_F(14), KEY_F(26), KEY_F(38)},
+ {SDLK_F3, FALSE, KEY_F(3), KEY_F(15), KEY_F(27), KEY_F(39)},
+ {SDLK_F4, FALSE, KEY_F(4), KEY_F(16), KEY_F(28), KEY_F(40)},
+ {SDLK_F5, FALSE, KEY_F(5), KEY_F(17), KEY_F(29), KEY_F(41)},
+ {SDLK_F6, FALSE, KEY_F(6), KEY_F(18), KEY_F(30), KEY_F(42)},
+ {SDLK_F7, FALSE, KEY_F(7), KEY_F(19), KEY_F(31), KEY_F(43)},
+ {SDLK_F8, FALSE, KEY_F(8), KEY_F(20), KEY_F(32), KEY_F(44)},
+ {SDLK_F9, FALSE, KEY_F(9), KEY_F(21), KEY_F(33), KEY_F(45)},
+ {SDLK_F10, FALSE, KEY_F(10), KEY_F(22), KEY_F(34), KEY_F(46)},
+ {SDLK_F11, FALSE, KEY_F(11), KEY_F(23), KEY_F(35), KEY_F(47)},
+ {SDLK_F12, FALSE, KEY_F(12), KEY_F(24), KEY_F(36), KEY_F(48)},
+ {SDLK_F13, FALSE, KEY_F(13), KEY_F(25), KEY_F(37), KEY_F(49)},
+ {SDLK_F14, FALSE, KEY_F(14), KEY_F(26), KEY_F(38), KEY_F(50)},
+ {SDLK_F15, FALSE, KEY_F(15), KEY_F(27), KEY_F(39), KEY_F(51)},
+ {SDLK_BACKSPACE,FALSE, 0x08, 0x08, CTL_BKSP, ALT_BKSP},
+ {SDLK_TAB, FALSE, 0x09, KEY_BTAB, CTL_TAB, ALT_TAB},
+ {SDLK_PRINT, FALSE, KEY_PRINT, KEY_SPRINT, KEY_PRINT, KEY_PRINT},
+ {SDLK_PAUSE, FALSE, KEY_SUSPEND, KEY_SSUSPEND, KEY_SUSPEND, KEY_SUSPEND},
+ {SDLK_CLEAR, FALSE, KEY_CLEAR, KEY_CLEAR, KEY_CLEAR, KEY_CLEAR},
+ {SDLK_BREAK, FALSE, KEY_BREAK, KEY_BREAK, KEY_BREAK, KEY_BREAK},
+ {SDLK_HELP, FALSE, KEY_HELP, KEY_SHELP, KEY_LHELP, KEY_HELP},
+ {SDLK_MENU, FALSE, KEY_OPTIONS, KEY_SOPTIONS, KEY_OPTIONS, KEY_OPTIONS},
+ {SDLK_ESCAPE, FALSE, 0x1B, 0x1B, 0x1B, ALT_ESC},
+ {SDLK_KP_ENTER,TRUE, PADENTER, PADENTER, CTL_PADENTER,ALT_PADENTER},
+ {SDLK_KP_PLUS, TRUE, PADPLUS, '+', CTL_PADPLUS, ALT_PADPLUS},
+ {SDLK_KP_MINUS,TRUE, PADMINUS, '-', CTL_PADMINUS,ALT_PADMINUS},
+ {SDLK_KP_MULTIPLY,TRUE,PADSTAR, '*', CTL_PADSTAR, ALT_PADSTAR},
+ {SDLK_KP_DIVIDE,TRUE, PADSLASH, '/', CTL_PADSLASH,ALT_PADSLASH},
+ {SDLK_KP_PERIOD,TRUE, PADSTOP, '.', CTL_PADSTOP, ALT_PADSTOP},
+ {SDLK_KP0, TRUE, PAD0, '0', CTL_PAD0, ALT_PAD0},
+ {SDLK_KP1, TRUE, KEY_C1, '1', CTL_PAD1, ALT_PAD1},
+ {SDLK_KP2, TRUE, KEY_C2, '2', CTL_PAD2, ALT_PAD2},
+ {SDLK_KP3, TRUE, KEY_C3, '3', CTL_PAD3, ALT_PAD3},
+ {SDLK_KP4, TRUE, KEY_B1, '4', CTL_PAD4, ALT_PAD4},
+ {SDLK_KP5, TRUE, KEY_B2, '5', CTL_PAD5, ALT_PAD5},
+ {SDLK_KP6, TRUE, KEY_B3, '6', CTL_PAD6, ALT_PAD6},
+ {SDLK_KP7, TRUE, KEY_A1, '7', CTL_PAD7, ALT_PAD7},
+ {SDLK_KP8, TRUE, KEY_A2, '8', CTL_PAD8, ALT_PAD8},
+ {SDLK_KP9, TRUE, KEY_A3, '9', CTL_PAD9, ALT_PAD9},
+ {0, 0, 0, 0, 0, 0}
+};
+
+unsigned long PDC_get_input_fd(void)
+{
+ PDC_LOG(("PDC_get_input_fd() - called\n"));
+
+ return 0L; /* test this */
+}
+
+void PDC_set_keyboard_binary(bool on)
+{
+ PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
+}
+
+/* check if a key or mouse event is waiting */
+
+bool PDC_check_key(void)
+{
+ Uint32 current = SDL_GetTicks();
+ int haveevent = SDL_PollEvent(&event);
+
+ /* if we have an event, or 30 ms have passed without a screen
+ update, or the timer has wrapped, update now */
+
+ if (haveevent ||
+ current < pdc_lastupdate || ((current - pdc_lastupdate) > 30))
+ PDC_update_rects();
+
+ return haveevent;
+}
+
+static int _process_key_event(void)
+{
+ int i, key = 0;
+
+ pdc_key_modifiers = 0L;
+ SP->key_code = FALSE;
+
+ if (event.type == SDL_KEYUP)
+ {
+ if (SP->return_key_modifiers && event.key.keysym.sym == oldkey)
+ {
+ switch (oldkey)
+ {
+ case SDLK_RSHIFT:
+ return KEY_SHIFT_R;
+ case SDLK_LSHIFT:
+ return KEY_SHIFT_L;
+ case SDLK_RCTRL:
+ return KEY_CONTROL_R;
+ case SDLK_LCTRL:
+ return KEY_CONTROL_L;
+ case SDLK_RALT:
+ return KEY_ALT_R;
+ case SDLK_LALT:
+ return KEY_ALT_L;
+ default:
+ break;
+ }
+ }
+
+ return -1;
+ }
+
+ oldkey = event.key.keysym.sym;
+
+ if (SP->save_key_modifiers)
+ {
+ if (event.key.keysym.mod & KMOD_NUM)
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
+
+ if (event.key.keysym.mod & KMOD_SHIFT)
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
+
+ if (event.key.keysym.mod & KMOD_CTRL)
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
+
+ if (event.key.keysym.mod & KMOD_ALT)
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT;
+ }
+
+ for (i = 0; key_table[i].keycode; i++)
+ {
+ if (key_table[i].keycode == event.key.keysym.sym)
+ {
+ if ((event.key.keysym.mod & KMOD_SHIFT) ||
+ (key_table[i].numkeypad && (event.key.keysym.mod & KMOD_NUM)))
+ {
+ key = key_table[i].shifted;
+ }
+ else if (event.key.keysym.mod & KMOD_CTRL)
+ {
+ key = key_table[i].control;
+ }
+ else if (event.key.keysym.mod & KMOD_ALT)
+ {
+ key = key_table[i].alt;
+ }
+
+ /* To get here, we ignore all other modifiers */
+
+ else
+ key = key_table[i].normal;
+
+ SP->key_code = (key > 0x100);
+ break;
+ }
+ }
+
+ if (!key)
+ {
+ key = event.key.keysym.unicode;
+
+ if (key > 0x7f)
+ key = 0;
+ }
+
+ /* Handle ALT letters and numbers */
+
+ if (event.key.keysym.mod & KMOD_ALT)
+ {
+ if (key >= 'A' && key <= 'Z')
+ {
+ key += ALT_A - 'A';
+ SP->key_code = TRUE;
+ }
+
+ if (key >= 'a' && key <= 'z')
+ {
+ key += ALT_A - 'a';
+ SP->key_code = TRUE;
+ }
+
+ if (key >= '0' && key <= '9')
+ {
+ key += ALT_0 - '0';
+ SP->key_code = TRUE;
+ }
+ }
+
+ return key ? key : -1;
+}
+
+static int _process_mouse_event(void)
+{
+ SDLMod keymods;
+ short shift_flags = 0;
+
+ memset(&pdc_mouse_status, 0, sizeof(MOUSE_STATUS));
+
+ keymods = SDL_GetModState();
+
+ if (keymods & KMOD_SHIFT)
+ shift_flags |= BUTTON_SHIFT;
+
+ if (keymods & KMOD_CTRL)
+ shift_flags |= BUTTON_CONTROL;
+
+ if (keymods & KMOD_ALT)
+ shift_flags |= BUTTON_ALT;
+
+ if (event.type == SDL_MOUSEMOTION)
+ {
+ int i;
+
+ pdc_mouse_status.x = event.motion.x / pdc_fwidth;
+ pdc_mouse_status.y = event.motion.y / pdc_fheight;
+
+ if (!event.motion.state ||
+ (pdc_mouse_status.x == old_mouse_status.x &&
+ pdc_mouse_status.y == old_mouse_status.y))
+ return -1;
+
+ pdc_mouse_status.changes = PDC_MOUSE_MOVED;
+
+ for (i = 0; i < 3; i++)
+ {
+ if (event.motion.state & SDL_BUTTON(i + 1))
+ {
+ pdc_mouse_status.button[i] = BUTTON_MOVED | shift_flags;
+ pdc_mouse_status.changes |= (1 << i);
+ }
+ }
+ }
+ else
+ {
+ short action = (event.button.state == SDL_PRESSED) ?
+ BUTTON_PRESSED : BUTTON_RELEASED;
+ Uint8 btn = event.button.button;
+
+ /* handle scroll wheel */
+
+ if ((btn == 4 || btn == 5) && action == BUTTON_RELEASED)
+ {
+ pdc_mouse_status.x = pdc_mouse_status.y = -1;
+
+ pdc_mouse_status.changes = (btn == 5) ?
+ PDC_MOUSE_WHEEL_DOWN : PDC_MOUSE_WHEEL_UP;
+
+ return KEY_MOUSE;
+ }
+
+ if (btn < 1 || btn > 3)
+ return -1;
+
+ /* check for a click -- a press followed immediately by a release */
+
+ if (action == BUTTON_PRESSED && SP->mouse_wait)
+ {
+ SDL_Event rel;
+
+ napms(SP->mouse_wait);
+
+ if (SDL_PollEvent(&rel))
+ {
+ if (rel.type == SDL_MOUSEBUTTONUP && rel.button.button == btn)
+ action = BUTTON_CLICKED;
+ else
+ SDL_PushEvent(&rel);
+ }
+ }
+
+ pdc_mouse_status.x = event.button.x / pdc_fwidth;
+ pdc_mouse_status.y = event.button.y / pdc_fheight;
+
+ btn--;
+
+ pdc_mouse_status.button[btn] = action | shift_flags;
+ pdc_mouse_status.changes = (1 << btn);
+ }
+
+ old_mouse_status = pdc_mouse_status;
+
+ return KEY_MOUSE;
+}
+
+/* return the next available key or mouse event */
+
+int PDC_get_key(void)
+{
+ switch (event.type)
+ {
+ case SDL_QUIT:
+ exit(1);
+ case SDL_VIDEORESIZE:
+ if (pdc_own_screen &&
+ (event.resize.h / pdc_fheight != LINES ||
+ event.resize.w / pdc_fwidth != COLS))
+ {
+ pdc_sheight = event.resize.h;
+ pdc_swidth = event.resize.w;
+
+ if (!SP->resized)
+ {
+ SP->resized = TRUE;
+ return KEY_RESIZE;
+ }
+ }
+ break;
+ case SDL_MOUSEMOTION:
+ SDL_ShowCursor(SDL_ENABLE);
+ case SDL_MOUSEBUTTONUP:
+ case SDL_MOUSEBUTTONDOWN:
+ oldkey = SDLK_SPACE;
+ if (SP->_trap_mbe)
+ return _process_mouse_event();
+ break;
+ case SDL_KEYUP:
+ case SDL_KEYDOWN:
+ PDC_mouse_set();
+ return _process_key_event();
+ }
+
+ return -1;
+}
+
+/* discard any pending keyboard or mouse input -- this is the core
+ routine for flushinp() */
+
+void PDC_flushinp(void)
+{
+ PDC_LOG(("PDC_flushinp() - called\n"));
+
+ while (PDC_check_key());
+}
+
+int PDC_mouse_set(void)
+{
+ SDL_ShowCursor(SP->_trap_mbe ? SDL_ENABLE : SDL_DISABLE);
+
+ return OK;
+}
+
+int PDC_modifiers_set(void)
+{
+ return OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcscrn.c b/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcscrn.c
new file mode 100644
index 0000000000..e422b25cee
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcscrn.c
@@ -0,0 +1,295 @@
+/* Public Domain Curses */
+
+#include "pdcsdl.h"
+
+RCSID("$Id: pdcscrn.c,v 1.34 2008/07/14 04:24:52 wmcbrine Exp $")
+
+#include <stdlib.h>
+#include "deffont.h"
+#include "deficon.h"
+
+SDL_Surface *pdc_screen = NULL, *pdc_font = NULL, *pdc_icon = NULL,
+ *pdc_back = NULL, *pdc_tileback = NULL;
+int pdc_sheight = 0, pdc_swidth = 0, pdc_yoffset = 0, pdc_xoffset = 0;
+
+SDL_Color pdc_color[16];
+Uint32 pdc_mapped[16];
+int pdc_fheight, pdc_fwidth, pdc_flastc;
+bool pdc_own_screen;
+
+/* COLOR_PAIR to attribute encoding table. */
+
+static struct {short f, b;} atrtab[PDC_COLOR_PAIRS];
+
+void PDC_retile(void)
+{
+ if (pdc_tileback)
+ SDL_FreeSurface(pdc_tileback);
+
+ pdc_tileback = SDL_DisplayFormat(pdc_screen);
+
+ if (pdc_back)
+ {
+ SDL_Rect dest;
+
+ dest.y = 0;
+
+ while (dest.y < pdc_tileback->h)
+ {
+ dest.x = 0;
+
+ while (dest.x < pdc_tileback->w)
+ {
+ SDL_BlitSurface(pdc_back, 0, pdc_tileback, &dest);
+ dest.x += pdc_back->w;
+ }
+
+ dest.y += pdc_back->h;
+ }
+
+ SDL_BlitSurface(pdc_tileback, 0, pdc_screen, 0);
+ }
+}
+
+void PDC_scr_close(void)
+{
+ PDC_LOG(("PDC_scr_close() - called\n"));
+}
+
+void PDC_scr_free(void)
+{
+ if (SP)
+ free(SP);
+}
+
+/* open the physical screen -- allocate SP, miscellaneous intialization */
+
+int PDC_scr_open(int argc, char **argv)
+{
+ int i;
+
+ PDC_LOG(("PDC_scr_open() - called\n"));
+
+ SP = calloc(1, sizeof(SCREEN));
+
+ if (!SP)
+ return ERR;
+
+ pdc_own_screen = !pdc_screen;
+
+ if (pdc_own_screen)
+ {
+ if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) < 0)
+ {
+ fprintf(stderr, "Could not start SDL: %s\n", SDL_GetError());
+ return ERR;
+ }
+
+ atexit(SDL_Quit);
+ }
+
+ if (!pdc_font)
+ {
+ const char *fname = getenv("PDC_FONT");
+ pdc_font = SDL_LoadBMP(fname ? fname : "pdcfont.bmp");
+ }
+
+ if (!pdc_font)
+ pdc_font = SDL_LoadBMP_RW(SDL_RWFromMem(deffont, sizeof(deffont)), 0);
+
+ if (!pdc_font)
+ {
+ fprintf(stderr, "Could not load font\n");
+ return ERR;
+ }
+
+ SP->mono = !pdc_font->format->palette;
+
+ if (!SP->mono && !pdc_back)
+ {
+ const char *bname = getenv("PDC_BACKGROUND");
+ pdc_back = SDL_LoadBMP(bname ? bname : "pdcback.bmp");
+ }
+
+ if (!SP->mono && (pdc_back || !pdc_own_screen))
+ {
+ SP->orig_attr = TRUE;
+ SP->orig_fore = COLOR_WHITE;
+ SP->orig_back = -1;
+ }
+ else
+ SP->orig_attr = FALSE;
+
+ pdc_fheight = pdc_font->h / 8;
+ pdc_fwidth = pdc_font->w / 32;
+
+ if (!SP->mono)
+ pdc_flastc = pdc_font->format->palette->ncolors - 1;
+
+ if (pdc_own_screen && !pdc_icon)
+ {
+ const char *iname = getenv("PDC_ICON");
+ pdc_icon = SDL_LoadBMP(iname ? iname : "pdcicon.bmp");
+
+ if (!pdc_icon)
+ pdc_icon = SDL_LoadBMP_RW(SDL_RWFromMem(deficon,
+ sizeof(deficon)), 0);
+
+ if (pdc_icon)
+ SDL_WM_SetIcon(pdc_icon, NULL);
+ }
+
+ if (pdc_own_screen)
+ {
+ const char *env = getenv("PDC_LINES");
+ pdc_sheight = (env ? atoi(env) : 25) * pdc_fheight;
+
+ env = getenv("PDC_COLS");
+ pdc_swidth = (env ? atoi(env) : 80) * pdc_fwidth;
+
+ pdc_screen = SDL_SetVideoMode(pdc_swidth, pdc_sheight, 0,
+ SDL_SWSURFACE|SDL_ANYFORMAT|SDL_RESIZABLE);
+ }
+ else
+ {
+ if (!pdc_sheight)
+ pdc_sheight = pdc_screen->h - pdc_yoffset;
+
+ if (!pdc_swidth)
+ pdc_swidth = pdc_screen->w - pdc_xoffset;
+ }
+
+ if (!pdc_screen)
+ {
+ fprintf(stderr, "Couldn't create a surface: %s\n", SDL_GetError());
+ return ERR;
+ }
+
+ if (SP->orig_attr)
+ PDC_retile();
+
+ for (i = 0; i < 8; i++)
+ {
+ pdc_color[i].r = (i & COLOR_RED) ? 0xc0 : 0;
+ pdc_color[i].g = (i & COLOR_GREEN) ? 0xc0 : 0;
+ pdc_color[i].b = (i & COLOR_BLUE) ? 0xc0 : 0;
+
+ pdc_color[i + 8].r = (i & COLOR_RED) ? 0xff : 0x40;
+ pdc_color[i + 8].g = (i & COLOR_GREEN) ? 0xff : 0x40;
+ pdc_color[i + 8].b = (i & COLOR_BLUE) ? 0xff : 0x40;
+ }
+
+ for (i = 0; i < 16; i++)
+ pdc_mapped[i] = SDL_MapRGB(pdc_screen->format, pdc_color[i].r,
+ pdc_color[i].g, pdc_color[i].b);
+
+ SDL_EnableUNICODE(1);
+
+ PDC_mouse_set();
+
+ if (pdc_own_screen)
+ PDC_set_title(argc ? argv[0] : "PDCurses");
+
+ SP->lines = PDC_get_rows();
+ SP->cols = PDC_get_columns();
+
+ SP->mouse_wait = PDC_CLICK_PERIOD;
+ SP->audible = FALSE;
+
+ PDC_reset_prog_mode();
+
+ return OK;
+}
+
+/* the core of resize_term() */
+
+int PDC_resize_screen(int nlines, int ncols)
+{
+ if (!pdc_own_screen)
+ return ERR;
+
+ if (nlines && ncols)
+ {
+ pdc_sheight = nlines * pdc_fheight;
+ pdc_swidth = ncols * pdc_fwidth;
+ }
+
+ SDL_FreeSurface(pdc_screen);
+
+ pdc_screen = SDL_SetVideoMode(pdc_swidth, pdc_sheight, 0,
+ SDL_SWSURFACE|SDL_ANYFORMAT|SDL_RESIZABLE);
+
+ if (pdc_tileback)
+ PDC_retile();
+
+ SP->resized = FALSE;
+ SP->cursrow = SP->curscol = 0;
+
+ return OK;
+}
+
+void PDC_reset_prog_mode(void)
+{
+ PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
+
+ PDC_flushinp();
+ SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
+}
+
+void PDC_reset_shell_mode(void)
+{
+ PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
+
+ SDL_EnableKeyRepeat(0, 0);
+ PDC_flushinp();
+}
+
+void PDC_restore_screen_mode(int i)
+{
+}
+
+void PDC_save_screen_mode(int i)
+{
+}
+
+void PDC_init_pair(short pair, short fg, short bg)
+{
+ atrtab[pair].f = fg;
+ atrtab[pair].b = bg;
+}
+
+int PDC_pair_content(short pair, short *fg, short *bg)
+{
+ *fg = atrtab[pair].f;
+ *bg = atrtab[pair].b;
+
+ return OK;
+}
+
+bool PDC_can_change_color(void)
+{
+ return TRUE;
+}
+
+int PDC_color_content(short color, short *red, short *green, short *blue)
+{
+ *red = DIVROUND(pdc_color[color].r * 1000, 255);
+ *green = DIVROUND(pdc_color[color].g * 1000, 255);
+ *blue = DIVROUND(pdc_color[color].b * 1000, 255);
+
+ return OK;
+}
+
+int PDC_init_color(short color, short red, short green, short blue)
+{
+ pdc_color[color].r = DIVROUND(red * 255, 1000);
+ pdc_color[color].g = DIVROUND(green * 255, 1000);
+ pdc_color[color].b = DIVROUND(blue * 255, 1000);
+
+ pdc_mapped[color] = SDL_MapRGB(pdc_screen->format, pdc_color[color].r,
+ pdc_color[color].g, pdc_color[color].b);
+
+ wrefresh(curscr);
+
+ return OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcsdl.h b/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcsdl.h
new file mode 100644
index 0000000000..79df21a52d
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcsdl.h
@@ -0,0 +1,26 @@
+/* Public Domain Curses */
+
+/* $Id: pdcsdl.h,v 1.17 2008/07/14 04:24:52 wmcbrine Exp $ */
+
+#include <curspriv.h>
+
+#include <SDL/SDL.h>
+
+PDCEX SDL_Surface *pdc_screen, *pdc_font, *pdc_icon, *pdc_back;
+PDCEX int pdc_sheight, pdc_swidth, pdc_yoffset, pdc_xoffset;
+
+extern SDL_Surface *pdc_tileback; /* used to regenerate the background
+ of "transparent" cells */
+extern SDL_Color pdc_color[16]; /* colors for font palette */
+extern Uint32 pdc_mapped[16]; /* colors for FillRect(), as
+ used in _highlight() */
+extern int pdc_fheight, pdc_fwidth; /* font height and width */
+extern int pdc_flastc; /* font palette's last color
+ (treated as the foreground) */
+extern bool pdc_own_screen; /* if pdc_screen was not set
+ before initscr(), PDCurses is
+ responsible for (owns) it */
+extern Uint32 pdc_lastupdate; /* time of last update, in ticks */
+
+void PDC_update_rects(void);
+void PDC_retile(void);
diff --git a/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcsetsc.c b/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcsetsc.c
new file mode 100644
index 0000000000..0df97ab744
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcsetsc.c
@@ -0,0 +1,62 @@
+/* Public Domain Curses */
+
+#include "pdcsdl.h"
+
+RCSID("$Id: pdcsetsc.c,v 1.7 2008/07/14 04:24:52 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: pdcsetsc
+
+ Synopsis:
+ int PDC_set_blink(bool blinkon);
+ void PDC_set_title(const char *title);
+
+ Description:
+ PDC_set_blink() toggles whether the A_BLINK attribute sets an
+ actual blink mode (TRUE), or sets the background color to high
+ intensity (FALSE). The default is platform-dependent (FALSE in
+ most cases). It returns OK if it could set the state to match
+ the given parameter, ERR otherwise. Current platforms also
+ adjust the value of COLORS according to this function -- 16 for
+ FALSE, and 8 for TRUE.
+
+ PDC_set_title() sets the title of the window in which the curses
+ program is running. This function may not do anything on some
+ platforms. (Currently it only works in Win32 and X11.)
+
+ Portability X/Open BSD SYS V
+ PDC_set_blink - - -
+ PDC_set_title - - -
+
+**man-end****************************************************************/
+
+int PDC_curs_set(int visibility)
+{
+ int ret_vis;
+
+ PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
+
+ ret_vis = SP->visibility;
+
+ SP->visibility = visibility;
+
+ PDC_gotoyx(SP->cursrow, SP->curscol);
+
+ return ret_vis;
+}
+
+void PDC_set_title(const char *title)
+{
+ PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
+
+ SDL_WM_SetCaption(title, title);
+}
+
+int PDC_set_blink(bool blinkon)
+{
+ if (pdc_color_started)
+ COLORS = 16;
+
+ return blinkon ? ERR : OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcutil.c b/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcutil.c
new file mode 100644
index 0000000000..b2d84045ff
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/sdl1/pdcutil.c
@@ -0,0 +1,23 @@
+/* Public Domain Curses */
+
+#include "pdcsdl.h"
+
+RCSID("$Id: pdcutil.c,v 1.6 2008/07/14 04:24:52 wmcbrine Exp $")
+
+void PDC_beep(void)
+{
+ PDC_LOG(("PDC_beep() - called\n"));
+}
+
+void PDC_napms(int ms)
+{
+ PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
+
+ PDC_update_rects();
+ SDL_Delay(ms);
+}
+
+const char *PDC_sysname(void)
+{
+ return "SDL";
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/sdl1/sdltest.c b/payloads/libpayload/curses/PDCurses-3.4/sdl1/sdltest.c
new file mode 100644
index 0000000000..d39533b303
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/sdl1/sdltest.c
@@ -0,0 +1,81 @@
+/* Here's a simple example of combining SDL and PDCurses functionality.
+ The top portion of the window is devoted to SDL, with a four-line
+ (assuming the default 8x16 font) stdscr at the bottom.
+
+ $Id: sdltest.c,v 1.2 2008/07/14 04:24:52 wmcbrine Exp $
+*/
+
+#include <SDL/SDL.h>
+#include <curses.h>
+#include <stdlib.h>
+#include <time.h>
+
+/* You could #include pdcsdl.h, or just add the relevant declarations
+ here: */
+
+PDCEX SDL_Surface *pdc_screen;
+PDCEX int pdc_yoffset;
+
+int main(int argc, char **argv)
+{
+ char inp[60];
+ int i, j, seed;
+
+ seed = time((time_t *)0);
+ srand(seed);
+
+ /* Initialize SDL */
+
+ if (SDL_Init(SDL_INIT_VIDEO) < 0)
+ exit(1);
+
+ atexit(SDL_Quit);
+
+ pdc_screen = SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE|SDL_ANYFORMAT);
+
+ /* Initialize PDCurses */
+
+ pdc_yoffset = 416; /* 480 - 4 * 16 */
+
+ initscr();
+ start_color();
+ scrollok(stdscr, TRUE);
+
+ PDC_set_title("PDCurses for SDL");
+
+ /* Do some SDL stuff */
+
+ for (i = 640, j = 416; j; i -= 2, j -= 2)
+ {
+ SDL_Rect dest;
+
+ dest.x = (640 - i) / 2;
+ dest.y = (416 - j) / 2;
+ dest.w = i;
+ dest.h = j;
+
+ SDL_FillRect(pdc_screen, &dest,
+ SDL_MapRGB(pdc_screen->format, rand() % 256,
+ rand() % 256, rand() % 256));
+ }
+
+ SDL_UpdateRect(pdc_screen, 0, 0, 640, 416);
+
+ /* Do some curses stuff */
+
+ init_pair(1, COLOR_WHITE + 8, COLOR_BLUE);
+ bkgd(COLOR_PAIR(1));
+
+ addstr("This is a demo of ");
+ attron(A_UNDERLINE);
+ addstr("PDCurses for SDL");
+ attroff(A_UNDERLINE);
+ addstr(".\nYour comments here: ");
+ getnstr(inp, 59);
+ addstr("Press any key to exit.");
+
+ getch();
+ endwin();
+
+ return 0;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/term.h b/payloads/libpayload/curses/PDCurses-3.4/term.h
new file mode 100644
index 0000000000..ce6bc4fae6
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/term.h
@@ -0,0 +1,57 @@
+/* Public Domain Curses */
+
+/* $Id: term.h,v 1.16 2008/07/13 16:08:16 wmcbrine Exp $ */
+
+/* PDCurses doesn't operate with terminfo, but we need these functions for
+ compatibility, to allow some things (notably, interface libraries for
+ other languages) to be compiled. Anyone who tries to actually _use_
+ them will be disappointed, since they only return ERR. */
+
+#ifndef __PDCURSES_TERM_H__
+#define __PDCURSES_TERM_H__ 1
+
+#include <curses.h>
+
+#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
+extern "C"
+{
+#endif
+
+typedef struct
+{
+ const char *_termname;
+} TERMINAL;
+
+#ifdef PDC_DLL_BUILD
+# ifndef CURSES_LIBRARY
+__declspec(dllimport) TERMINAL *cur_term;
+# else
+__declspec(dllexport) extern TERMINAL *cur_term;
+# endif
+#else
+extern TERMINAL *cur_term;
+#endif
+
+int del_curterm(TERMINAL *);
+int putp(const char *);
+int restartterm(const char *, int, int *);
+TERMINAL *set_curterm(TERMINAL *);
+int setterm(const char *);
+int setupterm(const char *, int, int *);
+int tgetent(char *, const char *);
+int tgetflag(const char *);
+int tgetnum(const char *);
+char *tgetstr(const char *, char **);
+char *tgoto(const char *, int, int);
+int tigetflag(const char *);
+int tigetnum(const char *);
+char *tigetstr(const char *);
+char *tparm(const char *, long, long, long, long, long,
+ long, long, long, long);
+int tputs(const char *, int, int (*)(int));
+
+#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
+}
+#endif
+
+#endif /* __PDCURSES_TERM_H__ */
diff --git a/payloads/libpayload/curses/PDCurses-3.4/version.mif b/payloads/libpayload/curses/PDCurses-3.4/version.mif
new file mode 100644
index 0000000000..9ff7335b41
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/version.mif
@@ -0,0 +1,4 @@
+# Version number macros for inclusion from makefiles
+
+VER = 34
+VERDOT = 3.4
diff --git a/payloads/libpayload/curses/PDCurses-3.4/watcom.mif b/payloads/libpayload/curses/PDCurses-3.4/watcom.mif
new file mode 100644
index 0000000000..023ea37e36
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/watcom.mif
@@ -0,0 +1,59 @@
+# Common elements for the Watcom makefiles
+
+srcdir = $(PDCURSES_SRCDIR)\pdcurses
+demodir = $(PDCURSES_SRCDIR)\demos
+
+LIBOBJS = addch.obj addchstr.obj addstr.obj attr.obj beep.obj bkgd.obj &
+border.obj clear.obj color.obj delch.obj deleteln.obj deprec.obj &
+getch.obj getstr.obj getyx.obj inch.obj inchstr.obj initscr.obj inopts.obj &
+insch.obj insstr.obj instr.obj kernel.obj keyname.obj mouse.obj move.obj &
+outopts.obj overlay.obj pad.obj panel.obj printw.obj refresh.obj &
+scanw.obj scr_dump.obj scroll.obj slk.obj termattr.obj terminfo.obj &
+touch.obj util.obj window.obj debug.obj
+
+PDCOBJS = pdcclip.obj pdcdisp.obj pdcgetsc.obj pdckbd.obj pdcscrn.obj &
+pdcsetsc.obj pdcutil.obj
+
+DEMOS = testcurs.exe newdemo.exe xmas.exe tuidemo.exe firework.exe &
+ptest.exe rain.exe worm.exe
+
+LIBCURSES = pdcurses.lib
+
+LINK = wlink
+
+!ifdef __LOADDLL__
+! loaddll wcc wccd
+! loaddll wcc386 wccd386
+! loaddll wlink wlink
+! loaddll wlib wlibd
+!endif
+
+all: $(LIBCURSES) $(DEMOS)
+
+clean
+ -del *.obj
+ -del *.lib
+ -del *.exe
+ -del *.err
+
+demos: $(DEMOS)
+
+.c: $(srcdir);$(osdir);$(demodir)
+.c.obj: .autodepend
+ $(CC) $(CFLAGS) $<
+
+.obj.exe:
+ $(LINK) $(LDFLAGS) n $@ f $*.obj l $(LIBCURSES)
+
+testcurs.exe: testcurs.obj $(LIBCURSES)
+newdemo.exe: newdemo.obj $(LIBCURSES)
+xmas.exe: xmas.obj $(LIBCURSES)
+firework.exe: firework.obj $(LIBCURSES)
+rain.exe: rain.obj $(LIBCURSES)
+worm.exe: worm.obj $(LIBCURSES)
+ptest.exe: ptest.obj $(LIBCURSES)
+
+tuidemo.exe: tuidemo.obj tui.obj $(LIBCURSES)
+ $(LINK) $(LDFLAGS) n $@ f tuidemo.obj f tui.obj l $(LIBCURSES)
+
+dist: .symbolic
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/README b/payloads/libpayload/curses/PDCurses-3.4/win32/README
new file mode 100644
index 0000000000..bfe2ad957f
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/README
@@ -0,0 +1,76 @@
+PDCurses for Win32
+==================
+
+This directory contains PDCurses source code files specific to Win32
+console mode (Win9x/Me/NT/2k/XP/Vista).
+
+
+Building
+--------
+
+. Choose the appropriate makefile for your compiler:
+
+ bccwin32.mak - Borland C++ 4.0.2+
+ dmcwin32.mak - Digital Mars
+ gccwin32.mak - Cygnus GNU Compiler
+ lccwin32.mak - LCC-Win32
+ mingwin32.mak - MinGW
+ vcwin32.mak - Microsoft Visual C++ 2.0+
+ wccwin32.mak - Watcom 10.6+
+
+. Optionally, you can build in a different directory than the platform
+ directory by setting PDCURSES_SRCDIR to point to the directory where
+ you unpacked PDCurses, and changing to your target directory:
+
+ set PDCURSES_SRCDIR=c:\pdcurses
+
+ This won't work with the LCC or Digital Mars makefiles, nor will the
+ options described below.
+
+. Build it:
+
+ make -f makefilename
+
+ (For Watcom, use "wmake" instead of "make"; for MSVC, "nmake".) You'll
+ get the libraries (pdcurses.lib or .a, depending on your compiler; and
+ panel.lib or .a), the demos (*.exe), and a lot of object files. Note
+ that the panel library is just a copy of the main library, provided
+ for convenience; both panel and curses functions are in the main
+ library.
+
+ You can also give the optional parameter "WIDE=Y", to build the
+ library with wide-character (Unicode) support:
+
+ make -f mingwin32.mak WIDE=Y
+
+ When built this way, the library is not compatible with Windows 9x,
+ unless you also link with the Microsoft Layer for Unicode (not
+ tested).
+
+ Another option, "UTF8=Y", makes PDCurses ignore the system locale, and
+ treat all narrow-character strings as UTF-8. This option has no effect
+ unless WIDE=Y is also set. Use it to get around the poor support for
+ UTF-8 in the Win32 console:
+
+ make -f mingwin32.mak WIDE=Y UTF8=Y
+
+ You can also use the optional parameter "DLL=Y" with Visual C++,
+ MinGW or Cygwin, to build the library as a DLL:
+
+ nmake -f vcwin32.mak WIDE=Y DLL=Y
+
+ When you build the library as a Windows DLL, you must always define
+ PDCURSES_DLL_BUILD when linking against it. (Or, if you only want to
+ use the DLL, you could add this definition to your curses.h.)
+
+
+Distribution Status
+-------------------
+
+The files in this directory are released to the Public Domain.
+
+
+Acknowledgements
+----------------
+
+Generic Win32 port was provided by Chris Szurgot <szurgot@itribe.net>
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/bccwin32.mak b/payloads/libpayload/curses/PDCurses-3.4/win32/bccwin32.mak
new file mode 100644
index 0000000000..229ab4be5c
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/bccwin32.mak
@@ -0,0 +1,85 @@
+# Borland MAKE Makefile for PDCurses library - Win32 BC++ 4.0+
+#
+# Usage: make -f [path\]bccwin32.mak [DEBUG=] [WIDE=] [UTF8=] [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.lib|testcurs.exe...]
+
+O = obj
+
+!ifndef PDCURSES_SRCDIR
+PDCURSES_SRCDIR = ..
+!endif
+
+!include $(PDCURSES_SRCDIR)\version.mif
+!include $(PDCURSES_SRCDIR)\libobjs.mif
+
+osdir = $(PDCURSES_SRCDIR)\win32
+
+CC = bcc32 -q
+
+!ifdef DEBUG
+CFLAGS = -N -v -y -DPDCDEBUG
+!else
+CFLAGS = -O
+!endif
+
+!ifdef WIDE
+WIDEOPT = -DPDC_WIDE
+!endif
+
+!ifdef UTF8
+UTF8OPT = -DPDC_FORCE_UTF8
+!endif
+
+BUILD = $(CC) -I$(PDCURSES_SRCDIR) -c -Tpe -w32 $(CFLAGS) -w-par \
+$(WIDEOPT) $(UTF8OPT)
+
+LIBEXE = tlib /C /E /0 /a
+
+LIBCURSES = pdcurses.lib
+
+all: $(LIBCURSES) $(DEMOS)
+
+clean:
+ -del *.obj
+ -del *.lib
+ -del *.tds
+ -del *.exe
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ -del $@
+ $(LIBEXE) $@ $(LIBOBJS) $(PDCOBJS)
+ -copy $(LIBCURSES) panel.lib
+
+.autodepend
+
+{$(srcdir)\}.c.obj:
+ $(BUILD) $<
+
+{$(osdir)\}.c.obj:
+ $(BUILD) $<
+
+{$(demodir)\}.c.obj:
+ $(BUILD) $<
+
+.c.obj:
+ $(BUILD) $<
+
+.obj.exe:
+ $(CC) -e$@ $** $(LIBCURSES)
+
+tuidemo.exe: tuidemo.obj tui.obj $(LIBCURSES)
+ $(CC) -e$@ $**
+
+tui.obj: $(demodir)\tui.c $(demodir)\tui.h $(PDCURSES_CURSES_H)
+ $(BUILD) -I$(demodir) $(demodir)\tui.c
+
+tuidemo.obj: $(demodir)\tuidemo.c $(PDCURSES_CURSES_H)
+ $(BUILD) -I$(demodir) $(demodir)\tuidemo.c
+
+PLATFORM1 = Borland C++ Win32
+PLATFORM2 = Borland C/C++ 5.5 for Win32
+ARCNAME = pdc$(VER)_bcc_w32
+
+!include $(PDCURSES_SRCDIR)\makedist.mif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/dmcwin32.mak b/payloads/libpayload/curses/PDCurses-3.4/win32/dmcwin32.mak
new file mode 100644
index 0000000000..23522cc94f
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/dmcwin32.mak
@@ -0,0 +1,253 @@
+# Makefile for PDCurses library - WIN32 Digital Mars
+#
+# Usage: make -f dmcwin32.mak [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.lib|testcurs.exe...]
+
+PDCURSES_SRCDIR = ..
+
+PDCURSES_CURSES_H = $(PDCURSES_SRCDIR)\curses.h
+PDCURSES_CURSPRIV_H = $(PDCURSES_SRCDIR)\curspriv.h
+PDCURSES_HEADERS = $(PDCURSES_CURSES_H) $(PDCURSES_CURSPRIV_H)
+
+PANEL_HEADER = $(PDCURSES_SRCDIR)\panel.h
+TERM_HEADER = $(PDCURSES_SRCDIR)\term.h
+
+srcdir = $(PDCURSES_SRCDIR)\pdcurses
+osdir = $(PDCURSES_SRCDIR)\win32
+demodir = $(PDCURSES_SRCDIR)\demos
+
+PDCURSES_WIN_H = $(osdir)\pdcwin.h
+
+CC = dmc
+
+CFLAGS = -c -o+space -Nc
+
+CPPFLAGS = -I$(PDCURSES_SRCDIR) #-DPDC_WIDE -DPDC_FORCE_UTF8
+
+LINK = dmc
+LIBEXE = lib
+
+LIBCURSES = pdcurses.lib
+
+BUILD = $(CC) $(CFLAGS) $(CPPFLAGS)
+
+DEMOS = testcurs.exe newdemo.exe xmas.exe tuidemo.exe \
+firework.exe ptest.exe rain.exe worm.exe
+
+all: $(LIBCURSES) $(DEMOS)
+
+clean:
+ -del *.obj
+ -del *.lib
+ -del *.exe
+ -del *.map
+ -del advapi32.def
+
+LIBOBJS = addch.obj addchstr.obj addstr.obj attr.obj beep.obj bkgd.obj \
+border.obj clear.obj color.obj delch.obj deleteln.obj deprec.obj getch.obj \
+getstr.obj getyx.obj inch.obj inchstr.obj initscr.obj inopts.obj \
+insch.obj insstr.obj instr.obj kernel.obj keyname.obj mouse.obj move.obj \
+outopts.obj overlay.obj pad.obj panel.obj printw.obj refresh.obj \
+scanw.obj scr_dump.obj scroll.obj slk.obj termattr.obj terminfo.obj \
+touch.obj util.obj window.obj debug.obj
+
+PDCOBJS = pdcclip.obj pdcdisp.obj pdcgetsc.obj pdckbd.obj pdcscrn.obj \
+pdcsetsc.obj pdcutil.obj
+
+DEMOOBJS = testcurs.obj newdemo.obj xmas.obj tuidemo.obj tui.obj \
+firework.obj ptest.obj rain.obj worm.obj
+
+$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
+$(PDCOBJS) : $(PDCURSES_WIN_H)
+panel.obj ptest.obj: $(PANEL_HEADER)
+terminfo.obj: $(TERM_HEADER)
+
+$(DEMOOBJS) : $(PDCURSES_CURSES_H)
+$(DEMOS) : $(LIBCURSES)
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ $(LIBEXE) -c $@ $(LIBOBJS) $(PDCOBJS)
+ -copy $(LIBCURSES) panel.lib
+
+SRCBUILD = $(BUILD) $(srcdir)\$*.c
+OSBUILD = $(BUILD) $(osdir)\$*.c
+DEMOBUILD = $(LINK) $(CPPFLAGS) -o+space $@ $**
+
+addch.obj: $(srcdir)\addch.c
+ $(SRCBUILD)
+
+addchstr.obj: $(srcdir)\addchstr.c
+ $(SRCBUILD)
+
+addstr.obj: $(srcdir)\addstr.c
+ $(SRCBUILD)
+
+attr.obj: $(srcdir)\attr.c
+ $(SRCBUILD)
+
+beep.obj: $(srcdir)\beep.c
+ $(SRCBUILD)
+
+bkgd.obj: $(srcdir)\bkgd.c
+ $(SRCBUILD)
+
+border.obj: $(srcdir)\border.c
+ $(SRCBUILD)
+
+clear.obj: $(srcdir)\clear.c
+ $(SRCBUILD)
+
+color.obj: $(srcdir)\color.c
+ $(SRCBUILD)
+
+delch.obj: $(srcdir)\delch.c
+ $(SRCBUILD)
+
+deleteln.obj: $(srcdir)\deleteln.c
+ $(SRCBUILD)
+
+deprec.obj: $(srcdir)\deprec.c
+ $(SRCBUILD)
+
+getch.obj: $(srcdir)\getch.c
+ $(SRCBUILD)
+
+getstr.obj: $(srcdir)\getstr.c
+ $(SRCBUILD)
+
+getyx.obj: $(srcdir)\getyx.c
+ $(SRCBUILD)
+
+inch.obj: $(srcdir)\inch.c
+ $(SRCBUILD)
+
+inchstr.obj: $(srcdir)\inchstr.c
+ $(SRCBUILD)
+
+initscr.obj: $(srcdir)\initscr.c
+ $(SRCBUILD)
+
+inopts.obj: $(srcdir)\inopts.c
+ $(SRCBUILD)
+
+insch.obj: $(srcdir)\insch.c
+ $(SRCBUILD)
+
+insstr.obj: $(srcdir)\insstr.c
+ $(SRCBUILD)
+
+instr.obj: $(srcdir)\instr.c
+ $(SRCBUILD)
+
+kernel.obj: $(srcdir)\kernel.c
+ $(SRCBUILD)
+
+keyname.obj: $(srcdir)\keyname.c
+ $(SRCBUILD)
+
+mouse.obj: $(srcdir)\mouse.c
+ $(SRCBUILD)
+
+move.obj: $(srcdir)\move.c
+ $(SRCBUILD)
+
+outopts.obj: $(srcdir)\outopts.c
+ $(SRCBUILD)
+
+overlay.obj: $(srcdir)\overlay.c
+ $(SRCBUILD)
+
+pad.obj: $(srcdir)\pad.c
+ $(SRCBUILD)
+
+panel.obj: $(srcdir)\panel.c
+ $(SRCBUILD)
+
+printw.obj: $(srcdir)\printw.c
+ $(SRCBUILD)
+
+refresh.obj: $(srcdir)\refresh.c
+ $(SRCBUILD)
+
+scanw.obj: $(srcdir)\scanw.c
+ $(SRCBUILD)
+
+scr_dump.obj: $(srcdir)\scr_dump.c
+ $(SRCBUILD)
+
+scroll.obj: $(srcdir)\scroll.c
+ $(SRCBUILD)
+
+slk.obj: $(srcdir)\slk.c
+ $(SRCBUILD)
+
+termattr.obj: $(srcdir)\termattr.c
+ $(SRCBUILD)
+
+terminfo.obj: $(srcdir)\terminfo.c
+ $(SRCBUILD)
+
+touch.obj: $(srcdir)\touch.c
+ $(SRCBUILD)
+
+util.obj: $(srcdir)\util.c
+ $(SRCBUILD)
+
+window.obj: $(srcdir)\window.c
+ $(SRCBUILD)
+
+debug.obj: $(srcdir)\debug.c
+ $(SRCBUILD)
+
+pdcclip.obj: $(osdir)\pdcclip.c
+ $(OSBUILD)
+
+pdcdisp.obj: $(osdir)\pdcdisp.c
+ $(OSBUILD)
+
+pdcgetsc.obj: $(osdir)\pdcgetsc.c
+ $(OSBUILD)
+
+pdckbd.obj: $(osdir)\pdckbd.c
+ $(OSBUILD)
+
+pdcscrn.obj: $(osdir)\pdcscrn.c
+ $(OSBUILD)
+
+pdcsetsc.obj: $(osdir)\pdcsetsc.c
+ $(OSBUILD)
+
+pdcutil.obj: $(osdir)\pdcutil.c
+ $(OSBUILD)
+
+firework.exe: $(demodir)\firework.c
+ $(DEMOBUILD)
+
+newdemo.exe: $(demodir)\newdemo.c
+ $(DEMOBUILD)
+
+ptest.exe: $(demodir)\ptest.c
+ $(DEMOBUILD)
+
+rain.exe: $(demodir)\rain.c
+ $(DEMOBUILD)
+
+testcurs.exe: $(demodir)\testcurs.c
+ $(DEMOBUILD) advapi32.lib
+
+tuidemo.exe: tuidemo.obj tui.obj
+ $(DEMOBUILD)
+
+worm.exe: $(demodir)\worm.c
+ $(DEMOBUILD)
+
+xmas.exe: $(demodir)\xmas.c
+ $(DEMOBUILD)
+
+tui.obj: $(demodir)\tui.c $(demodir)\tui.h
+ $(BUILD) -I$(demodir) $(demodir)\$*.c
+
+tuidemo.obj: $(demodir)\tuidemo.c
+ $(BUILD) -I$(demodir) $(demodir)\$*.c
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/gccwin32.mak b/payloads/libpayload/curses/PDCurses-3.4/win32/gccwin32.mak
new file mode 100644
index 0000000000..7504bb34fa
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/gccwin32.mak
@@ -0,0 +1,128 @@
+# GNU MAKE Makefile for PDCurses library - WIN32 Cygnus GCC
+#
+# Usage: make -f [path\]gccwin32.mak [DEBUG=Y] [DLL=Y] [WIDE=Y] [UTF8=Y] [tgt]
+#
+# where tgt can be any of:
+# [all|demos|pdcurses.a|testcurs.exe...]
+
+O = o
+
+ifndef PDCURSES_SRCDIR
+ PDCURSES_SRCDIR = ..
+endif
+
+include $(PDCURSES_SRCDIR)/version.mif
+include $(PDCURSES_SRCDIR)/libobjs.mif
+
+osdir = $(PDCURSES_SRCDIR)/win32
+
+PDCURSES_WIN_H = $(osdir)/pdcwin.h
+
+CC = gcc
+
+ifeq ($(DEBUG),Y)
+ CFLAGS = -g -Wall -DPDCDEBUG
+ LDFLAGS = -g
+else
+ CFLAGS = -O2 -Wall
+ LDFLAGS =
+endif
+
+CFLAGS += -I$(PDCURSES_SRCDIR)
+
+BASEDEF = $(PDCURSES_SRCDIR)/exp-base.def
+WIDEDEF = $(PDCURSES_SRCDIR)/exp-wide.def
+
+DEFDEPS = $(BASEDEF)
+
+ifeq ($(WIDE),Y)
+ CFLAGS += -DPDC_WIDE
+ DEFDEPS += $(WIDEDEF)
+endif
+
+ifeq ($(UTF8),Y)
+ CFLAGS += -DPDC_FORCE_UTF8
+endif
+
+DEFFILE = pdcurses.def
+
+LINK = gcc
+
+ifeq ($(DLL),Y)
+ CFLAGS += -DPDC_DLL_BUILD
+ LIBEXE = gcc $(DEFFILE)
+ LIBFLAGS = -Wl,--out-implib,pdcurses.a -shared -o
+ LIBCURSES = pdcurses.dll
+ LIBDEPS = $(LIBOBJS) $(PDCOBJS) $(DEFFILE)
+ CLEAN = $(LIBCURSES) *.a $(DEFFILE)
+else
+ LIBEXE = ar
+ LIBFLAGS = rcv
+ LIBCURSES = pdcurses.a
+ LIBDEPS = $(LIBOBJS) $(PDCOBJS)
+ CLEAN = *.a
+endif
+
+.PHONY: all libs clean demos dist
+
+all: libs demos
+
+libs: $(LIBCURSES)
+
+clean:
+ -rm -f *.o
+ -rm -f *.exe
+ -rm -f $(CLEAN)
+
+demos: $(DEMOS)
+ strip *.exe
+
+$(DEFFILE): $(DEFDEPS)
+ echo LIBRARY pdcurses > $@
+ echo EXPORTS >> $@
+ cat $(BASEDEF) >> $@
+ifeq ($(WIDE),Y)
+ cat $(WIDEDEF) >> $@
+endif
+
+$(LIBCURSES) : $(LIBDEPS)
+ $(LIBEXE) $(LIBFLAGS) $@ $?
+ -cp pdcurses.a panel.a
+
+$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
+$(PDCOBJS) : $(PDCURSES_WIN_H)
+$(DEMOS) : $(PDCURSES_CURSES_H) $(LIBCURSES)
+panel.o : $(PANEL_HEADER)
+terminfo.o: $(TERM_HEADER)
+
+$(LIBOBJS) : %.o: $(srcdir)/%.c
+ $(CC) -c $(CFLAGS) $<
+
+$(PDCOBJS) : %.o: $(osdir)/%.c
+ $(CC) -c $(CFLAGS) $<
+
+firework.exe newdemo.exe rain.exe testcurs.exe worm.exe xmas.exe \
+ptest.exe: %.exe: $(demodir)/%.c
+ $(CC) $(CFLAGS) -o$@ $< $(LIBCURSES)
+
+tuidemo.exe: tuidemo.o tui.o
+ $(LINK) $(LDFLAGS) -o$@ tuidemo.o tui.o $(LIBCURSES)
+
+tui.o: $(demodir)/tui.c $(demodir)/tui.h $(PDCURSES_CURSES_H)
+ $(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<
+
+tuidemo.o: $(demodir)/tuidemo.c $(PDCURSES_CURSES_H)
+ $(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<
+
+dist: $(PDCLIBS)
+ echo PDCurses $(VERDOT) for Cygnus Win32 > file_id.diz
+ echo ------------------------------------------ >> file_id.diz
+ echo Public Domain Curses library for >> file_id.diz
+ echo Cygnus GCC for Win32. >> file_id.diz
+ echo Source available in PDCURS$(VER).ZIP >> file_id.diz
+ echo Public Domain. >> file_id.diz
+ zip -9jX pdc$(VER)_cyg_w32 \
+ $(PDCURSES_SRCDIR)/README $(PDCURSES_SRCDIR)/HISTORY \
+ $(PDCURSES_SRCDIR)/curses.h $(PDCURSES_SRCDIR)/panel.h \
+ $(LIBCURSES) $(LIBPANEL) file_id.diz
+ rm file_id.diz
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/lccwin32.mak b/payloads/libpayload/curses/PDCurses-3.4/win32/lccwin32.mak
new file mode 100644
index 0000000000..90c1c894d1
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/lccwin32.mak
@@ -0,0 +1,273 @@
+# Makefile for PDCurses library - WIN32 LCC-Win32
+#
+# Usage: make -f lccwin32.mak [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.lib|testcurs.exe...]
+
+PDCURSES_SRCDIR = ..
+
+PDCURSES_CURSES_H = $(PDCURSES_SRCDIR)\curses.h
+PDCURSES_CURSPRIV_H = $(PDCURSES_SRCDIR)\curspriv.h
+PDCURSES_HEADERS = $(PDCURSES_CURSES_H) $(PDCURSES_CURSPRIV_H)
+
+PANEL_HEADER = $(PDCURSES_SRCDIR)\panel.h
+TERM_HEADER = $(PDCURSES_SRCDIR)\term.h
+
+srcdir = $(PDCURSES_SRCDIR)\pdcurses
+osdir = $(PDCURSES_SRCDIR)\win32
+demodir = $(PDCURSES_SRCDIR)\demos
+
+PDCURSES_WIN_H = $(osdir)\pdcwin.h
+
+CC = lcc
+
+#CFLAGS = -c -g3 -A -ansic
+CFLAGS = -c -O -A -ansic
+
+CPPFLAGS = -I$(PDCURSES_SRCDIR) #-DPDC_WIDE -DPDC_FORCE_UTF8
+
+LINK = lcclnk
+LIBEXE = lcclib
+
+LIBCURSES = pdcurses.lib
+
+BUILD = $(CC) $(CFLAGS) $(CPPFLAGS)
+PDCLIBS = $(LIBCURSES)
+
+DEMOS = testcurs.exe newdemo.exe xmas.exe tuidemo.exe \
+firework.exe ptest.exe rain.exe worm.exe
+
+all: $(PDCLIBS) $(DEMOS)
+
+clean:
+ -del *.obj
+ -del *.lib
+ -del *.exe
+
+LIBOBJS = addch.obj addchstr.obj addstr.obj attr.obj beep.obj bkgd.obj \
+border.obj clear.obj color.obj delch.obj deleteln.obj deprec.obj getch.obj \
+getstr.obj getyx.obj inch.obj inchstr.obj initscr.obj inopts.obj \
+insch.obj insstr.obj instr.obj kernel.obj keyname.obj mouse.obj move.obj \
+outopts.obj overlay.obj pad.obj panel.obj printw.obj refresh.obj \
+scanw.obj scr_dump.obj scroll.obj slk.obj termattr.obj terminfo.obj \
+touch.obj util.obj window.obj debug.obj
+
+PDCOBJS = pdcclip.obj pdcdisp.obj pdcgetsc.obj pdckbd.obj pdcscrn.obj \
+pdcsetsc.obj pdcutil.obj
+
+DEMOOBJS = testcurs.obj newdemo.obj xmas.obj tuidemo.obj tui.obj \
+firework.obj ptest.obj rain.obj worm.obj
+
+$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
+$(PDCOBJS) : $(PDCURSES_WIN_H)
+panel.obj ptest.obj: $(PANEL_HEADER)
+terminfo.obj: $(TERM_HEADER)
+
+$(DEMOOBJS) : $(PDCURSES_CURSES_H)
+$(DEMOS) : $(LIBCURSES)
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ $(LIBEXE) /out:$@ $(LIBOBJS) $(PDCOBJS)
+ -copy $(LIBCURSES) panel.lib
+
+SRCBUILD = $(BUILD) $(srcdir)\$*.c
+OSBUILD = $(BUILD) $(osdir)\$*.c
+
+addch.obj: $(srcdir)\addch.c
+ $(SRCBUILD)
+
+addchstr.obj: $(srcdir)\addchstr.c
+ $(SRCBUILD)
+
+addstr.obj: $(srcdir)\addstr.c
+ $(SRCBUILD)
+
+attr.obj: $(srcdir)\attr.c
+ $(SRCBUILD)
+
+beep.obj: $(srcdir)\beep.c
+ $(SRCBUILD)
+
+bkgd.obj: $(srcdir)\bkgd.c
+ $(SRCBUILD)
+
+border.obj: $(srcdir)\border.c
+ $(SRCBUILD)
+
+clear.obj: $(srcdir)\clear.c
+ $(SRCBUILD)
+
+color.obj: $(srcdir)\color.c
+ $(SRCBUILD)
+
+delch.obj: $(srcdir)\delch.c
+ $(SRCBUILD)
+
+deleteln.obj: $(srcdir)\deleteln.c
+ $(SRCBUILD)
+
+deprec.obj: $(srcdir)\deprec.c
+ $(SRCBUILD)
+
+getch.obj: $(srcdir)\getch.c
+ $(SRCBUILD)
+
+getstr.obj: $(srcdir)\getstr.c
+ $(SRCBUILD)
+
+getyx.obj: $(srcdir)\getyx.c
+ $(SRCBUILD)
+
+inch.obj: $(srcdir)\inch.c
+ $(SRCBUILD)
+
+inchstr.obj: $(srcdir)\inchstr.c
+ $(SRCBUILD)
+
+initscr.obj: $(srcdir)\initscr.c
+ $(SRCBUILD)
+
+inopts.obj: $(srcdir)\inopts.c
+ $(SRCBUILD)
+
+insch.obj: $(srcdir)\insch.c
+ $(SRCBUILD)
+
+insstr.obj: $(srcdir)\insstr.c
+ $(SRCBUILD)
+
+instr.obj: $(srcdir)\instr.c
+ $(SRCBUILD)
+
+kernel.obj: $(srcdir)\kernel.c
+ $(SRCBUILD)
+
+keyname.obj: $(srcdir)\keyname.c
+ $(SRCBUILD)
+
+mouse.obj: $(srcdir)\mouse.c
+ $(SRCBUILD)
+
+move.obj: $(srcdir)\move.c
+ $(SRCBUILD)
+
+outopts.obj: $(srcdir)\outopts.c
+ $(SRCBUILD)
+
+overlay.obj: $(srcdir)\overlay.c
+ $(SRCBUILD)
+
+pad.obj: $(srcdir)\pad.c
+ $(SRCBUILD)
+
+panel.obj: $(srcdir)\panel.c
+ $(SRCBUILD)
+
+printw.obj: $(srcdir)\printw.c
+ $(SRCBUILD)
+
+refresh.obj: $(srcdir)\refresh.c
+ $(SRCBUILD)
+
+scanw.obj: $(srcdir)\scanw.c
+ $(SRCBUILD)
+
+scr_dump.obj: $(srcdir)\scr_dump.c
+ $(SRCBUILD)
+
+scroll.obj: $(srcdir)\scroll.c
+ $(SRCBUILD)
+
+slk.obj: $(srcdir)\slk.c
+ $(SRCBUILD)
+
+termattr.obj: $(srcdir)\termattr.c
+ $(SRCBUILD)
+
+terminfo.obj: $(srcdir)\terminfo.c
+ $(SRCBUILD)
+
+touch.obj: $(srcdir)\touch.c
+ $(SRCBUILD)
+
+util.obj: $(srcdir)\util.c
+ $(SRCBUILD)
+
+window.obj: $(srcdir)\window.c
+ $(SRCBUILD)
+
+debug.obj: $(srcdir)\debug.c
+ $(SRCBUILD)
+
+pdcclip.obj: $(osdir)\pdcclip.c
+ $(OSBUILD)
+
+pdcdisp.obj: $(osdir)\pdcdisp.c
+ $(OSBUILD)
+
+pdcgetsc.obj: $(osdir)\pdcgetsc.c
+ $(OSBUILD)
+
+pdckbd.obj: $(osdir)\pdckbd.c
+ $(OSBUILD)
+
+pdcscrn.obj: $(osdir)\pdcscrn.c
+ $(OSBUILD)
+
+pdcsetsc.obj: $(osdir)\pdcsetsc.c
+ $(OSBUILD)
+
+pdcutil.obj: $(osdir)\pdcutil.c
+ $(OSBUILD)
+
+firework.exe: firework.obj
+ $(LINK) -o $@ firework.obj $(LIBCURSES)
+
+newdemo.exe: newdemo.obj
+ $(LINK) -o $@ newdemo.obj $(LIBCURSES)
+
+ptest.exe: ptest.obj
+ $(LINK) -o $@ ptest.obj $(LIBCURSES)
+
+rain.exe: rain.obj
+ $(LINK) -o $@ rain.obj $(LIBCURSES)
+
+testcurs.exe: testcurs.obj
+ $(LINK) -o $@ testcurs.obj $(LIBCURSES)
+
+tuidemo.exe: tuidemo.obj tui.obj
+ $(LINK) -o $@ tuidemo.obj tui.obj $(LIBCURSES)
+
+worm.exe: worm.obj
+ $(LINK) -o $@ worm.obj $(LIBCURSES)
+
+xmas.exe: xmas.obj
+ $(LINK) -o $@ xmas.obj $(LIBCURSES)
+
+firework.obj: $(demodir)\firework.c
+ $(BUILD) $(demodir)\$*.c
+
+newdemo.obj: $(demodir)\newdemo.c
+ $(BUILD) $(demodir)\$*.c
+
+ptest.obj: $(demodir)\ptest.c
+ $(BUILD) $(demodir)\$*.c
+
+rain.obj: $(demodir)\rain.c
+ $(BUILD) $(demodir)\$*.c
+
+testcurs.obj: $(demodir)\testcurs.c
+ $(BUILD) $(demodir)\$*.c
+
+tui.obj: $(demodir)\tui.c $(demodir)\tui.h
+ $(BUILD) -I$(demodir) $(demodir)\$*.c
+
+tuidemo.obj: $(demodir)\tuidemo.c
+ $(BUILD) -I$(demodir) $(demodir)\$*.c
+
+worm.obj: $(demodir)\worm.c
+ $(BUILD) $(demodir)\$*.c
+
+xmas.obj: $(demodir)\xmas.c
+ $(BUILD) $(demodir)\$*.c
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/mingwin32.mak b/payloads/libpayload/curses/PDCurses-3.4/win32/mingwin32.mak
new file mode 100644
index 0000000000..7fb17e8fc8
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/mingwin32.mak
@@ -0,0 +1,121 @@
+# GNU MAKE Makefile for PDCurses library - WIN32 MinGW GCC
+#
+# Usage: make -f [path\]mingwin32.mak [DEBUG=Y] [DLL=Y] [WIDE=Y] [UTF8=Y] [tgt]
+#
+# where tgt can be any of:
+# [all|demos|pdcurses.a|testcurs.exe...]
+
+O = o
+
+ifndef PDCURSES_SRCDIR
+ PDCURSES_SRCDIR = ..
+endif
+
+include $(PDCURSES_SRCDIR)/version.mif
+include $(PDCURSES_SRCDIR)/libobjs.mif
+
+osdir = $(PDCURSES_SRCDIR)/win32
+
+PDCURSES_WIN_H = $(osdir)/pdcwin.h
+
+CC = gcc
+
+ifeq ($(DEBUG),Y)
+ CFLAGS = -g -Wall -DPDCDEBUG
+ LDFLAGS = -g
+else
+ CFLAGS = -O2 -Wall
+ LDFLAGS =
+endif
+
+CFLAGS += -I$(PDCURSES_SRCDIR)
+
+BASEDEF = $(PDCURSES_SRCDIR)\exp-base.def
+WIDEDEF = $(PDCURSES_SRCDIR)\exp-wide.def
+
+DEFDEPS = $(BASEDEF)
+
+ifeq ($(WIDE),Y)
+ CFLAGS += -DPDC_WIDE
+ DEFDEPS += $(WIDEDEF)
+endif
+
+ifeq ($(UTF8),Y)
+ CFLAGS += -DPDC_FORCE_UTF8
+endif
+
+DEFFILE = pdcurses.def
+
+LINK = gcc
+
+ifeq ($(DLL),Y)
+ CFLAGS += -DPDC_DLL_BUILD
+ LIBEXE = gcc $(DEFFILE)
+ LIBFLAGS = -Wl,--out-implib,pdcurses.a -shared -o
+ LIBCURSES = pdcurses.dll
+ LIBDEPS = $(LIBOBJS) $(PDCOBJS) $(DEFFILE)
+ CLEAN = $(LIBCURSES) *.a $(DEFFILE)
+else
+ LIBEXE = ar
+ LIBFLAGS = rcv
+ LIBCURSES = pdcurses.a
+ LIBDEPS = $(LIBOBJS) $(PDCOBJS)
+ CLEAN = *.a
+endif
+
+.PHONY: all libs clean demos dist
+
+all: libs demos
+
+libs: $(LIBCURSES)
+
+clean:
+ -del *.o
+ -del *.exe
+ -del $(CLEAN)
+
+demos: $(DEMOS)
+ strip *.exe
+
+$(DEFFILE): $(DEFDEPS)
+ echo LIBRARY pdcurses > $@
+ echo EXPORTS >> $@
+ type $(BASEDEF) >> $@
+ifeq ($(WIDE),Y)
+ type $(WIDEDEF) >> $@
+endif
+
+$(LIBCURSES) : $(LIBDEPS)
+ $(LIBEXE) $(LIBFLAGS) $@ $?
+ -copy pdcurses.a panel.a
+
+$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
+$(PDCOBJS) : $(PDCURSES_WIN_H)
+$(DEMOS) : $(PDCURSES_CURSES_H) $(LIBCURSES)
+panel.o : $(PANEL_HEADER)
+terminfo.o: $(TERM_HEADER)
+
+$(LIBOBJS) : %.o: $(srcdir)/%.c
+ $(CC) -c $(CFLAGS) $<
+
+$(PDCOBJS) : %.o: $(osdir)/%.c
+ $(CC) -c $(CFLAGS) $<
+
+firework.exe newdemo.exe rain.exe testcurs.exe worm.exe xmas.exe \
+ptest.exe: %.exe: $(demodir)/%.c
+ $(CC) $(CFLAGS) -o$@ $< $(LIBCURSES)
+
+tuidemo.exe: tuidemo.o tui.o
+ $(LINK) $(LDFLAGS) -o$@ tuidemo.o tui.o $(LIBCURSES)
+
+tui.o: $(demodir)/tui.c $(demodir)/tui.h $(PDCURSES_CURSES_H)
+ $(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<
+
+tuidemo.o: $(demodir)/tuidemo.c $(PDCURSES_CURSES_H)
+ $(CC) -c $(CFLAGS) -I$(demodir) -o$@ $<
+
+PLATFORM1 = MinGW Win32
+PLATFORM2 = MinGW for Win32
+ARCNAME = pdc$(VER)_ming_w32
+
+include $(PDCURSES_SRCDIR)/makedist.mif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcclip.c b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcclip.c
new file mode 100644
index 0000000000..35b6bba514
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcclip.c
@@ -0,0 +1,145 @@
+/* Public Domain Curses */
+
+#include "pdcwin.h"
+
+RCSID("$Id: pdcclip.c,v 1.30 2008/07/14 04:24:52 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: clipboard
+
+ Synopsis:
+ int PDC_getclipboard(char **contents, long *length);
+ int PDC_setclipboard(const char *contents, long length);
+ int PDC_freeclipboard(char *contents);
+ int PDC_clearclipboard(void);
+
+ Description:
+ PDC_getclipboard() gets the textual contents of the system's
+ clipboard. This function returns the contents of the clipboard
+ in the contents argument. It is the responsibilitiy of the
+ caller to free the memory returned, via PDC_freeclipboard().
+ The length of the clipboard contents is returned in the length
+ argument.
+
+ PDC_setclipboard copies the supplied text into the system's
+ clipboard, emptying the clipboard prior to the copy.
+
+ PDC_clearclipboard() clears the internal clipboard.
+
+ Return Values:
+ indicator of success/failure of call.
+ PDC_CLIP_SUCCESS the call was successful
+ PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for
+ the clipboard contents
+ PDC_CLIP_EMPTY the clipboard contains no text
+ PDC_CLIP_ACCESS_ERROR no clipboard support
+
+ Portability X/Open BSD SYS V
+ PDC_getclipboard - - -
+ PDC_setclipboard - - -
+ PDC_freeclipboard - - -
+ PDC_clearclipboard - - -
+
+**man-end****************************************************************/
+
+#ifdef PDC_WIDE
+# define PDC_TEXT CF_UNICODETEXT
+#else
+# define PDC_TEXT CF_OEMTEXT
+#endif
+
+int PDC_getclipboard(char **contents, long *length)
+{
+ HANDLE handle;
+ long len;
+
+ PDC_LOG(("PDC_getclipboard() - called\n"));
+
+ if (!OpenClipboard(NULL))
+ return PDC_CLIP_ACCESS_ERROR;
+
+ if ((handle = GetClipboardData(PDC_TEXT)) == NULL)
+ {
+ CloseClipboard();
+ return PDC_CLIP_EMPTY;
+ }
+
+#ifdef PDC_WIDE
+ len = wcslen((wchar_t *)handle) * 3;
+#else
+ len = strlen((char *)handle);
+#endif
+ *contents = (char *)GlobalAlloc(GMEM_FIXED, len + 1);
+
+ if (!*contents)
+ {
+ CloseClipboard();
+ return PDC_CLIP_MEMORY_ERROR;
+ }
+
+#ifdef PDC_WIDE
+ len = PDC_wcstombs((char *)*contents, (wchar_t *)handle, len);
+#else
+ strcpy((char *)*contents, (char *)handle);
+#endif
+ *length = len;
+ CloseClipboard();
+
+ return PDC_CLIP_SUCCESS;
+}
+
+int PDC_setclipboard(const char *contents, long length)
+{
+ HGLOBAL ptr1;
+ LPTSTR ptr2;
+
+ PDC_LOG(("PDC_setclipboard() - called\n"));
+
+ if (!OpenClipboard(NULL))
+ return PDC_CLIP_ACCESS_ERROR;
+
+ ptr1 = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,
+ (length + 1) * sizeof(TCHAR));
+
+ if (!ptr1)
+ return PDC_CLIP_MEMORY_ERROR;
+
+ ptr2 = GlobalLock(ptr1);
+
+#ifdef PDC_WIDE
+ PDC_mbstowcs((wchar_t *)ptr2, contents, length);
+#else
+ memcpy((char *)ptr2, contents, length + 1);
+#endif
+ GlobalUnlock(ptr1);
+ EmptyClipboard();
+
+ if (!SetClipboardData(PDC_TEXT, ptr1))
+ {
+ GlobalFree(ptr1);
+ return PDC_CLIP_ACCESS_ERROR;
+ }
+
+ CloseClipboard();
+ GlobalFree(ptr1);
+
+ return PDC_CLIP_SUCCESS;
+}
+
+int PDC_freeclipboard(char *contents)
+{
+ PDC_LOG(("PDC_freeclipboard() - called\n"));
+
+ GlobalFree(contents);
+ return PDC_CLIP_SUCCESS;
+}
+
+int PDC_clearclipboard(void)
+{
+ PDC_LOG(("PDC_clearclipboard() - called\n"));
+
+ EmptyClipboard();
+
+ return PDC_CLIP_SUCCESS;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcdisp.c b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcdisp.c
new file mode 100644
index 0000000000..c2ad8142c6
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcdisp.c
@@ -0,0 +1,117 @@
+/* Public Domain Curses */
+
+#include "pdcwin.h"
+
+RCSID("$Id: pdcdisp.c,v 1.47 2008/07/14 04:24:52 wmcbrine Exp $")
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef CHTYPE_LONG
+
+# define A(x) ((chtype)x | A_ALTCHARSET)
+
+chtype acs_map[128] =
+{
+ A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9), A(10),
+ A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18), A(19),
+ A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27), A(28),
+ A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&', '\'', '(',
+ ')', '*',
+
+# ifdef PDC_WIDE
+ 0x2192, 0x2190, 0x2191, 0x2193,
+# else
+ A(0x1a), A(0x1b), A(0x18), A(0x19),
+# endif
+
+ '/',
+
+# ifdef PDC_WIDE
+ 0x2588,
+# else
+ 0xdb,
+# endif
+
+ '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
+ '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
+ 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
+
+# ifdef PDC_WIDE
+ 0x2666, 0x2592,
+# else
+ A(0x04), 0xb1,
+# endif
+
+ 'b', 'c', 'd', 'e',
+
+# ifdef PDC_WIDE
+ 0x00b0, 0x00b1, 0x2591, 0x00a4, 0x2518, 0x2510, 0x250c, 0x2514,
+ 0x253c, 0x23ba, 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524,
+ 0x2534, 0x252c, 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3,
+ 0x00b7,
+# else
+ 0xf8, 0xf1, 0xb0, A(0x0f), 0xd9, 0xbf, 0xda, 0xc0, 0xc5, 0x2d, 0x2d,
+ 0xc4, 0x2d, 0x5f, 0xc3, 0xb4, 0xc1, 0xc2, 0xb3, 0xf3, 0xf2, 0xe3,
+ 0xd8, 0x9c, 0xf9,
+# endif
+
+ A(127)
+};
+
+# undef A
+
+#endif
+
+/* position hardware cursor at (y, x) */
+
+void PDC_gotoyx(int row, int col)
+{
+ COORD coord;
+
+ PDC_LOG(("PDC_gotoyx() - called: row %d col %d from row %d col %d\n",
+ row, col, SP->cursrow, SP->curscol));
+
+ coord.X = col;
+ coord.Y = row;
+
+ SetConsoleCursorPosition(pdc_con_out, coord);
+}
+
+/* update the given physical line to look like the corresponding line in
+ curscr */
+
+void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
+{
+ CHAR_INFO ci[512];
+ int j;
+ COORD bufSize, bufPos;
+ SMALL_RECT sr;
+
+ PDC_LOG(("PDC_transform_line() - called: lineno=%d\n", lineno));
+
+ bufPos.X = bufPos.Y = 0;
+
+ bufSize.X = len;
+ bufSize.Y = 1;
+
+ sr.Top = lineno;
+ sr.Bottom = lineno;
+ sr.Left = x;
+ sr.Right = x + len - 1;
+
+ for (j = 0; j < len; j++)
+ {
+ chtype ch = srcp[j];
+
+ ci[j].Attributes = pdc_atrtab[ch >> PDC_ATTR_SHIFT];
+#ifdef CHTYPE_LONG
+ if (ch & A_ALTCHARSET && !(ch & 0xff80))
+ ch = acs_map[ch & 0x7f];
+#endif
+ ci[j].Char.UnicodeChar = ch & A_CHARTEXT;
+ }
+
+ WriteConsoleOutput(pdc_con_out, ci, bufSize, bufPos, &sr);
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcgetsc.c b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcgetsc.c
new file mode 100644
index 0000000000..15f0dc5f80
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcgetsc.c
@@ -0,0 +1,57 @@
+/* Public Domain Curses */
+
+#include "pdcwin.h"
+
+RCSID("$Id: pdcgetsc.c,v 1.36 2008/07/14 04:24:52 wmcbrine Exp $")
+
+/* get the cursor size/shape */
+
+int PDC_get_cursor_mode(void)
+{
+ CONSOLE_CURSOR_INFO ci;
+
+ PDC_LOG(("PDC_get_cursor_mode() - called\n"));
+
+ GetConsoleCursorInfo(pdc_con_out, &ci);
+
+ return ci.dwSize;
+}
+
+/* return number of screen rows */
+
+int PDC_get_rows(void)
+{
+ CONSOLE_SCREEN_BUFFER_INFO scr;
+
+ PDC_LOG(("PDC_get_rows() - called\n"));
+
+ GetConsoleScreenBufferInfo(pdc_con_out, &scr);
+
+ return scr.srWindow.Bottom - scr.srWindow.Top + 1;
+}
+
+/* return number of buffer rows */
+
+int PDC_get_buffer_rows(void)
+{
+ CONSOLE_SCREEN_BUFFER_INFO scr;
+
+ PDC_LOG(("PDC_get_buffer_rows() - called\n"));
+
+ GetConsoleScreenBufferInfo(pdc_con_out, &scr);
+
+ return scr.dwSize.Y;
+}
+
+/* return width of screen/viewport */
+
+int PDC_get_columns(void)
+{
+ CONSOLE_SCREEN_BUFFER_INFO scr;
+
+ PDC_LOG(("PDC_get_columns() - called\n"));
+
+ GetConsoleScreenBufferInfo(pdc_con_out, &scr);
+
+ return scr.srWindow.Right - scr.srWindow.Left + 1;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdckbd.c b/payloads/libpayload/curses/PDCurses-3.4/win32/pdckbd.c
new file mode 100644
index 0000000000..1c5b05b0fe
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdckbd.c
@@ -0,0 +1,656 @@
+/* Public Domain Curses */
+
+#include "pdcwin.h"
+
+RCSID("$Id: pdckbd.c,v 1.115 2008/07/20 20:12:04 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: pdckbd
+
+ Synopsis:
+ unsigned long PDC_get_input_fd(void);
+
+ Description:
+ PDC_get_input_fd() returns the file descriptor that PDCurses
+ reads its input from. It can be used for select().
+
+ Portability X/Open BSD SYS V
+ PDC_get_input_fd - - -
+
+**man-end****************************************************************/
+
+unsigned long pdc_key_modifiers = 0L;
+
+/* These variables are used to store information about the next
+ Input Event. */
+
+static INPUT_RECORD save_ip;
+static MOUSE_STATUS old_mouse_status;
+static DWORD event_count = 0;
+static SHORT left_key;
+static int key_count = 0;
+static int save_press = 0;
+
+#define KEV save_ip.Event.KeyEvent
+#define MEV save_ip.Event.MouseEvent
+
+/************************************************************************
+ * Table for key code translation of function keys in keypad mode *
+ * These values are for strict IBM keyboard compatibles only *
+ ************************************************************************/
+
+typedef struct
+{
+ unsigned short normal;
+ unsigned short shift;
+ unsigned short control;
+ unsigned short alt;
+ unsigned short extended;
+} KPTAB;
+
+static KPTAB kptab[] =
+{
+ {0, 0, 0, 0, 0 }, /* 0 */
+ {0, 0, 0, 0, 0 }, /* 1 VK_LBUTTON */
+ {0, 0, 0, 0, 0 }, /* 2 VK_RBUTTON */
+ {0, 0, 0, 0, 0 }, /* 3 VK_CANCEL */
+ {0, 0, 0, 0, 0 }, /* 4 VK_MBUTTON */
+ {0, 0, 0, 0, 0 }, /* 5 */
+ {0, 0, 0, 0, 0 }, /* 6 */
+ {0, 0, 0, 0, 0 }, /* 7 */
+ {0x08, 0x08, 0x7F, ALT_BKSP, 0 }, /* 8 VK_BACK */
+ {0x09, KEY_BTAB, CTL_TAB, ALT_TAB, 999 }, /* 9 VK_TAB */
+ {0, 0, 0, 0, 0 }, /* 10 */
+ {0, 0, 0, 0, 0 }, /* 11 */
+ {KEY_B2, 0x35, CTL_PAD5, ALT_PAD5, 0 }, /* 12 VK_CLEAR */
+ {0x0D, 0x0D, CTL_ENTER, ALT_ENTER, 1 }, /* 13 VK_RETURN */
+ {0, 0, 0, 0, 0 }, /* 14 */
+ {0, 0, 0, 0, 0 }, /* 15 */
+ {0, 0, 0, 0, 0 }, /* 16 VK_SHIFT HANDLED SEPARATELY */
+ {0, 0, 0, 0, 0 }, /* 17 VK_CONTROL HANDLED SEPARATELY */
+ {0, 0, 0, 0, 0 }, /* 18 VK_MENU HANDLED SEPARATELY */
+ {0, 0, 0, 0, 0 }, /* 19 VK_PAUSE */
+ {0, 0, 0, 0, 0 }, /* 20 VK_CAPITAL HANDLED SEPARATELY */
+ {0, 0, 0, 0, 0 }, /* 21 VK_HANGUL */
+ {0, 0, 0, 0, 0 }, /* 22 */
+ {0, 0, 0, 0, 0 }, /* 23 VK_JUNJA */
+ {0, 0, 0, 0, 0 }, /* 24 VK_FINAL */
+ {0, 0, 0, 0, 0 }, /* 25 VK_HANJA */
+ {0, 0, 0, 0, 0 }, /* 26 */
+ {0x1B, 0x1B, 0x1B, ALT_ESC, 0 }, /* 27 VK_ESCAPE */
+ {0, 0, 0, 0, 0 }, /* 28 VK_CONVERT */
+ {0, 0, 0, 0, 0 }, /* 29 VK_NONCONVERT */
+ {0, 0, 0, 0, 0 }, /* 30 VK_ACCEPT */
+ {0, 0, 0, 0, 0 }, /* 31 VK_MODECHANGE */
+ {0x20, 0x20, 0x20, 0x20, 0 }, /* 32 VK_SPACE */
+ {KEY_A3, 0x39, CTL_PAD9, ALT_PAD9, 3 }, /* 33 VK_PRIOR */
+ {KEY_C3, 0x33, CTL_PAD3, ALT_PAD3, 4 }, /* 34 VK_NEXT */
+ {KEY_C1, 0x31, CTL_PAD1, ALT_PAD1, 5 }, /* 35 VK_END */
+ {KEY_A1, 0x37, CTL_PAD7, ALT_PAD7, 6 }, /* 36 VK_HOME */
+ {KEY_B1, 0x34, CTL_PAD4, ALT_PAD4, 7 }, /* 37 VK_LEFT */
+ {KEY_A2, 0x38, CTL_PAD8, ALT_PAD8, 8 }, /* 38 VK_UP */
+ {KEY_B3, 0x36, CTL_PAD6, ALT_PAD6, 9 }, /* 39 VK_RIGHT */
+ {KEY_C2, 0x32, CTL_PAD2, ALT_PAD2, 10 }, /* 40 VK_DOWN */
+ {0, 0, 0, 0, 0 }, /* 41 VK_SELECT */
+ {0, 0, 0, 0, 0 }, /* 42 VK_PRINT */
+ {0, 0, 0, 0, 0 }, /* 43 VK_EXECUTE */
+ {0, 0, 0, 0, 0 }, /* 44 VK_SNAPSHOT*/
+ {PAD0, 0x30, CTL_PAD0, ALT_PAD0, 11 }, /* 45 VK_INSERT */
+ {PADSTOP, 0x2E, CTL_PADSTOP, ALT_PADSTOP,12 }, /* 46 VK_DELETE */
+ {0, 0, 0, 0, 0 }, /* 47 VK_HELP */
+ {0x30, 0x29, 0, ALT_0, 0 }, /* 48 */
+ {0x31, 0x21, 0, ALT_1, 0 }, /* 49 */
+ {0x32, 0x40, 0, ALT_2, 0 }, /* 50 */
+ {0x33, 0x23, 0, ALT_3, 0 }, /* 51 */
+ {0x34, 0x24, 0, ALT_4, 0 }, /* 52 */
+ {0x35, 0x25, 0, ALT_5, 0 }, /* 53 */
+ {0x36, 0x5E, 0, ALT_6, 0 }, /* 54 */
+ {0x37, 0x26, 0, ALT_7, 0 }, /* 55 */
+ {0x38, 0x2A, 0, ALT_8, 0 }, /* 56 */
+ {0x39, 0x28, 0, ALT_9, 0 }, /* 57 */
+ {0, 0, 0, 0, 0 }, /* 58 */
+ {0, 0, 0, 0, 0 }, /* 59 */
+ {0, 0, 0, 0, 0 }, /* 60 */
+ {0, 0, 0, 0, 0 }, /* 61 */
+ {0, 0, 0, 0, 0 }, /* 62 */
+ {0, 0, 0, 0, 0 }, /* 63 */
+ {0, 0, 0, 0, 0 }, /* 64 */
+ {0x61, 0x41, 0x01, ALT_A, 0 }, /* 65 */
+ {0x62, 0x42, 0x02, ALT_B, 0 }, /* 66 */
+ {0x63, 0x43, 0x03, ALT_C, 0 }, /* 67 */
+ {0x64, 0x44, 0x04, ALT_D, 0 }, /* 68 */
+ {0x65, 0x45, 0x05, ALT_E, 0 }, /* 69 */
+ {0x66, 0x46, 0x06, ALT_F, 0 }, /* 70 */
+ {0x67, 0x47, 0x07, ALT_G, 0 }, /* 71 */
+ {0x68, 0x48, 0x08, ALT_H, 0 }, /* 72 */
+ {0x69, 0x49, 0x09, ALT_I, 0 }, /* 73 */
+ {0x6A, 0x4A, 0x0A, ALT_J, 0 }, /* 74 */
+ {0x6B, 0x4B, 0x0B, ALT_K, 0 }, /* 75 */
+ {0x6C, 0x4C, 0x0C, ALT_L, 0 }, /* 76 */
+ {0x6D, 0x4D, 0x0D, ALT_M, 0 }, /* 77 */
+ {0x6E, 0x4E, 0x0E, ALT_N, 0 }, /* 78 */
+ {0x6F, 0x4F, 0x0F, ALT_O, 0 }, /* 79 */
+ {0x70, 0x50, 0x10, ALT_P, 0 }, /* 80 */
+ {0x71, 0x51, 0x11, ALT_Q, 0 }, /* 81 */
+ {0x72, 0x52, 0x12, ALT_R, 0 }, /* 82 */
+ {0x73, 0x53, 0x13, ALT_S, 0 }, /* 83 */
+ {0x74, 0x54, 0x14, ALT_T, 0 }, /* 84 */
+ {0x75, 0x55, 0x15, ALT_U, 0 }, /* 85 */
+ {0x76, 0x56, 0x16, ALT_V, 0 }, /* 86 */
+ {0x77, 0x57, 0x17, ALT_W, 0 }, /* 87 */
+ {0x78, 0x58, 0x18, ALT_X, 0 }, /* 88 */
+ {0x79, 0x59, 0x19, ALT_Y, 0 }, /* 89 */
+ {0x7A, 0x5A, 0x1A, ALT_Z, 0 }, /* 90 */
+ {0, 0, 0, 0, 0 }, /* 91 VK_LWIN */
+ {0, 0, 0, 0, 0 }, /* 92 VK_RWIN */
+ {0, 0, 0, 0, 0 }, /* 93 VK_APPS */
+ {0, 0, 0, 0, 0 }, /* 94 */
+ {0, 0, 0, 0, 0 }, /* 95 */
+ {0x30, 0, CTL_PAD0, ALT_PAD0, 0 }, /* 96 VK_NUMPAD0 */
+ {0x31, 0, CTL_PAD1, ALT_PAD1, 0 }, /* 97 VK_NUMPAD1 */
+ {0x32, 0, CTL_PAD2, ALT_PAD2, 0 }, /* 98 VK_NUMPAD2 */
+ {0x33, 0, CTL_PAD3, ALT_PAD3, 0 }, /* 99 VK_NUMPAD3 */
+ {0x34, 0, CTL_PAD4, ALT_PAD4, 0 }, /* 100 VK_NUMPAD4 */
+ {0x35, 0, CTL_PAD5, ALT_PAD5, 0 }, /* 101 VK_NUMPAD5 */
+ {0x36, 0, CTL_PAD6, ALT_PAD6, 0 }, /* 102 VK_NUMPAD6 */
+ {0x37, 0, CTL_PAD7, ALT_PAD7, 0 }, /* 103 VK_NUMPAD7 */
+ {0x38, 0, CTL_PAD8, ALT_PAD8, 0 }, /* 104 VK_NUMPAD8 */
+ {0x39, 0, CTL_PAD9, ALT_PAD9, 0 }, /* 105 VK_NUMPAD9 */
+ {PADSTAR, SHF_PADSTAR,CTL_PADSTAR, ALT_PADSTAR,999 }, /* 106 VK_MULTIPLY*/
+ {PADPLUS, SHF_PADPLUS,CTL_PADPLUS, ALT_PADPLUS,999 }, /* 107 VK_ADD */
+ {0, 0, 0, 0, 0 }, /* 108 VK_SEPARATOR */
+ {PADMINUS, SHF_PADMINUS,CTL_PADMINUS,ALT_PADMINUS,999}, /* 109 VK_SUBTRACT*/
+ {0x2E, 0, CTL_PADSTOP, ALT_PADSTOP,0 }, /* 110 VK_DECIMAL */
+ {PADSLASH, SHF_PADSLASH,CTL_PADSLASH,ALT_PADSLASH,2 }, /* 111 VK_DIVIDE */
+ {KEY_F(1), KEY_F(13), KEY_F(25), KEY_F(37), 0 }, /* 112 VK_F1 */
+ {KEY_F(2), KEY_F(14), KEY_F(26), KEY_F(38), 0 }, /* 113 VK_F2 */
+ {KEY_F(3), KEY_F(15), KEY_F(27), KEY_F(39), 0 }, /* 114 VK_F3 */
+ {KEY_F(4), KEY_F(16), KEY_F(28), KEY_F(40), 0 }, /* 115 VK_F4 */
+ {KEY_F(5), KEY_F(17), KEY_F(29), KEY_F(41), 0 }, /* 116 VK_F5 */
+ {KEY_F(6), KEY_F(18), KEY_F(30), KEY_F(42), 0 }, /* 117 VK_F6 */
+ {KEY_F(7), KEY_F(19), KEY_F(31), KEY_F(43), 0 }, /* 118 VK_F7 */
+ {KEY_F(8), KEY_F(20), KEY_F(32), KEY_F(44), 0 }, /* 119 VK_F8 */
+ {KEY_F(9), KEY_F(21), KEY_F(33), KEY_F(45), 0 }, /* 120 VK_F9 */
+ {KEY_F(10), KEY_F(22), KEY_F(34), KEY_F(46), 0 }, /* 121 VK_F10 */
+ {KEY_F(11), KEY_F(23), KEY_F(35), KEY_F(47), 0 }, /* 122 VK_F11 */
+ {KEY_F(12), KEY_F(24), KEY_F(36), KEY_F(48), 0 }, /* 123 VK_F12 */
+
+ /* 124 through 218 */
+
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},
+
+ {0x5B, 0x7B, 0x1B, ALT_LBRACKET,0 }, /* 219 */
+ {0x5C, 0x7C, 0x1C, ALT_BSLASH, 0 }, /* 220 */
+ {0x5D, 0x7D, 0x1D, ALT_RBRACKET,0 }, /* 221 */
+ {0, 0, 0x27, ALT_FQUOTE, 0 }, /* 222 */
+ {0, 0, 0, 0, 0 }, /* 223 */
+ {0, 0, 0, 0, 0 }, /* 224 */
+ {0, 0, 0, 0, 0 } /* 225 */
+};
+
+static KPTAB ext_kptab[] =
+{
+ {0, 0, 0, 0, }, /* MUST BE EMPTY */
+ {PADENTER, SHF_PADENTER, CTL_PADENTER, ALT_PADENTER}, /* 13 */
+ {PADSLASH, SHF_PADSLASH, CTL_PADSLASH, ALT_PADSLASH}, /* 111 */
+ {KEY_PPAGE, KEY_SPREVIOUS, CTL_PGUP, ALT_PGUP }, /* 33 */
+ {KEY_NPAGE, KEY_SNEXT, CTL_PGDN, ALT_PGDN }, /* 34 */
+ {KEY_END, KEY_SEND, CTL_END, ALT_END }, /* 35 */
+ {KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME }, /* 36 */
+ {KEY_LEFT, KEY_SLEFT, CTL_LEFT, ALT_LEFT }, /* 37 */
+ {KEY_UP, KEY_SUP, CTL_UP, ALT_UP }, /* 38 */
+ {KEY_RIGHT, KEY_SRIGHT, CTL_RIGHT, ALT_RIGHT }, /* 39 */
+ {KEY_DOWN, KEY_SDOWN, CTL_DOWN, ALT_DOWN }, /* 40 */
+ {KEY_IC, KEY_SIC, CTL_INS, ALT_INS }, /* 45 */
+ {KEY_DC, KEY_SDC, CTL_DEL, ALT_DEL }, /* 46 */
+ {PADSLASH, SHF_PADSLASH, CTL_PADSLASH, ALT_PADSLASH}, /* 191 */
+};
+
+/* End of kptab[] */
+
+unsigned long PDC_get_input_fd(void)
+{
+ PDC_LOG(("PDC_get_input_fd() - called\n"));
+
+ return 0L;
+}
+
+void PDC_set_keyboard_binary(bool on)
+{
+ PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
+}
+
+/* check if a key or mouse event is waiting */
+
+bool PDC_check_key(void)
+{
+ if (key_count > 0)
+ return TRUE;
+
+ GetNumberOfConsoleInputEvents(pdc_con_in, &event_count);
+
+ return (event_count != 0);
+}
+
+/* _get_key_count returns 0 if save_ip doesn't contain an event which
+ should be passed back to the user. This function filters "useless"
+ events.
+
+ The function returns the number of keys waiting. This may be > 1
+ if the repetition of real keys pressed so far are > 1.
+
+ Returns 0 on NUMLOCK, CAPSLOCK, SCROLLLOCK.
+
+ Returns 1 for SHIFT, ALT, CTRL only if no other key has been pressed
+ in between, and SP->return_key_modifiers is set; these are returned
+ on keyup.
+
+ Normal keys are returned on keydown only. The number of repetitions
+ are returned. Dead keys (diacritics) are omitted. See below for a
+ description.
+*/
+
+static int _get_key_count(void)
+{
+ int num_keys = 0, vk;
+
+ PDC_LOG(("_get_key_count() - called\n"));
+
+ vk = KEV.wVirtualKeyCode;
+
+ if (KEV.bKeyDown)
+ {
+ /* key down */
+
+ save_press = 0;
+
+ if (vk == VK_CAPITAL || vk == VK_NUMLOCK || vk == VK_SCROLL)
+ {
+ /* throw away these modifiers */
+ }
+ else if (vk == VK_SHIFT || vk == VK_CONTROL || vk == VK_MENU)
+ {
+ /* These keys are returned on keyup only. */
+
+ save_press = vk;
+ switch (vk)
+ {
+ case VK_SHIFT:
+ left_key = GetKeyState(VK_LSHIFT);
+ break;
+ case VK_CONTROL:
+ left_key = GetKeyState(VK_LCONTROL);
+ break;
+ case VK_MENU:
+ left_key = GetKeyState(VK_LMENU);
+ }
+ }
+ else
+ {
+ /* Check for diacritics. These are dead keys. Some locales
+ have modified characters like umlaut-a, which is an "a"
+ with two dots on it. In some locales you have to press a
+ special key (the dead key) immediately followed by the
+ "a" to get a composed umlaut-a. The special key may have
+ a normal meaning with different modifiers. */
+
+ if (KEV.uChar.UnicodeChar || !(MapVirtualKey(vk, 2) & 0x80000000))
+ num_keys = KEV.wRepeatCount;
+ }
+ }
+ else
+ {
+ /* key up */
+
+ /* Only modifier keys or the results of ALT-numpad entry are
+ returned on keyup */
+
+ if ((vk == VK_MENU && KEV.uChar.UnicodeChar) ||
+ ((vk == VK_SHIFT || vk == VK_CONTROL || vk == VK_MENU) &&
+ vk == save_press))
+ {
+ save_press = 0;
+ num_keys = 1;
+ }
+ }
+
+ PDC_LOG(("_get_key_count() - returning: num_keys %d\n", num_keys));
+
+ return num_keys;
+}
+
+/* _process_key_event returns -1 if the key in save_ip should be
+ ignored. Otherwise it returns the keycode which should be returned
+ by PDC_get_key(). save_ip must be a key event.
+
+ CTRL-ALT support has been disabled, when is it emitted plainly? */
+
+static int _process_key_event(void)
+{
+ int key = (unsigned short)KEV.uChar.UnicodeChar;
+ WORD vk = KEV.wVirtualKeyCode;
+ DWORD state = KEV.dwControlKeyState;
+
+ int idx;
+ BOOL enhanced;
+
+ SP->key_code = TRUE;
+
+ /* Save the key modifiers if required. Do this first to allow to
+ detect e.g. a pressed CTRL key after a hit of NUMLOCK. */
+
+ if (SP->save_key_modifiers)
+ {
+ if (state & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT;
+
+ if (state & SHIFT_PRESSED)
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
+
+ if (state & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
+
+ if (state & NUMLOCK_ON)
+ pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
+ }
+
+ /* Handle modifier keys hit by themselves */
+
+ switch (vk)
+ {
+ case VK_SHIFT: /* shift */
+ if (!SP->return_key_modifiers)
+ return -1;
+
+ return (left_key & 0x8000) ? KEY_SHIFT_L : KEY_SHIFT_R;
+
+ case VK_CONTROL: /* control */
+ if (!SP->return_key_modifiers)
+ return -1;
+
+ return (left_key & 0x8000) ? KEY_CONTROL_L : KEY_CONTROL_R;
+
+ case VK_MENU: /* alt */
+ if (!key)
+ {
+ if (!SP->return_key_modifiers)
+ return -1;
+
+ return (left_key & 0x8000) ? KEY_ALT_L : KEY_ALT_R;
+ }
+ }
+
+ /* The system may emit Ascii or Unicode characters depending on
+ whether ReadConsoleInputA or ReadConsoleInputW is used.
+
+ Normally, if key != 0 then the system did the translation
+ successfully. But this is not true for LEFT_ALT (different to
+ RIGHT_ALT). In case of LEFT_ALT we can get key != 0. So
+ check for this first. */
+
+ if (key && ( !(state & LEFT_ALT_PRESSED) ||
+ (state & RIGHT_ALT_PRESSED) ))
+ {
+ /* This code should catch all keys returning a printable
+ character. Characters above 0x7F should be returned as
+ positive codes. But if'ndef NUMKEYPAD we have to return
+ extended keycodes for keypad codes. */
+
+#ifndef NUMKEYPAD
+ if (kptab[vk].extended == 0)
+#endif
+ {
+ SP->key_code = FALSE;
+ return key;
+ }
+ }
+
+ /* This case happens if a functional key has been entered. */
+
+ if ((state & ENHANCED_KEY) && (kptab[vk].extended != 999))
+ {
+ enhanced = TRUE;
+ idx = kptab[vk].extended;
+ }
+ else
+ {
+ enhanced = FALSE;
+ idx = vk;
+ }
+
+ if (state & SHIFT_PRESSED)
+ key = enhanced ? ext_kptab[idx].shift : kptab[idx].shift;
+
+ else if (state & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
+ key = enhanced ? ext_kptab[idx].control : kptab[idx].control;
+
+ else if (state & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
+ key = enhanced ? ext_kptab[idx].alt : kptab[idx].alt;
+
+ else
+ key = enhanced ? ext_kptab[idx].normal : kptab[idx].normal;
+
+ if (key < KEY_CODE_YES)
+ SP->key_code = FALSE;
+
+ return key;
+}
+
+static int _process_mouse_event(void)
+{
+ static const DWORD button_mask[] = {1, 4, 2};
+ short action, shift_flags = 0;
+ int i;
+
+ save_press = 0;
+ SP->key_code = TRUE;
+
+ memset(&pdc_mouse_status, 0, sizeof(MOUSE_STATUS));
+
+ /* Handle scroll wheel */
+
+ if (MEV.dwEventFlags == 4)
+ {
+ pdc_mouse_status.changes = (MEV.dwButtonState & 0xFF000000) ?
+ PDC_MOUSE_WHEEL_DOWN : PDC_MOUSE_WHEEL_UP;
+
+ pdc_mouse_status.x = -1;
+ pdc_mouse_status.y = -1;
+
+ memset(&old_mouse_status, 0, sizeof(old_mouse_status));
+
+ return KEY_MOUSE;
+ }
+
+ action = (MEV.dwEventFlags == 2) ? BUTTON_DOUBLE_CLICKED :
+ ((MEV.dwEventFlags == 1) ? BUTTON_MOVED : BUTTON_PRESSED);
+
+ for (i = 0; i < 3; i++)
+ pdc_mouse_status.button[i] =
+ (MEV.dwButtonState & button_mask[i]) ? action : 0;
+
+ if (action == BUTTON_PRESSED && MEV.dwButtonState & 7 && SP->mouse_wait)
+ {
+ /* Check for a click -- a PRESS followed immediately by a release */
+
+ if (!event_count)
+ {
+ napms(SP->mouse_wait);
+
+ GetNumberOfConsoleInputEvents(pdc_con_in, &event_count);
+ }
+
+ if (event_count)
+ {
+ INPUT_RECORD ip;
+ DWORD count;
+ bool have_click = FALSE;
+
+ PeekConsoleInput(pdc_con_in, &ip, 1, &count);
+
+ for (i = 0; i < 3; i++)
+ {
+ if (pdc_mouse_status.button[i] == BUTTON_PRESSED &&
+ !(ip.Event.MouseEvent.dwButtonState & button_mask[i]))
+ {
+ pdc_mouse_status.button[i] = BUTTON_CLICKED;
+ have_click = TRUE;
+ }
+ }
+
+ /* If a click was found, throw out the event */
+
+ if (have_click)
+ ReadConsoleInput(pdc_con_in, &ip, 1, &count);
+ }
+ }
+
+ pdc_mouse_status.x = MEV.dwMousePosition.X;
+ pdc_mouse_status.y = MEV.dwMousePosition.Y;
+
+ pdc_mouse_status.changes = 0;
+
+ for (i = 0; i < 3; i++)
+ {
+ if (old_mouse_status.button[i] != pdc_mouse_status.button[i])
+ pdc_mouse_status.changes |= (1 << i);
+
+ if (pdc_mouse_status.button[i] == BUTTON_MOVED)
+ {
+ /* Discard non-moved "moves" */
+
+ if (pdc_mouse_status.x == old_mouse_status.x &&
+ pdc_mouse_status.y == old_mouse_status.y)
+ return -1;
+
+ /* Motion events always flag the button as changed */
+
+ pdc_mouse_status.changes |= (1 << i);
+ pdc_mouse_status.changes |= PDC_MOUSE_MOVED;
+ break;
+ }
+ }
+
+ old_mouse_status = pdc_mouse_status;
+
+ /* Treat click events as release events for comparison purposes */
+
+ for (i = 0; i < 3; i++)
+ {
+ if (old_mouse_status.button[i] == BUTTON_CLICKED ||
+ old_mouse_status.button[i] == BUTTON_DOUBLE_CLICKED)
+ old_mouse_status.button[i] = BUTTON_RELEASED;
+ }
+
+ /* Check for SHIFT/CONTROL/ALT */
+
+ if (MEV.dwControlKeyState & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED))
+ shift_flags |= BUTTON_ALT;
+
+ if (MEV.dwControlKeyState & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED))
+ shift_flags |= BUTTON_CONTROL;
+
+ if (MEV.dwControlKeyState & SHIFT_PRESSED)
+ shift_flags |= BUTTON_SHIFT;
+
+ if (shift_flags)
+ {
+ for (i = 0; i < 3; i++)
+ {
+ if (pdc_mouse_status.changes & (1 << i))
+ pdc_mouse_status.button[i] |= shift_flags;
+ }
+ }
+
+ return KEY_MOUSE;
+}
+
+/* return the next available key or mouse event */
+
+int PDC_get_key(void)
+{
+ pdc_key_modifiers = 0L;
+
+ if (!key_count)
+ {
+ DWORD count;
+
+ ReadConsoleInput(pdc_con_in, &save_ip, 1, &count);
+ event_count--;
+
+ if (save_ip.EventType == MOUSE_EVENT)
+ key_count = 1;
+ else if (save_ip.EventType == KEY_EVENT)
+ key_count = _get_key_count();
+ }
+
+ if (key_count)
+ {
+ key_count--;
+
+ switch (save_ip.EventType)
+ {
+ case KEY_EVENT:
+ return _process_key_event();
+
+ case MOUSE_EVENT:
+ return _process_mouse_event();
+ }
+ }
+
+ return -1;
+}
+
+/* discard any pending keyboard or mouse input -- this is the core
+ routine for flushinp() */
+
+void PDC_flushinp(void)
+{
+ PDC_LOG(("PDC_flushinp() - called\n"));
+
+ FlushConsoleInputBuffer(pdc_con_in);
+}
+
+int PDC_mouse_set(void)
+{
+ /* If turning on mouse input: Set ENABLE_MOUSE_INPUT, and clear
+ all other flags, including the extended flags;
+ If turning off the mouse: Set QuickEdit Mode to the status it
+ had on startup, and clear all other flags */
+
+ SetConsoleMode(pdc_con_in, SP->_trap_mbe ?
+ (ENABLE_MOUSE_INPUT|0x0080) : (pdc_quick_edit|0x0080));
+
+ memset(&old_mouse_status, 0, sizeof(old_mouse_status));
+
+ return OK;
+}
+
+int PDC_modifiers_set(void)
+{
+ return OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcscrn.c b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcscrn.c
new file mode 100644
index 0000000000..b48ddaafd9
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcscrn.c
@@ -0,0 +1,620 @@
+/* Public Domain Curses */
+
+#include "pdcwin.h"
+
+RCSID("$Id: pdcscrn.c,v 1.92 2008/07/20 20:12:04 wmcbrine Exp $")
+
+#ifdef CHTYPE_LONG
+# define PDC_OFFSET 32
+#else
+# define PDC_OFFSET 8
+#endif
+
+/* COLOR_PAIR to attribute encoding table. */
+
+unsigned char *pdc_atrtab = (unsigned char *)NULL;
+
+HANDLE pdc_con_out = INVALID_HANDLE_VALUE;
+HANDLE pdc_con_in = INVALID_HANDLE_VALUE;
+
+DWORD pdc_quick_edit;
+
+static short curstoreal[16], realtocurs[16] =
+{
+ COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, COLOR_RED,
+ COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE, COLOR_BLACK + 8,
+ COLOR_BLUE + 8, COLOR_GREEN + 8, COLOR_CYAN + 8, COLOR_RED + 8,
+ COLOR_MAGENTA + 8, COLOR_YELLOW + 8, COLOR_WHITE + 8
+};
+
+enum { PDC_RESTORE_NONE, PDC_RESTORE_BUFFER, PDC_RESTORE_WINDOW };
+
+/* Struct for storing console registry keys, and for use with the
+ undocumented WM_SETCONSOLEINFO message. Originally by James Brown,
+ www.catch22.net. */
+
+static struct
+{
+ ULONG Length;
+ COORD ScreenBufferSize;
+ COORD WindowSize;
+ ULONG WindowPosX;
+ ULONG WindowPosY;
+
+ COORD FontSize;
+ ULONG FontFamily;
+ ULONG FontWeight;
+ WCHAR FaceName[32];
+
+ ULONG CursorSize;
+ ULONG FullScreen;
+ ULONG QuickEdit;
+ ULONG AutoPosition;
+ ULONG InsertMode;
+
+ USHORT ScreenColors;
+ USHORT PopupColors;
+ ULONG HistoryNoDup;
+ ULONG HistoryBufferSize;
+ ULONG NumberOfHistoryBuffers;
+
+ COLORREF ColorTable[16];
+
+ ULONG CodePage;
+ HWND Hwnd;
+
+ WCHAR ConsoleTitle[0x100];
+} console_info;
+
+static CONSOLE_SCREEN_BUFFER_INFO orig_scr;
+
+static CHAR_INFO *ci_save = NULL;
+static DWORD old_console_mode = 0;
+
+static bool is_nt;
+
+static HWND _find_console_handle(void)
+{
+ TCHAR orgtitle[1024], temptitle[1024];
+ HWND wnd;
+
+ GetConsoleTitle(orgtitle, 1024);
+
+ wsprintf(temptitle, TEXT("%d/%d"), GetTickCount(), GetCurrentProcessId());
+ SetConsoleTitle(temptitle);
+
+ Sleep(40);
+
+ wnd = FindWindow(NULL, temptitle);
+
+ SetConsoleTitle(orgtitle);
+
+ return wnd;
+}
+
+/* Undocumented console message */
+
+#define WM_SETCONSOLEINFO (WM_USER + 201)
+
+/* Wrapper around WM_SETCONSOLEINFO. We need to create the necessary
+ section (file-mapping) object in the context of the process which
+ owns the console, before posting the message. Originally by JB. */
+
+static void _set_console_info(void)
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ CONSOLE_CURSOR_INFO cci;
+ DWORD dwConsoleOwnerPid;
+ HANDLE hProcess;
+ HANDLE hSection, hDupSection;
+ PVOID ptrView;
+
+ /* Each-time initialization for console_info */
+
+ GetConsoleCursorInfo(pdc_con_out, &cci);
+ console_info.CursorSize = cci.dwSize;
+
+ GetConsoleScreenBufferInfo(pdc_con_out, &csbi);
+ console_info.ScreenBufferSize = csbi.dwSize;
+
+ console_info.WindowSize.X = csbi.srWindow.Right - csbi.srWindow.Left + 1;
+ console_info.WindowSize.Y = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
+
+ console_info.WindowPosX = csbi.srWindow.Left;
+ console_info.WindowPosY = csbi.srWindow.Top;
+
+ /* Open the process which "owns" the console */
+
+ GetWindowThreadProcessId(console_info.Hwnd, &dwConsoleOwnerPid);
+
+ hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwConsoleOwnerPid);
+
+ /* Create a SECTION object backed by page-file, then map a view of
+ this section into the owner process so we can write the contents
+ of the CONSOLE_INFO buffer into it */
+
+ hSection = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE,
+ 0, sizeof(console_info), 0);
+
+ /* Copy our console structure into the section-object */
+
+ ptrView = MapViewOfFile(hSection, FILE_MAP_WRITE|FILE_MAP_READ,
+ 0, 0, sizeof(console_info));
+
+ memcpy(ptrView, &console_info, sizeof(console_info));
+
+ UnmapViewOfFile(ptrView);
+
+ /* Map the memory into owner process */
+
+ DuplicateHandle(GetCurrentProcess(), hSection, hProcess, &hDupSection,
+ 0, FALSE, DUPLICATE_SAME_ACCESS);
+
+ /* Send console window the "update" message */
+
+ SendMessage(console_info.Hwnd, WM_SETCONSOLEINFO, (WPARAM)hDupSection, 0);
+
+ CloseHandle(hSection);
+ CloseHandle(hProcess);
+}
+
+/* One-time initialization for console_info -- color table and font info
+ from the registry; other values from functions. */
+
+static void _init_console_info(void)
+{
+ DWORD scrnmode, len;
+ HKEY reghnd;
+ int i;
+
+ console_info.Hwnd = _find_console_handle();
+ console_info.Length = sizeof(console_info);
+
+ GetConsoleMode(pdc_con_in, &scrnmode);
+ console_info.QuickEdit = !!(scrnmode & 0x0040);
+ console_info.InsertMode = !!(scrnmode & 0x0020);
+
+ console_info.FullScreen = FALSE;
+ console_info.AutoPosition = 0x10000;
+ console_info.ScreenColors = SP->orig_back << 4 | SP->orig_fore;
+ console_info.PopupColors = 0xf5;
+
+ console_info.HistoryNoDup = FALSE;
+ console_info.HistoryBufferSize = 50;
+ console_info.NumberOfHistoryBuffers = 4;
+
+ console_info.CodePage = GetConsoleOutputCP();
+
+ RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Console"), 0,
+ KEY_QUERY_VALUE, &reghnd);
+
+ len = sizeof(DWORD);
+
+ /* Default color table */
+
+ for (i = 0; i < 16; i++)
+ {
+ char tname[13];
+
+ sprintf(tname, "ColorTable%02d", i);
+ RegQueryValueExA(reghnd, tname, NULL, NULL,
+ (LPBYTE)(&(console_info.ColorTable[i])), &len);
+ }
+
+ /* Font info */
+
+ RegQueryValueEx(reghnd, TEXT("FontSize"), NULL, NULL,
+ (LPBYTE)(&console_info.FontSize), &len);
+ RegQueryValueEx(reghnd, TEXT("FontFamily"), NULL, NULL,
+ (LPBYTE)(&console_info.FontFamily), &len);
+ RegQueryValueEx(reghnd, TEXT("FontWeight"), NULL, NULL,
+ (LPBYTE)(&console_info.FontWeight), &len);
+
+ len = sizeof(WCHAR) * 32;
+ RegQueryValueExW(reghnd, L"FaceName", NULL, NULL,
+ (LPBYTE)(console_info.FaceName), &len);
+
+ RegCloseKey(reghnd);
+}
+
+/* close the physical screen -- may restore the screen to its state
+ before PDC_scr_open(); miscellaneous cleanup */
+
+void PDC_scr_close(void)
+{
+ COORD origin;
+ SMALL_RECT rect;
+
+ PDC_LOG(("PDC_scr_close() - called\n"));
+
+ PDC_reset_shell_mode();
+
+ if (SP->_restore != PDC_RESTORE_NONE)
+ {
+ if (SP->_restore == PDC_RESTORE_WINDOW)
+ {
+ rect.Top = orig_scr.srWindow.Top;
+ rect.Left = orig_scr.srWindow.Left;
+ rect.Bottom = orig_scr.srWindow.Bottom;
+ rect.Right = orig_scr.srWindow.Right;
+ }
+ else /* PDC_RESTORE_BUFFER */
+ {
+ rect.Top = rect.Left = 0;
+ rect.Bottom = orig_scr.dwSize.Y - 1;
+ rect.Right = orig_scr.dwSize.X - 1;
+ }
+
+ origin.X = origin.Y = 0;
+
+ if (!WriteConsoleOutput(pdc_con_out, ci_save, orig_scr.dwSize,
+ origin, &rect))
+ return;
+ }
+
+ if (SP->visibility != 1)
+ curs_set(1);
+
+ /* Position cursor to the bottom left of the screen. */
+
+ PDC_gotoyx(PDC_get_buffer_rows() - 2, 0);
+}
+
+void PDC_scr_free(void)
+{
+ if (SP)
+ free(SP);
+ if (pdc_atrtab)
+ free(pdc_atrtab);
+
+ pdc_atrtab = (unsigned char *)NULL;
+}
+
+/* open the physical screen -- allocate SP, miscellaneous intialization,
+ and may save the existing screen for later restoration */
+
+int PDC_scr_open(int argc, char **argv)
+{
+ COORD bufsize, origin;
+ SMALL_RECT rect;
+ const char *str;
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ int i;
+
+ PDC_LOG(("PDC_scr_open() - called\n"));
+
+ SP = calloc(1, sizeof(SCREEN));
+ pdc_atrtab = calloc(PDC_COLOR_PAIRS * PDC_OFFSET, 1);
+
+ if (!SP || !pdc_atrtab)
+ return ERR;
+
+ for (i = 0; i < 16; i++)
+ curstoreal[realtocurs[i]] = i;
+
+ pdc_con_out = GetStdHandle(STD_OUTPUT_HANDLE);
+ pdc_con_in = GetStdHandle(STD_INPUT_HANDLE);
+
+ if (GetFileType(pdc_con_in) != FILE_TYPE_CHAR)
+ {
+ fprintf(stderr, "\nRedirection is not supported.\n");
+ exit(1);
+ }
+
+ is_nt = !(GetVersion() & 0x80000000);
+
+ GetConsoleScreenBufferInfo(pdc_con_out, &csbi);
+ GetConsoleScreenBufferInfo(pdc_con_out, &orig_scr);
+ GetConsoleMode(pdc_con_in, &old_console_mode);
+
+ /* preserve QuickEdit Mode setting for use in PDC_mouse_set() when
+ the mouse is not enabled -- other console input settings are
+ cleared */
+
+ pdc_quick_edit = old_console_mode & 0x0040;
+
+ SP->lines = (str = getenv("LINES")) ? atoi(str) : PDC_get_rows();
+ SP->cols = (str = getenv("COLS")) ? atoi(str) : PDC_get_columns();
+
+ SP->mouse_wait = PDC_CLICK_PERIOD;
+ SP->audible = TRUE;
+
+ if (SP->lines < 2 || SP->lines > csbi.dwMaximumWindowSize.Y)
+ {
+ fprintf(stderr, "LINES value must be >= 2 and <= %d: got %d\n",
+ csbi.dwMaximumWindowSize.Y, SP->lines);
+
+ return ERR;
+ }
+
+ if (SP->cols < 2 || SP->cols > csbi.dwMaximumWindowSize.X)
+ {
+ fprintf(stderr, "COLS value must be >= 2 and <= %d: got %d\n",
+ csbi.dwMaximumWindowSize.X, SP->cols);
+
+ return ERR;
+ }
+
+ SP->orig_fore = csbi.wAttributes & 0x0f;
+ SP->orig_back = (csbi.wAttributes & 0xf0) >> 4;
+
+ SP->orig_attr = TRUE;
+
+ SP->_restore = PDC_RESTORE_NONE;
+
+ if (getenv("PDC_RESTORE_SCREEN"))
+ {
+ /* Attempt to save the complete console buffer */
+
+ ci_save = malloc(orig_scr.dwSize.X * orig_scr.dwSize.Y *
+ sizeof(CHAR_INFO));
+
+ if (!ci_save)
+ {
+ PDC_LOG(("PDC_scr_open() - malloc failure (1)\n"));
+
+ return ERR;
+ }
+
+ bufsize.X = orig_scr.dwSize.X;
+ bufsize.Y = orig_scr.dwSize.Y;
+
+ origin.X = origin.Y = 0;
+
+ rect.Top = rect.Left = 0;
+ rect.Bottom = orig_scr.dwSize.Y - 1;
+ rect.Right = orig_scr.dwSize.X - 1;
+
+ if (!ReadConsoleOutput(pdc_con_out, ci_save, bufsize, origin, &rect))
+ {
+ /* We can't save the complete buffer, so try and save just
+ the displayed window */
+
+ free(ci_save);
+ ci_save = NULL;
+
+ bufsize.X = orig_scr.srWindow.Right - orig_scr.srWindow.Left + 1;
+ bufsize.Y = orig_scr.srWindow.Bottom - orig_scr.srWindow.Top + 1;
+
+ ci_save = malloc(bufsize.X * bufsize.Y * sizeof(CHAR_INFO));
+
+ if (!ci_save)
+ {
+ PDC_LOG(("PDC_scr_open() - malloc failure (2)\n"));
+
+ return ERR;
+ }
+
+ origin.X = origin.Y = 0;
+
+ rect.Top = orig_scr.srWindow.Top;
+ rect.Left = orig_scr.srWindow.Left;
+ rect.Bottom = orig_scr.srWindow.Bottom;
+ rect.Right = orig_scr.srWindow.Right;
+
+ if (!ReadConsoleOutput(pdc_con_out, ci_save, bufsize,
+ origin, &rect))
+ {
+#ifdef PDCDEBUG
+ CHAR LastError[256];
+
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL,
+ GetLastError(), MAKELANGID(LANG_NEUTRAL,
+ SUBLANG_DEFAULT), LastError, 256, NULL);
+
+ PDC_LOG(("PDC_scr_open() - %s\n", LastError));
+#endif
+ free(ci_save);
+ ci_save = NULL;
+
+ return ERR;
+ }
+
+ SP->_restore = PDC_RESTORE_WINDOW;
+ }
+ else
+ SP->_restore = PDC_RESTORE_BUFFER;
+ }
+
+ SP->_preserve = (getenv("PDC_PRESERVE_SCREEN") != NULL);
+
+ PDC_reset_prog_mode();
+
+ SP->mono = FALSE;
+
+ return OK;
+}
+
+ /* Calls SetConsoleWindowInfo with the given parameters, but fits them
+ if a scoll bar shrinks the maximum possible value. The rectangle
+ must at least fit in a half-sized window. */
+
+static BOOL _fit_console_window(HANDLE con_out, CONST SMALL_RECT *rect)
+{
+ SMALL_RECT run;
+ SHORT mx, my;
+
+ if (SetConsoleWindowInfo(con_out, TRUE, rect))
+ return TRUE;
+
+ run = *rect;
+ run.Right /= 2;
+ run.Bottom /= 2;
+
+ mx = run.Right;
+ my = run.Bottom;
+
+ if (!SetConsoleWindowInfo(con_out, TRUE, &run))
+ return FALSE;
+
+ for (run.Right = rect->Right; run.Right >= mx; run.Right--)
+ if (SetConsoleWindowInfo(con_out, TRUE, &run))
+ break;
+
+ if (run.Right < mx)
+ return FALSE;
+
+ for (run.Bottom = rect->Bottom; run.Bottom >= my; run.Bottom--)
+ if (SetConsoleWindowInfo(con_out, TRUE, &run))
+ return TRUE;
+
+ return FALSE;
+}
+
+/* the core of resize_term() */
+
+int PDC_resize_screen(int nlines, int ncols)
+{
+ SMALL_RECT rect;
+ COORD size, max;
+
+ if (nlines < 2 || ncols < 2)
+ return ERR;
+
+ max = GetLargestConsoleWindowSize(pdc_con_out);
+
+ rect.Left = rect.Top = 0;
+ rect.Right = ncols - 1;
+
+ if (rect.Right > max.X)
+ rect.Right = max.X;
+
+ rect.Bottom = nlines - 1;
+
+ if (rect.Bottom > max.Y)
+ rect.Bottom = max.Y;
+
+ size.X = rect.Right + 1;
+ size.Y = rect.Bottom + 1;
+
+ _fit_console_window(pdc_con_out, &rect);
+ SetConsoleScreenBufferSize(pdc_con_out, size);
+ _fit_console_window(pdc_con_out, &rect);
+ SetConsoleScreenBufferSize(pdc_con_out, size);
+ SetConsoleActiveScreenBuffer(pdc_con_out);
+
+ return OK;
+}
+
+void PDC_reset_prog_mode(void)
+{
+ PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
+
+ if (is_nt)
+ {
+ COORD bufsize;
+ SMALL_RECT rect;
+
+ bufsize.X = orig_scr.srWindow.Right - orig_scr.srWindow.Left + 1;
+ bufsize.Y = orig_scr.srWindow.Bottom - orig_scr.srWindow.Top + 1;
+
+ rect.Top = rect.Left = 0;
+ rect.Bottom = bufsize.Y - 1;
+ rect.Right = bufsize.X - 1;
+
+ SetConsoleScreenBufferSize(pdc_con_out, bufsize);
+ SetConsoleWindowInfo(pdc_con_out, TRUE, &rect);
+ SetConsoleScreenBufferSize(pdc_con_out, bufsize);
+ SetConsoleActiveScreenBuffer(pdc_con_out);
+ }
+
+ PDC_mouse_set();
+}
+
+void PDC_reset_shell_mode(void)
+{
+ PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
+
+ if (is_nt)
+ {
+ SetConsoleScreenBufferSize(pdc_con_out, orig_scr.dwSize);
+ SetConsoleWindowInfo(pdc_con_out, TRUE, &orig_scr.srWindow);
+ SetConsoleScreenBufferSize(pdc_con_out, orig_scr.dwSize);
+ SetConsoleWindowInfo(pdc_con_out, TRUE, &orig_scr.srWindow);
+ SetConsoleActiveScreenBuffer(pdc_con_out);
+ }
+
+ SetConsoleMode(pdc_con_in, old_console_mode);
+}
+
+void PDC_restore_screen_mode(int i)
+{
+}
+
+void PDC_save_screen_mode(int i)
+{
+}
+
+void PDC_init_pair(short pair, short fg, short bg)
+{
+ unsigned char att, temp_bg;
+ chtype i;
+
+ fg = curstoreal[fg];
+ bg = curstoreal[bg];
+
+ for (i = 0; i < PDC_OFFSET; i++)
+ {
+ att = fg | (bg << 4);
+
+ if (i & (A_REVERSE >> PDC_ATTR_SHIFT))
+ att = bg | (fg << 4);
+ if (i & (A_UNDERLINE >> PDC_ATTR_SHIFT))
+ att = 1;
+ if (i & (A_INVIS >> PDC_ATTR_SHIFT))
+ {
+ temp_bg = att >> 4;
+ att = temp_bg << 4 | temp_bg;
+ }
+ if (i & (A_BOLD >> PDC_ATTR_SHIFT))
+ att |= 8;
+ if (i & (A_BLINK >> PDC_ATTR_SHIFT))
+ att |= 128;
+
+ pdc_atrtab[pair * PDC_OFFSET + i] = att;
+ }
+}
+
+int PDC_pair_content(short pair, short *fg, short *bg)
+{
+ *fg = realtocurs[pdc_atrtab[pair * PDC_OFFSET] & 0x0F];
+ *bg = realtocurs[(pdc_atrtab[pair * PDC_OFFSET] & 0xF0) >> 4];
+
+ return OK;
+}
+
+bool PDC_can_change_color(void)
+{
+ return is_nt;
+}
+
+int PDC_color_content(short color, short *red, short *green, short *blue)
+{
+ DWORD col;
+
+ if (!console_info.Hwnd)
+ _init_console_info();
+
+ col = console_info.ColorTable[curstoreal[color]];
+
+ *red = DIVROUND(GetRValue(col) * 1000, 255);
+ *green = DIVROUND(GetGValue(col) * 1000, 255);
+ *blue = DIVROUND(GetBValue(col) * 1000, 255);
+
+ return OK;
+}
+
+int PDC_init_color(short color, short red, short green, short blue)
+{
+ if (!console_info.Hwnd)
+ _init_console_info();
+
+ console_info.ColorTable[curstoreal[color]] =
+ RGB(DIVROUND(red * 255, 1000),
+ DIVROUND(green * 255, 1000),
+ DIVROUND(blue * 255, 1000));
+
+ _set_console_info();
+
+ return OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcsetsc.c b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcsetsc.c
new file mode 100644
index 0000000000..cfb12315e4
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcsetsc.c
@@ -0,0 +1,89 @@
+/* Public Domain Curses */
+
+#include "pdcwin.h"
+
+RCSID("$Id: pdcsetsc.c,v 1.40 2008/07/14 04:24:52 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: pdcsetsc
+
+ Synopsis:
+ int PDC_set_blink(bool blinkon);
+ void PDC_set_title(const char *title);
+
+ Description:
+ PDC_set_blink() toggles whether the A_BLINK attribute sets an
+ actual blink mode (TRUE), or sets the background color to high
+ intensity (FALSE). The default is platform-dependent (FALSE in
+ most cases). It returns OK if it could set the state to match
+ the given parameter, ERR otherwise. Current platforms also
+ adjust the value of COLORS according to this function -- 16 for
+ FALSE, and 8 for TRUE.
+
+ PDC_set_title() sets the title of the window in which the curses
+ program is running. This function may not do anything on some
+ platforms. (Currently it only works in Win32 and X11.)
+
+ Portability X/Open BSD SYS V
+ PDC_set_blink - - -
+ PDC_set_title - - -
+
+**man-end****************************************************************/
+
+int PDC_curs_set(int visibility)
+{
+ CONSOLE_CURSOR_INFO cci;
+ int ret_vis;
+
+ PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
+
+ ret_vis = SP->visibility;
+
+ if (GetConsoleCursorInfo(pdc_con_out, &cci) == FALSE)
+ return ERR;
+
+ switch(visibility)
+ {
+ case 0: /* invisible */
+ cci.bVisible = FALSE;
+ break;
+ case 2: /* highly visible */
+ cci.bVisible = TRUE;
+ cci.dwSize = 95;
+ break;
+ default: /* normal visibility */
+ cci.bVisible = TRUE;
+ cci.dwSize = SP->orig_cursor;
+ break;
+ }
+
+ if (SetConsoleCursorInfo(pdc_con_out, &cci) == FALSE)
+ return ERR;
+
+ SP->visibility = visibility;
+ return ret_vis;
+}
+
+void PDC_set_title(const char *title)
+{
+#ifdef PDC_WIDE
+ wchar_t wtitle[512];
+#endif
+ PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
+
+#ifdef PDC_WIDE
+ PDC_mbstowcs(wtitle, title, 511);
+ SetConsoleTitleW(wtitle);
+#else
+ SetConsoleTitleA(title);
+#endif
+}
+
+int PDC_set_blink(bool blinkon)
+{
+ if (pdc_color_started)
+ COLORS = 16;
+
+ return blinkon ? ERR : OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcurses.ico b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcurses.ico
new file mode 100644
index 0000000000..53a6dde3c9
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcurses.ico
Binary files differ
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcurses.rc b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcurses.rc
new file mode 100644
index 0000000000..1b8bba4bfc
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcurses.rc
@@ -0,0 +1,28 @@
+#include "winver.h"
+
+1 VERSIONINFO
+ FILEVERSION 3,4,0,0
+ PRODUCTVERSION 3,4,0,0
+ FILEFLAGSMASK 0x3fL
+ FILEFLAGS 0x0L
+ FILEOS VOS_UNKNOWN
+ FILETYPE VFT_DLL
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Maintainer", "William McBrine\0"
+ VALUE "FileDescription", "Public Domain Curses\0"
+ VALUE "FileVersion", "3.4.0\0"
+ VALUE "InternalName", "PDCurses\0"
+ VALUE "LegalCopyright", "Public Domain\0"
+ VALUE "OriginalFilename", "PDCURSES.DLL\0"
+ VALUE "ProductName", "Public Domain Curses Library\0"
+ VALUE "ProductVersion", "3.4.0\0"
+ END
+ END
+END
+
+1 ICON DISCARDABLE "PDCURSES.ico"
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcutil.c b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcutil.c
new file mode 100644
index 0000000000..f7be019e8e
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcutil.c
@@ -0,0 +1,25 @@
+/* Public Domain Curses */
+
+#include "pdcwin.h"
+
+RCSID("$Id: pdcutil.c,v 1.14 2008/07/14 04:24:52 wmcbrine Exp $")
+
+void PDC_beep(void)
+{
+ PDC_LOG(("PDC_beep() - called\n"));
+
+/* MessageBeep(MB_OK); */
+ MessageBeep(0XFFFFFFFF);
+}
+
+void PDC_napms(int ms)
+{
+ PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
+
+ Sleep(ms);
+}
+
+const char *PDC_sysname(void)
+{
+ return "Win32";
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/pdcwin.h b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcwin.h
new file mode 100644
index 0000000000..bb3396f078
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/pdcwin.h
@@ -0,0 +1,17 @@
+/* Public Domain Curses */
+
+/* $Id: pdcwin.h,v 1.6 2008/07/13 06:36:32 wmcbrine Exp $ */
+
+#ifdef PDC_WIDE
+# define UNICODE
+#endif
+
+#include <windows.h>
+#undef MOUSE_MOVED
+#include <curspriv.h>
+
+extern unsigned char *pdc_atrtab;
+extern HANDLE pdc_con_out, pdc_con_in;
+extern DWORD pdc_quick_edit;
+
+extern int PDC_get_buffer_rows(void);
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/vcwin32.mak b/payloads/libpayload/curses/PDCurses-3.4/win32/vcwin32.mak
new file mode 100644
index 0000000000..b8dc4043b7
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/vcwin32.mak
@@ -0,0 +1,136 @@
+# Visual C++ NMakefile for PDCurses library - Win32 VC++ 2.0+
+#
+# Usage: nmake -f [path\]vcwin32.mak [DEBUG=] [DLL=] [WIDE=] [UTF8=] [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.lib|testcurs.exe...]
+
+O = obj
+
+!ifndef PDCURSES_SRCDIR
+PDCURSES_SRCDIR = ..
+!endif
+
+!include $(PDCURSES_SRCDIR)\version.mif
+!include $(PDCURSES_SRCDIR)\libobjs.mif
+
+osdir = $(PDCURSES_SRCDIR)\win32
+
+PDCURSES_WIN_H = $(osdir)\pdcwin.h
+
+CC = cl.exe -nologo
+
+!ifdef DEBUG
+CFLAGS = -Z7 -DPDCDEBUG
+LDFLAGS = -debug -pdb:none
+!else
+CFLAGS = -O1
+LDFLAGS =
+!endif
+
+BASEDEF = $(PDCURSES_SRCDIR)\exp-base.def
+WIDEDEF = $(PDCURSES_SRCDIR)\exp-wide.def
+
+DEFDEPS = $(BASEDEF)
+
+!ifdef WIDE
+WIDEOPT = -DPDC_WIDE
+DEFDEPS = $(DEFDEPS) $(WIDEDEF)
+!endif
+
+!ifdef UTF8
+UTF8OPT = -DPDC_FORCE_UTF8
+!endif
+
+DEFFILE = pdcurses.def
+SHL_LD = link $(LDFLAGS) /NOLOGO /DLL /OUT:pdcurses.dll /DEF:$(DEFFILE)
+
+LINK = link.exe -nologo
+
+CCLIBS = user32.lib advapi32.lib
+# may need to add msvcrt.lib for VC 2.x, VC 5.0 doesn't want it
+#CCLIBS = msvcrt.lib user32.lib advapi32.lib
+
+LIBEXE = lib -nologo
+
+LIBCURSES = pdcurses.lib
+CURSESDLL = pdcurses.dll
+
+!ifdef DLL
+DLLOPT = -DPDC_DLL_BUILD
+PDCLIBS = $(CURSESDLL)
+!else
+PDCLIBS = $(LIBCURSES)
+!endif
+
+BUILD = $(CC) -I$(PDCURSES_SRCDIR) -c $(CFLAGS) $(DLLOPT) \
+$(WIDEOPT) $(UTF8OPT)
+
+all: $(PDCLIBS) $(DEMOS)
+
+clean:
+ -del *.obj
+ -del *.lib
+ -del *.exe
+ -del *.dll
+ -del *.exp
+ -del *.res
+ -del *.def
+
+DEMOOBJS = $(DEMOS:.exe=.obj) tui.obj
+
+$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
+$(PDCOBJS) : $(PDCURSES_WIN_H)
+$(DEMOOBJS) : $(PDCURSES_CURSES_H)
+$(DEMOS) : $(LIBCURSES)
+panel.obj : $(PANEL_HEADER)
+terminfo.obj: $(TERM_HEADER)
+
+!ifndef DLL
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ $(LIBEXE) -out:$@ $(LIBOBJS) $(PDCOBJS)
+ -copy $(LIBCURSES) panel.lib
+!endif
+
+$(DEFFILE) : $(DEFDEPS)
+ echo LIBRARY pdcurses > $(DEFFILE)
+ echo EXPORTS >> $(DEFFILE)
+ type $(BASEDEF) >> $(DEFFILE)
+!ifdef WIDE
+ type $(WIDEDEF) >> $(DEFFILE)
+!endif
+
+$(CURSESDLL) : $(LIBOBJS) $(PDCOBJS) $(DEFFILE) pdcurses.obj
+ $(SHL_LD) $(LIBOBJS) $(PDCOBJS) pdcurses.obj $(CCLIBS)
+ -copy $(LIBCURSES) panel.lib
+
+pdcurses.res pdcurses.obj: $(osdir)\pdcurses.rc $(osdir)\pdcurses.ico
+ rc /r /fopdcurses.res $(osdir)\pdcurses.rc
+ cvtres /MACHINE:IX86 /NOLOGO /OUT:pdcurses.obj pdcurses.res
+
+{$(srcdir)\}.c{}.obj::
+ $(BUILD) $<
+
+{$(osdir)\}.c{}.obj::
+ $(BUILD) $<
+
+{$(demodir)\}.c{}.obj::
+ $(BUILD) $<
+
+.obj.exe:
+ $(LINK) $(LDFLAGS) $< $(LIBCURSES) $(CCLIBS)
+
+tuidemo.exe: tuidemo.obj tui.obj
+ $(LINK) $(LDFLAGS) $*.obj tui.obj $(LIBCURSES) $(CCLIBS)
+
+tui.obj: $(demodir)\tui.c $(demodir)\tui.h
+ $(BUILD) -I$(demodir) $(demodir)\tui.c
+
+tuidemo.obj: $(demodir)\tuidemo.c
+ $(BUILD) -I$(demodir) $(demodir)\tuidemo.c
+
+PLATFORM1 = Visual C++
+PLATFORM2 = Microsoft Visual C/C++ for Win32
+ARCNAME = pdc$(VER)_vc_w32
+
+!include $(PDCURSES_SRCDIR)\makedist.mif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/win32/wccwin32.mak b/payloads/libpayload/curses/PDCurses-3.4/win32/wccwin32.mak
new file mode 100644
index 0000000000..1363897be0
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/win32/wccwin32.mak
@@ -0,0 +1,51 @@
+# Watcom WMAKE Makefile for PDCurses library - Win32 Watcom C/C++ 10.6+
+#
+# Usage: wmake -f [win32\]wccwin32.mak [DEBUG=Y] [WIDE=Y] [UTF8=Y] [target]
+#
+# where target can be any of:
+# [all|demos|pdcurses.lib|testcurs.exe...]
+
+!ifdef %PDCURSES_SRCDIR
+PDCURSES_SRCDIR = $(%PDCURSES_SRCDIR)
+!else
+PDCURSES_SRCDIR = ..
+!endif
+
+!include $(PDCURSES_SRCDIR)\version.mif
+
+osdir = $(PDCURSES_SRCDIR)\win32
+
+CC = wcc386
+TARGET = nt
+
+CFLAGS = /ei /zq /wx /i=$(PDCURSES_SRCDIR)
+
+!ifeq DEBUG Y
+CFLAGS += /d2 /DPDCDEBUG
+LDFLAGS = D W A op q sys $(TARGET)
+!else
+CFLAGS += /oneatx
+LDFLAGS = op q sys $(TARGET)
+!endif
+
+!ifeq WIDE Y
+CFLAGS += /DPDC_WIDE
+!endif
+
+!ifeq UTF8 Y
+CFLAGS += /DPDC_FORCE_UTF8
+!endif
+
+LIBEXE = wlib /q /n /t
+
+!include $(PDCURSES_SRCDIR)\watcom.mif
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ $(LIBEXE) $@ $(LIBOBJS) $(PDCOBJS)
+ -copy $(LIBCURSES) panel.lib
+
+PLATFORM1 = Watcom C++ Win32
+PLATFORM2 = Open Watcom 1.6 for Win32
+ARCNAME = pdc$(VER)_wcc_w32
+
+!include $(PDCURSES_SRCDIR)\makedist.mif
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/Makefile.aix.in b/payloads/libpayload/curses/PDCurses-3.4/x11/Makefile.aix.in
new file mode 100644
index 0000000000..0fe5db78ed
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/Makefile.aix.in
@@ -0,0 +1,234 @@
+# Makefile for PDCurses library for AIX/X11
+
+SHELL = @SHELL@
+THIS = Makefile
+
+@SET_MAKE@
+
+PDCURSES_SRCDIR = ..
+
+osdir = .
+srcdir = $(PDCURSES_SRCDIR)/pdcurses
+
+PDCURSES_CONFIG_H =$(PDCURSES_SRCDIR)/config.h
+PDCURSES_CURSES_H =$(PDCURSES_SRCDIR)/curses.h
+PDCURSES_CURSPRIV_H =$(PDCURSES_SRCDIR)/curspriv.h
+PDCURSES_HEADERS =$(PDCURSES_CONFIG_H) $(PDCURSES_CURSES_H) \
+$(PDCURSES_CURSPRIV_H)
+PDCURSES_X11_H =$(osdir)/pdcx11.h
+
+MH_EXTRA_LIBS = @MH_EXTRA_LIBS@
+
+CFLAGS = @CFLAGS@ @DYN_COMP@
+
+CPPFLAGS = @DEFS@ -DXCURSES @SYS_DEFS@ -I$(PDCURSES_SRCDIR)
+
+BUILD = @CC@ -c $(CFLAGS) $(CPPFLAGS) @MH_XINC_DIR@
+
+LINK = @CC@
+LDFLAGS =
+
+LIBCURSES = libXCurses.a
+
+all : $(LIBCURSES)
+
+install :
+ echo Does nothing at the moment
+
+clean :
+ -rm -rf *.o *.sho trace $(LIBCURSES)
+
+distclean: clean
+ -rm -f Makefile
+
+mostlyclean: clean
+
+realclean: distclean
+
+LIBOBJS = addch.o addchstr.o addstr.o attr.o beep.o bkgd.o border.o \
+clear.o color.o delch.o deleteln.o deprec.o getch.o getstr.o getyx.o \
+inch.o inchstr.o initscr.o inopts.o insch.o insstr.o instr.o kernel.o \
+keyname.o mouse.o move.o outopts.o overlay.o pad.o panel.o printw.o \
+refresh.o scanw.o scr_dump.o scroll.o slk.o termattr.o terminfo.o \
+touch.o util.o window.o debug.o
+
+PDCOBJS = pdcclip.o pdcdisp.o pdcgetsc.o pdckbd.o pdcscrn.o pdcsetsc.o \
+pdcutil.o pdcx11.o x11.o sb.o ScrollBox.o
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS) curses.exp
+ ld -bnoentry -bM:SRE -bE:curses.exp $(MH_LIBS) $(MH_EXTRA_LIBS) \
+$(LIBOBJS) $(PDCOBJS) -o $@
+
+$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
+$(PDCOBJS) : $(PDCURSES_X11_H)
+terminfo.o: $(TERM_HEADER)
+
+curses.exp: ../exp-base.def
+ cat ../exp-base.def > curses.exp
+ echo Xinitscr >> curses.exp
+ echo XCursesExit >> curses.exp
+ echo sb_init >> curses.exp
+ echo sb_set_horz >> curses.exp
+ echo sb_set_vert >> curses.exp
+ echo sb_get_horz >> curses.exp
+ echo sb_get_vert >> curses.exp
+ echo sb_refresh >> curses.exp
+
+addch.o: $(srcdir)/addch.c
+ $(BUILD) $(srcdir)/addch.c
+
+addchstr.o: $(srcdir)/addchstr.c
+ $(BUILD) $(srcdir)/addchstr.c
+
+addstr.o: $(srcdir)/addstr.c
+ $(BUILD) $(srcdir)/addstr.c
+
+attr.o: $(srcdir)/attr.c
+ $(BUILD) $(srcdir)/attr.c
+
+beep.o: $(srcdir)/beep.c
+ $(BUILD) $(srcdir)/beep.c
+
+bkgd.o: $(srcdir)/bkgd.c
+ $(BUILD) $(srcdir)/bkgd.c
+
+border.o: $(srcdir)/border.c
+ $(BUILD) $(srcdir)/border.c
+
+clear.o: $(srcdir)/clear.c
+ $(BUILD) $(srcdir)/clear.c
+
+color.o: $(srcdir)/color.c
+ $(BUILD) $(srcdir)/color.c
+
+delch.o: $(srcdir)/delch.c
+ $(BUILD) $(srcdir)/delch.c
+
+deleteln.o: $(srcdir)/deleteln.c
+ $(BUILD) $(srcdir)/deleteln.c
+
+deprec.o: $(srcdir)/deprec.c
+ $(BUILD) $(srcdir)/deprec.c
+
+getch.o: $(srcdir)/getch.c
+ $(BUILD) $(srcdir)/getch.c
+
+getstr.o: $(srcdir)/getstr.c
+ $(BUILD) $(srcdir)/getstr.c
+
+getyx.o: $(srcdir)/getyx.c
+ $(BUILD) $(srcdir)/getyx.c
+
+inch.o: $(srcdir)/inch.c
+ $(BUILD) $(srcdir)/inch.c
+
+inchstr.o: $(srcdir)/inchstr.c
+ $(BUILD) $(srcdir)/inchstr.c
+
+initscr.o: $(srcdir)/initscr.c
+ $(BUILD) $(srcdir)/initscr.c
+
+inopts.o: $(srcdir)/inopts.c
+ $(BUILD) $(srcdir)/inopts.c
+
+insch.o: $(srcdir)/insch.c
+ $(BUILD) $(srcdir)/insch.c
+
+insstr.o: $(srcdir)/insstr.c
+ $(BUILD) $(srcdir)/insstr.c
+
+instr.o: $(srcdir)/instr.c
+ $(BUILD) $(srcdir)/instr.c
+
+kernel.o: $(srcdir)/kernel.c
+ $(BUILD) $(srcdir)/kernel.c
+
+keyname.o: $(srcdir)/keyname.c
+ $(BUILD) $(srcdir)/keyname.c
+
+mouse.o: $(srcdir)/mouse.c
+ $(BUILD) $(srcdir)/mouse.c
+
+move.o: $(srcdir)/move.c
+ $(BUILD) $(srcdir)/move.c
+
+outopts.o: $(srcdir)/outopts.c
+ $(BUILD) $(srcdir)/outopts.c
+
+overlay.o: $(srcdir)/overlay.c
+ $(BUILD) $(srcdir)/overlay.c
+
+pad.o: $(srcdir)/pad.c
+ $(BUILD) $(srcdir)/pad.c
+
+panel.o: $(srcdir)/panel.c $(PDCURSES_SRCDIR)/panel.h
+ $(BUILD) $(srcdir)/panel.c
+
+printw.o: $(srcdir)/printw.c
+ $(BUILD) $(srcdir)/printw.c
+
+refresh.o: $(srcdir)/refresh.c
+ $(BUILD) $(srcdir)/refresh.c
+
+scanw.o: $(srcdir)/scanw.c
+ $(BUILD) $(srcdir)/scanw.c
+
+scr_dump.o: $(srcdir)/scr_dump.c
+ $(BUILD) $(srcdir)/scr_dump.c
+
+scroll.o: $(srcdir)/scroll.c
+ $(BUILD) $(srcdir)/scroll.c
+
+slk.o: $(srcdir)/slk.c
+ $(BUILD) $(srcdir)/slk.c
+
+termattr.o: $(srcdir)/termattr.c
+ $(BUILD) $(srcdir)/termattr.c
+
+terminfo.o: $(srcdir)/terminfo.c
+ $(BUILD) $(srcdir)/terminfo.c
+
+touch.o: $(srcdir)/touch.c
+ $(BUILD) $(srcdir)/touch.c
+
+util.o: $(srcdir)/util.c
+ $(BUILD) $(srcdir)/util.c
+
+window.o: $(srcdir)/window.c
+ $(BUILD) $(srcdir)/window.c
+
+debug.o: $(srcdir)/debug.c
+ $(BUILD) $(srcdir)/debug.c
+
+pdcclip.o: $(osdir)/pdcclip.c
+ $(BUILD) $(osdir)/pdcclip.c
+
+pdcdisp.o: $(osdir)/pdcdisp.c
+ $(BUILD) $(osdir)/pdcdisp.c
+
+pdcgetsc.o: $(osdir)/pdcgetsc.c
+ $(BUILD) $(osdir)/pdcgetsc.c
+
+pdckbd.o: $(osdir)/pdckbd.c
+ $(BUILD) $(osdir)/pdckbd.c
+
+pdcscrn.o: $(osdir)/pdcscrn.c
+ $(BUILD) $(osdir)/pdcscrn.c
+
+pdcsetsc.o: $(osdir)/pdcsetsc.c
+ $(BUILD) $(osdir)/pdcsetsc.c
+
+pdcutil.o: $(osdir)/pdcutil.c
+ $(BUILD) $(osdir)/pdcutil.c
+
+pdcx11.o: $(osdir)/pdcx11.c
+ $(BUILD) $(osdir)/pdcx11.c
+
+ScrollBox.o: $(osdir)/ScrollBox.c
+ $(BUILD) $(osdir)/ScrollBox.c
+
+sb.o: $(osdir)/sb.c
+ $(BUILD) $(osdir)/sb.c
+
+x11.o: $(osdir)/x11.c
+ $(BUILD) $(osdir)/x11.c
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/Makefile.in b/payloads/libpayload/curses/PDCurses-3.4/x11/Makefile.in
new file mode 100644
index 0000000000..d23a214fb3
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/Makefile.in
@@ -0,0 +1,572 @@
+# Makefile for PDCurses library for X11
+
+SHELL = @SHELL@
+THIS = Makefile
+
+@SET_MAKE@
+
+PDCURSES_SRCDIR = ..
+
+osdir = .
+srcdir = $(PDCURSES_SRCDIR)/pdcurses
+demodir = $(PDCURSES_SRCDIR)/demos
+
+PDCURSES_CONFIG_H =$(PDCURSES_SRCDIR)/config.h
+PDCURSES_CURSES_H =$(PDCURSES_SRCDIR)/curses.h
+PDCURSES_CURSPRIV_H =$(PDCURSES_SRCDIR)/curspriv.h
+PDCURSES_HEADERS =$(PDCURSES_CONFIG_H) $(PDCURSES_CURSES_H) \
+$(PDCURSES_CURSPRIV_H)
+PDCURSES_X11_H =$(osdir)/pdcx11.h
+
+SHLPRE = @SHLPRE@
+SHLPST = @SHLPST@
+LD_RXLIB1 = @LD_RXLIB1@
+LD_RXLIB2 = @MH_XLIBS@ @MH_EXTRA_LIBS@ -lc
+
+CFLAGS = @CFLAGS@
+
+CPPFLAGS = @DEFS@ -DXCURSES @SYS_DEFS@ -I$(PDCURSES_SRCDIR)
+
+BUILD = @CC@ -c $(CFLAGS) $(CPPFLAGS) @MH_XINC_DIR@
+DYN_BUILD = @O2SAVE@ $(BUILD) @DYN_COMP@ @CC2O@
+
+LINK = @PURIFY@ @CC@
+#LDFLAGS = $(LIB_DEPS) @LDFLAGS@ @LIBS@ @MH_XLIBS@ @MH_EXTRA_LIBS@
+LDFLAGS = $(LIBCURSES) @LDFLAGS@ @LIBS@ @MH_XLIBS@ @MH_EXTRA_LIBS@
+
+RANLIB = @RANLIB@
+
+LIBCURSES = libXCurses.a
+
+LIB_DEPS = -L$(PDCURSES_SRCDIR)/x11 -lXCurses
+
+PDCLIBS = $(LIBCURSES) @SHL_TARGETS@
+
+DEMOS = firework newdemo ptest rain testcurs tuidemo worm xmas
+DEMOOBJS = firework.o newdemo.o ptest.o rain.o testcurs.o tui.o \
+tuidemo.o worm.o xmas.o
+
+SHLFILE = XCurses
+
+all: $(PDCLIBS) $(DEMOS)
+
+install:
+ echo Does nothing at the moment
+
+clean:
+ -rm -rf *.o *.sho trace $(PDCLIBS) $(DEMOS)
+
+demos: $(DEMOS)
+
+distclean: clean
+ -rm -f Makefile
+
+mostlyclean: clean
+
+realclean: distclean
+
+LIBOBJS = addch.o addchstr.o addstr.o attr.o beep.o bkgd.o border.o \
+clear.o color.o delch.o deleteln.o deprec.o getch.o getstr.o getyx.o \
+inch.o inchstr.o initscr.o inopts.o insch.o insstr.o instr.o kernel.o \
+keyname.o mouse.o move.o outopts.o overlay.o pad.o panel.o printw.o \
+refresh.o scanw.o scr_dump.o scroll.o slk.o termattr.o terminfo.o \
+touch.o util.o window.o debug.o
+
+PDCOBJS = pdcclip.o pdcdisp.o pdcgetsc.o pdckbd.o pdcscrn.o pdcsetsc.o \
+pdcutil.o pdcx11.o x11.o sb.o ScrollBox.o
+
+LIBSHOBJS = $(LIBOBJS:.o=.sho)
+PDCSHOBJS = $(PDCOBJS:.o=.sho)
+
+SHOFILES = $(LIBSHOBJS) $(PDCSHOBJS)
+
+$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
+ ar rv $@ $?
+ -$(RANLIB) $@
+
+$(SHLPRE)$(SHLFILE)$(SHLPST) : $(SHOFILES)
+ $(LD_RXLIB1) -o $@ $(SHOFILES) $(LD_RXLIB2)
+
+$(LIBOBJS) $(PDCOBJS) $(SHOFILES) : $(PDCURSES_HEADERS)
+$(PDCOBJS) $(PDCSHOBJS) : $(PDCURSES_X11_H)
+$(DEMOOBJS) : $(PDCURSES_CURSES_H)
+$(DEMOS) : $(LIBCURSES)
+terminfo.o terminfo.sho: $(TERM_HEADER)
+
+addch.o: $(srcdir)/addch.c
+ $(BUILD) $(srcdir)/addch.c
+
+addchstr.o: $(srcdir)/addchstr.c
+ $(BUILD) $(srcdir)/addchstr.c
+
+addstr.o: $(srcdir)/addstr.c
+ $(BUILD) $(srcdir)/addstr.c
+
+attr.o: $(srcdir)/attr.c
+ $(BUILD) $(srcdir)/attr.c
+
+beep.o: $(srcdir)/beep.c
+ $(BUILD) $(srcdir)/beep.c
+
+bkgd.o: $(srcdir)/bkgd.c
+ $(BUILD) $(srcdir)/bkgd.c
+
+border.o: $(srcdir)/border.c
+ $(BUILD) $(srcdir)/border.c
+
+clear.o: $(srcdir)/clear.c
+ $(BUILD) $(srcdir)/clear.c
+
+color.o: $(srcdir)/color.c
+ $(BUILD) $(srcdir)/color.c
+
+delch.o: $(srcdir)/delch.c
+ $(BUILD) $(srcdir)/delch.c
+
+deleteln.o: $(srcdir)/deleteln.c
+ $(BUILD) $(srcdir)/deleteln.c
+
+deprec.o: $(srcdir)/deprec.c
+ $(BUILD) $(srcdir)/deprec.c
+
+getch.o: $(srcdir)/getch.c
+ $(BUILD) $(srcdir)/getch.c
+
+getstr.o: $(srcdir)/getstr.c
+ $(BUILD) $(srcdir)/getstr.c
+
+getyx.o: $(srcdir)/getyx.c
+ $(BUILD) $(srcdir)/getyx.c
+
+inch.o: $(srcdir)/inch.c
+ $(BUILD) $(srcdir)/inch.c
+
+inchstr.o: $(srcdir)/inchstr.c
+ $(BUILD) $(srcdir)/inchstr.c
+
+initscr.o: $(srcdir)/initscr.c
+ $(BUILD) $(srcdir)/initscr.c
+
+inopts.o: $(srcdir)/inopts.c
+ $(BUILD) $(srcdir)/inopts.c
+
+insch.o: $(srcdir)/insch.c
+ $(BUILD) $(srcdir)/insch.c
+
+insstr.o: $(srcdir)/insstr.c
+ $(BUILD) $(srcdir)/insstr.c
+
+instr.o: $(srcdir)/instr.c
+ $(BUILD) $(srcdir)/instr.c
+
+kernel.o: $(srcdir)/kernel.c
+ $(BUILD) $(srcdir)/kernel.c
+
+keyname.o: $(srcdir)/keyname.c
+ $(BUILD) $(srcdir)/keyname.c
+
+mouse.o: $(srcdir)/mouse.c
+ $(BUILD) $(srcdir)/mouse.c
+
+move.o: $(srcdir)/move.c
+ $(BUILD) $(srcdir)/move.c
+
+outopts.o: $(srcdir)/outopts.c
+ $(BUILD) $(srcdir)/outopts.c
+
+overlay.o: $(srcdir)/overlay.c
+ $(BUILD) $(srcdir)/overlay.c
+
+pad.o: $(srcdir)/pad.c
+ $(BUILD) $(srcdir)/pad.c
+
+panel.o: $(srcdir)/panel.c $(PDCURSES_SRCDIR)/panel.h
+ $(BUILD) $(srcdir)/panel.c
+
+printw.o: $(srcdir)/printw.c
+ $(BUILD) $(srcdir)/printw.c
+
+refresh.o: $(srcdir)/refresh.c
+ $(BUILD) $(srcdir)/refresh.c
+
+scanw.o: $(srcdir)/scanw.c
+ $(BUILD) $(srcdir)/scanw.c
+
+scr_dump.o: $(srcdir)/scr_dump.c
+ $(BUILD) $(srcdir)/scr_dump.c
+
+scroll.o: $(srcdir)/scroll.c
+ $(BUILD) $(srcdir)/scroll.c
+
+slk.o: $(srcdir)/slk.c
+ $(BUILD) $(srcdir)/slk.c
+
+termattr.o: $(srcdir)/termattr.c
+ $(BUILD) $(srcdir)/termattr.c
+
+terminfo.o: $(srcdir)/terminfo.c
+ $(BUILD) $(srcdir)/terminfo.c
+
+touch.o: $(srcdir)/touch.c
+ $(BUILD) $(srcdir)/touch.c
+
+util.o: $(srcdir)/util.c
+ $(BUILD) $(srcdir)/util.c
+
+window.o: $(srcdir)/window.c
+ $(BUILD) $(srcdir)/window.c
+
+debug.o: $(srcdir)/debug.c
+ $(BUILD) $(srcdir)/debug.c
+
+pdcclip.o: $(osdir)/pdcclip.c
+ $(BUILD) $(osdir)/pdcclip.c
+
+pdcdisp.o: $(osdir)/pdcdisp.c
+ $(BUILD) $(osdir)/pdcdisp.c
+
+pdcgetsc.o: $(osdir)/pdcgetsc.c
+ $(BUILD) $(osdir)/pdcgetsc.c
+
+pdckbd.o: $(osdir)/pdckbd.c
+ $(BUILD) $(osdir)/pdckbd.c
+
+pdcscrn.o: $(osdir)/pdcscrn.c
+ $(BUILD) $(osdir)/pdcscrn.c
+
+pdcsetsc.o: $(osdir)/pdcsetsc.c
+ $(BUILD) $(osdir)/pdcsetsc.c
+
+pdcutil.o: $(osdir)/pdcutil.c
+ $(BUILD) $(osdir)/pdcutil.c
+
+pdcx11.o: $(osdir)/pdcx11.c
+ $(BUILD) $(osdir)/pdcx11.c
+
+ScrollBox.o: $(osdir)/ScrollBox.c
+ $(BUILD) $(osdir)/ScrollBox.c
+
+sb.o: $(osdir)/sb.c
+ $(BUILD) $(osdir)/sb.c
+
+x11.o: $(osdir)/x11.c
+ $(BUILD) $(osdir)/x11.c
+
+addch.sho: $(srcdir)/addch.c
+ $(DYN_BUILD) $(srcdir)/addch.c
+ @SAVE2O@
+
+addchstr.sho: $(srcdir)/addchstr.c
+ $(DYN_BUILD) $(srcdir)/addchstr.c
+ @SAVE2O@
+
+addstr.sho: $(srcdir)/addstr.c
+ $(DYN_BUILD) $(srcdir)/addstr.c
+ @SAVE2O@
+
+attr.sho: $(srcdir)/attr.c
+ $(DYN_BUILD) $(srcdir)/attr.c
+ @SAVE2O@
+
+beep.sho: $(srcdir)/beep.c
+ $(DYN_BUILD) $(srcdir)/beep.c
+ @SAVE2O@
+
+bkgd.sho: $(srcdir)/bkgd.c
+ $(DYN_BUILD) $(srcdir)/bkgd.c
+ @SAVE2O@
+
+border.sho: $(srcdir)/border.c
+ $(DYN_BUILD) $(srcdir)/border.c
+ @SAVE2O@
+
+clear.sho: $(srcdir)/clear.c
+ $(DYN_BUILD) $(srcdir)/clear.c
+ @SAVE2O@
+
+color.sho: $(srcdir)/color.c
+ $(DYN_BUILD) $(srcdir)/color.c
+ @SAVE2O@
+
+delch.sho: $(srcdir)/delch.c
+ $(DYN_BUILD) $(srcdir)/delch.c
+ @SAVE2O@
+
+deleteln.sho: $(srcdir)/deleteln.c
+ $(DYN_BUILD) $(srcdir)/deleteln.c
+ @SAVE2O@
+
+deprec.sho: $(srcdir)/deprec.c
+ $(DYN_BUILD) $(srcdir)/deprec.c
+ @SAVE2O@
+
+getch.sho: $(srcdir)/getch.c
+ $(DYN_BUILD) $(srcdir)/getch.c
+ @SAVE2O@
+
+getstr.sho: $(srcdir)/getstr.c
+ $(DYN_BUILD) $(srcdir)/getstr.c
+ @SAVE2O@
+
+getyx.sho: $(srcdir)/getyx.c
+ $(DYN_BUILD) $(srcdir)/getyx.c
+ @SAVE2O@
+
+inch.sho: $(srcdir)/inch.c
+ $(DYN_BUILD) $(srcdir)/inch.c
+ @SAVE2O@
+
+inchstr.sho: $(srcdir)/inchstr.c
+ $(DYN_BUILD) $(srcdir)/inchstr.c
+ @SAVE2O@
+
+initscr.sho: $(srcdir)/initscr.c
+ $(DYN_BUILD) $(srcdir)/initscr.c
+ @SAVE2O@
+
+inopts.sho: $(srcdir)/inopts.c
+ $(DYN_BUILD) $(srcdir)/inopts.c
+ @SAVE2O@
+
+insch.sho: $(srcdir)/insch.c
+ $(DYN_BUILD) $(srcdir)/insch.c
+ @SAVE2O@
+
+insstr.sho: $(srcdir)/insstr.c
+ $(DYN_BUILD) $(srcdir)/insstr.c
+ @SAVE2O@
+
+instr.sho: $(srcdir)/instr.c
+ $(DYN_BUILD) $(srcdir)/instr.c
+ @SAVE2O@
+
+kernel.sho: $(srcdir)/kernel.c
+ $(DYN_BUILD) $(srcdir)/kernel.c
+ @SAVE2O@
+
+keyname.sho: $(srcdir)/keyname.c
+ $(DYN_BUILD) $(srcdir)/keyname.c
+ @SAVE2O@
+
+mouse.sho: $(srcdir)/mouse.c
+ $(DYN_BUILD) $(srcdir)/mouse.c
+ @SAVE2O@
+
+move.sho: $(srcdir)/move.c
+ $(DYN_BUILD) $(srcdir)/move.c
+ @SAVE2O@
+
+outopts.sho: $(srcdir)/outopts.c
+ $(DYN_BUILD) $(srcdir)/outopts.c
+ @SAVE2O@
+
+overlay.sho: $(srcdir)/overlay.c
+ $(DYN_BUILD) $(srcdir)/overlay.c
+ @SAVE2O@
+
+pad.sho: $(srcdir)/pad.c
+ $(DYN_BUILD) $(srcdir)/pad.c
+ @SAVE2O@
+
+panel.sho: $(srcdir)/panel.c $(PDCURSES_SRCDIR)/panel.h
+ $(DYN_BUILD) $(srcdir)/panel.c
+ @SAVE2O@
+
+printw.sho: $(srcdir)/printw.c
+ $(DYN_BUILD) $(srcdir)/printw.c
+ @SAVE2O@
+
+refresh.sho: $(srcdir)/refresh.c
+ $(DYN_BUILD) $(srcdir)/refresh.c
+ @SAVE2O@
+
+scanw.sho: $(srcdir)/scanw.c
+ $(DYN_BUILD) $(srcdir)/scanw.c
+ @SAVE2O@
+
+scr_dump.sho: $(srcdir)/scr_dump.c
+ $(DYN_BUILD) $(srcdir)/scr_dump.c
+ @SAVE2O@
+
+scroll.sho: $(srcdir)/scroll.c
+ $(DYN_BUILD) $(srcdir)/scroll.c
+ @SAVE2O@
+
+slk.sho: $(srcdir)/slk.c
+ $(DYN_BUILD) $(srcdir)/slk.c
+ @SAVE2O@
+
+termattr.sho: $(srcdir)/termattr.c
+ $(DYN_BUILD) $(srcdir)/termattr.c
+ @SAVE2O@
+
+terminfo.sho: $(srcdir)/terminfo.c
+ $(DYN_BUILD) $(srcdir)/terminfo.c
+ @SAVE2O@
+
+touch.sho: $(srcdir)/touch.c
+ $(DYN_BUILD) $(srcdir)/touch.c
+ @SAVE2O@
+
+util.sho: $(srcdir)/util.c
+ $(DYN_BUILD) $(srcdir)/util.c
+ @SAVE2O@
+
+window.sho: $(srcdir)/window.c
+ $(DYN_BUILD) $(srcdir)/window.c
+ @SAVE2O@
+
+debug.sho: $(srcdir)/debug.c
+ $(DYN_BUILD) $(srcdir)/debug.c
+ @SAVE2O@
+
+pdcclip.sho: $(osdir)/pdcclip.c
+ $(DYN_BUILD) $(osdir)/pdcclip.c
+ @SAVE2O@
+
+pdcdisp.sho: $(osdir)/pdcdisp.c
+ $(DYN_BUILD) $(osdir)/pdcdisp.c
+ @SAVE2O@
+
+pdcgetsc.sho: $(osdir)/pdcgetsc.c
+ $(DYN_BUILD) $(osdir)/pdcgetsc.c
+ @SAVE2O@
+
+pdckbd.sho: $(osdir)/pdckbd.c
+ $(DYN_BUILD) $(osdir)/pdckbd.c
+ @SAVE2O@
+
+pdcscrn.sho: $(osdir)/pdcscrn.c
+ $(DYN_BUILD) $(osdir)/pdcscrn.c
+ @SAVE2O@
+
+pdcsetsc.sho: $(osdir)/pdcsetsc.c
+ $(DYN_BUILD) $(osdir)/pdcsetsc.c
+ @SAVE2O@
+
+pdcutil.sho: $(osdir)/pdcutil.c
+ $(DYN_BUILD) $(osdir)/pdcutil.c
+ @SAVE2O@
+
+pdcx11.sho: $(osdir)/pdcx11.c
+ $(DYN_BUILD) $(osdir)/pdcx11.c
+ @SAVE2O@
+
+ScrollBox.sho: $(osdir)/ScrollBox.c
+ $(DYN_BUILD) $(osdir)/ScrollBox.c
+ @SAVE2O@
+
+sb.sho: $(osdir)/sb.c
+ $(DYN_BUILD) $(osdir)/sb.c
+ @SAVE2O@
+
+x11.sho: $(osdir)/x11.c
+ $(DYN_BUILD) $(osdir)/x11.c
+ @SAVE2O@
+
+firework: firework.o
+ $(LINK) firework.o -o $@ $(LDFLAGS)
+
+newdemo: newdemo.o
+ $(LINK) newdemo.o -o $@ $(LDFLAGS)
+
+ptest: ptest.o
+ $(LINK) ptest.o -o $@ $(LDFLAGS)
+
+rain: rain.o
+ $(LINK) rain.o -o $@ $(LDFLAGS)
+
+testcurs: testcurs.o
+ $(LINK) testcurs.o -o $@ $(LDFLAGS)
+
+tuidemo: tuidemo.o tui.o
+ $(LINK) tui.o tuidemo.o -o $@ $(LDFLAGS)
+
+worm: worm.o
+ $(LINK) worm.o -o $@ $(LDFLAGS)
+
+xmas: xmas.o
+ $(LINK) xmas.o -o $@ $(LDFLAGS)
+
+firework.o: $(demodir)/firework.c
+ $(BUILD) $(demodir)/firework.c
+
+newdemo.o: $(demodir)/newdemo.c
+ $(BUILD) $(demodir)/newdemo.c
+
+ptest.o: $(demodir)/ptest.c $(PDCURSES_SRCDIR)/panel.h
+ $(BUILD) $(demodir)/ptest.c
+
+rain.o: $(demodir)/rain.c
+ $(BUILD) $(demodir)/rain.c
+
+testcurs.o: $(demodir)/testcurs.c
+ $(BUILD) $(demodir)/testcurs.c
+
+tui.o: $(demodir)/tui.c $(demodir)/tui.h
+ $(BUILD) $(demodir)/tui.c
+
+tuidemo.o: $(demodir)/tuidemo.c
+ $(BUILD) $(demodir)/tuidemo.c
+
+worm.o: $(demodir)/worm.c
+ $(BUILD) $(demodir)/worm.c
+
+xmas.o: $(demodir)/xmas.c
+ $(BUILD) $(demodir)/xmas.c
+
+# This section provides for compiling and linking the
+# ncurses test programs.
+
+ncurses_testdir = $(HOME)/ncurses-5.6/test
+
+NCURSES_TESTS = bs gdc hanoi knight tclock ncurses
+
+ncurses_tests: $(NCURSES_TESTS)
+
+ncurses_clean:
+ -rm -f *.o trace $(NCURSES_TESTS)
+
+NCFLAGS = -I. -I$(ncurses_testdir)
+
+bs: bs.o $(LIBCURSES)
+ $(LINK) bs.o -o $@ $(LDFLAGS)
+
+gdc: gdc.o $(LIBCURSES)
+ $(LINK) gdc.o -o $@ $(LDFLAGS)
+
+hanoi: hanoi.o $(LIBCURSES)
+ $(LINK) hanoi.o -o $@ $(LDFLAGS)
+
+knight: knight.o $(LIBCURSES)
+ $(LINK) knight.o -o $@ $(LDFLAGS)
+
+tclock: tclock.o $(LIBCURSES)
+ $(LINK) tclock.o -o $@ $(LDFLAGS) -lm
+
+view: view.o $(LIBCURSES)
+ $(LINK) view.o -o $@ $(LDFLAGS)
+
+ncurses: ncurses.o $(LIBCURSES)
+ $(LINK) ncurses.o -o $@ $(LDFLAGS)
+
+bs.o: $(ncurses_testdir)/bs.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(NCFLAGS) $(ncurses_testdir)/bs.c
+
+gdc.o: $(ncurses_testdir)/gdc.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(NCFLAGS) $(ncurses_testdir)/gdc.c
+
+hanoi.o: $(ncurses_testdir)/hanoi.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(NCFLAGS) $(ncurses_testdir)/hanoi.c
+
+knight.o: $(ncurses_testdir)/knight.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(NCFLAGS) $(ncurses_testdir)/knight.c
+
+tclock.o: $(ncurses_testdir)/tclock.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(NCFLAGS) $(ncurses_testdir)/tclock.c
+
+view.o: $(ncurses_testdir)/view.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(NCFLAGS) $(ncurses_testdir)/view.c
+
+ncurses.o: $(ncurses_testdir)/ncurses.c $(PDCURSES_CURSES_H)
+ $(BUILD) $(NCFLAGS) $(ncurses_testdir)/ncurses.c
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/README b/payloads/libpayload/curses/PDCurses-3.4/x11/README
new file mode 100644
index 0000000000..37b45d06e7
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/README
@@ -0,0 +1,64 @@
+PDCurses for X11
+================
+
+This is a port of PDCurses for X11, aka XCurses. It is designed to
+allow existing curses programs to be re-compiled with PDCurses,
+resulting in native X11 programs.
+
+
+Building
+--------
+
+. Run "./configure" in the top-level directory.
+
+ To build the wide-character version of the library, specify
+ "--enable-widec" as a parameter. To use X Input Methods, add
+ "--enable-xim". I recommend these options, but I haven't yet made
+ them the defaults, for the sake of backwards compatibility and due to
+ their new and relatively untested status.
+
+ If your system is lacking in UTF-8 support, you can force the use of
+ UTF-8 instead of the system locale via "--enable-force-utf8". This is
+ generally more useful in Windows.
+
+ If configure can't find your X include files or X libraries, you can
+ specify the paths with the arguments "--x-includes=inc_path" and/or
+ "--x-libraries=lib_path".
+
+ By default, the library and demo programs are built with the optimizer
+ switch -O2. You can turn this off, and turn on debugging (-g), by
+ adding "--with-debug" to the configure command.
+
+. Run "make". This should build libXCurses and all the demo programs.
+
+. Optionally, run "make install". curses.h and panel.h will be renamed
+ when installed (to xcurses.h and xpanel.h), to avoid conflicts with
+ any existing curses installations. Unrenamed copies of curses.h and
+ panel.h are installed in (by default) /usr/local/include/xcurses.
+
+ libXpanel is just a symlink to libXCurses. Both curses and panel
+ functions are in the main library.
+
+
+Distribution Status
+-------------------
+
+As of April 13, 2006, the files in this directory are released to the
+Public Domain, except for ScrollBox*, which are under essentially the
+MIT X License.
+
+
+To be Done
+----------
+
+- have newterm() create a new X window
+
+- provide a command line parsing function to enable X command line
+ arguments to be parsed and stripped from the arguments passed back
+ to the calling procedure.
+
+
+Acknowledgements
+----------------
+
+X11 port was provided by Mark Hessling <mark@rexx.org>
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBox.c b/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBox.c
new file mode 100644
index 0000000000..48ea38fd6c
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBox.c
@@ -0,0 +1,321 @@
+/*
+ * Copyright 1989 O'Reilly and Associates, Inc.
+
+ The X Consortium, and any party obtaining a copy of these files from
+ the X Consortium, directly or indirectly, is granted, free of charge, a
+ full and unrestricted irrevocable, world-wide, paid up, royalty-free,
+ nonexclusive right and license to deal in this software and
+ documentation files (the "Software"), including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons who receive
+ copies from any such party to do so. This license includes without
+ limitation a license to do the foregoing actions under any patents of
+ the party supplying this software to the X Consortium.
+
+ $Id: ScrollBox.c,v 1.15 2008/07/14 04:24:52 wmcbrine Exp $
+ */
+
+/* ScrollBox.c - scrollBox composite widget */
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Shell.h>
+
+#include "x11/ScrollBoxP.h"
+
+#include <stdio.h>
+
+#define INITIAL_WIDTH 300
+#define INITIAL_HEIGHT 300
+
+/************************************************************************
+ * *
+ * scrollBox Resources *
+ * *
+ ************************************************************************/
+
+static XtResource resources[] =
+{
+ { XtNhSpace, XtCHSpace, XtRDimension, sizeof(Dimension),
+ XtOffset(ScrollBoxWidget, scrollBox.h_space),
+ XtRImmediate, (XtPointer)4 },
+ { XtNvSpace, XtCVSpace, XtRDimension, sizeof(Dimension),
+ XtOffset(ScrollBoxWidget, scrollBox.v_space),
+ XtRImmediate, (XtPointer)4 },
+ { XtNheightInc, XtCHeightInc, XtRDimension, sizeof(Dimension),
+ XtOffset(ScrollBoxWidget, scrollBox.increment_height),
+ XtRImmediate, (XtPointer)13 },
+ { XtNwidthInc, XtCWidthInc, XtRDimension, sizeof(Dimension),
+ XtOffset(ScrollBoxWidget, scrollBox.increment_width),
+ XtRImmediate, (XtPointer)7 },
+};
+
+/************************************************************************
+ * *
+ * Full class record constant *
+ * *
+ ************************************************************************/
+
+static void Initialize(Widget, Widget, ArgList, Cardinal *);
+static void Resize(Widget);
+static Boolean SetValues(Widget, Widget, Widget, ArgList, Cardinal *);
+static void ChangeManaged(Widget);
+static XtGeometryResult QueryGeometry(Widget, XtWidgetGeometry *,
+ XtWidgetGeometry *);
+static XtGeometryResult GeometryManager(Widget, XtWidgetGeometry *,
+ XtWidgetGeometry *);
+static void RefigureLocations(Widget);
+
+ScrollBoxClassRec scrollBoxClassRec = {
+ {
+ /* core_class fields */
+ /* superclass */ (WidgetClass) &compositeClassRec,
+ /* class_name */ "scrollBox",
+ /* widget_size */ sizeof(ScrollBoxRec),
+ /* class_initialize */ NULL,
+ /* class_part_init */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ NULL,
+ /* resize */ Resize,
+ /* expose */ NULL,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ QueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },{
+ /* composite_class fields */
+ /* geometry_manager */ GeometryManager,
+ /* change_managed */ ChangeManaged,
+ /* insert_child */ XtInheritInsertChild,
+ /* delete_child */ XtInheritDeleteChild,
+ /* extension */ NULL
+ },{
+ /* scrollBox class fields */
+ /* empty */ 0,
+ }
+};
+
+WidgetClass scrollBoxWidgetClass = (WidgetClass)&scrollBoxClassRec;
+
+
+/************************************************************************
+ * *
+ * Private Routines *
+ * *
+ ************************************************************************/
+
+/* Do a layout, either actually assigning positions, or just
+ calculating size. */
+
+static void DoLayout(Widget w, Boolean doit)
+{
+ ScrollBoxWidget sbw = (ScrollBoxWidget)w;
+ Widget wmain, vscroll, hscroll, child;
+ Dimension mw, mh; /* main window */
+ Dimension vh; /* vertical scrollbar length (height) */
+ Dimension hw; /* horizontal scrollbar length (width) */
+ Position vx;
+ Position hy;
+ Cardinal i;
+
+ if (sbw->composite.num_children != 3)
+ XtAppError(XtWidgetToApplicationContext(w),
+ "ScrollBox: must manage exactly three widgets.");
+
+ for (i = 0; i < sbw->composite.num_children; i++)
+ {
+ child = sbw->composite.children[i];
+
+ if (!XtIsManaged(child))
+ XtAppError(XtWidgetToApplicationContext(w),
+ "ScrollBox: all three widgets must be managed.");
+ }
+
+ /* Child one is the main window, two is the vertical scrollbar,
+ and three is the horizontal scrollbar. */
+
+ wmain = sbw->composite.children[0];
+ vscroll = sbw->composite.children[1];
+ hscroll = sbw->composite.children[2];
+
+ /* Size all three widgets so that space is fully utilized. */
+
+ mw = sbw->core.width - (2 * sbw->scrollBox.h_space) -
+ vscroll->core.width - (2 * vscroll->core.border_width) -
+ (2 * wmain->core.border_width);
+
+ mh = sbw->core.height - (2 * sbw->scrollBox.v_space) -
+ hscroll->core.height - (2 * hscroll->core.border_width) -
+ (2 * wmain->core.border_width);
+
+ /* Force the main window to be sized to the appropriate increment. */
+
+ mw = (mw / sbw->scrollBox.increment_width) *
+ sbw->scrollBox.increment_width;
+
+ mh = ((mh / sbw->scrollBox.increment_height) *
+ sbw->scrollBox.increment_height) +
+ sbw->scrollBox.increment_height;
+
+ vx = wmain->core.x + mw + sbw->scrollBox.h_space +
+ wmain->core.border_width + vscroll->core.border_width;
+
+ hy = wmain->core.y + mh + sbw->scrollBox.v_space +
+ wmain->core.border_width + hscroll->core.border_width;
+
+ vh = mh; /* scrollbars are always same length as main window */
+ hw = mw;
+
+ if (doit)
+ {
+ XtResizeWidget(wmain, mw, mh, 1);
+
+ XtResizeWidget(vscroll, vscroll->core.width, vh, 1);
+ XtMoveWidget(vscroll, vx, vscroll->core.y);
+
+ XtResizeWidget(hscroll, hw, hscroll->core.height, 1);
+ XtMoveWidget(hscroll, hscroll->core.x, hy);
+ }
+}
+
+static XtGeometryResult GeometryManager(Widget w, XtWidgetGeometry *request,
+ XtWidgetGeometry *reply)
+{
+ XtWidgetGeometry allowed;
+
+ if (request->request_mode & ~(XtCWQueryOnly | CWWidth | CWHeight))
+ return XtGeometryNo;
+
+ if (request->request_mode & CWWidth)
+ allowed.width = request->width;
+ else
+ allowed.width = w->core.width;
+
+ if (request->request_mode & CWHeight)
+ allowed.height = request->height;
+ else
+ allowed.height = w->core.height;
+
+ if (allowed.width == w->core.width && allowed.height == w->core.height)
+ return XtGeometryNo;
+
+ if (!(request->request_mode & XtCWQueryOnly))
+ RefigureLocations(w);
+
+ return XtGeometryYes;
+}
+
+static void RefigureLocations(Widget w)
+{
+ DoLayout(w, False);
+}
+
+/* Calculate preferred size. We can't just use the current sizes
+ of the children, because that calculation would always end up with
+ our current size. Could query each child, and use that size to
+ recalculate a size for us, then if it ends up being larger than width
+ and height passed in, accept bounding box. However, we know our
+ children and they don't have any particular preferred geometry,
+ except the bigger the better. Therefore, if the parent suggested a
+ size, we'll take it. */
+
+static XtGeometryResult QueryGeometry(Widget w, XtWidgetGeometry *request,
+ XtWidgetGeometry *reply_return)
+{
+ XtGeometryResult result=XtGeometryNo;
+
+ request->request_mode &= CWWidth | CWHeight;
+
+ /* parent isn't going to change w or h, so nothing to re-compute */
+
+ if (request->request_mode == 0)
+ return XtGeometryYes;
+
+ /* if proposed size is large enough, accept it. Otherwise, suggest
+ our arbitrary initial size. */
+
+ if (request->request_mode & CWHeight)
+ {
+ if (request->height < INITIAL_HEIGHT)
+ {
+ result = XtGeometryAlmost;
+ reply_return->height = INITIAL_HEIGHT;
+ reply_return->request_mode &= CWHeight;
+ }
+ else
+ result = XtGeometryYes;
+ }
+
+ if (request->request_mode & CWWidth)
+ {
+ if (request->width < INITIAL_WIDTH)
+ {
+ result = XtGeometryAlmost;
+ reply_return->width = INITIAL_WIDTH;
+ reply_return->request_mode &= CWWidth;
+ }
+ else
+ result = XtGeometryYes;
+ }
+
+ return result;
+}
+
+/* Actually layout the scrollBox */
+
+static void Resize(Widget w)
+{
+ DoLayout(w, True);
+}
+
+static void ChangeManaged(Widget w)
+{
+ DoLayout(w, True);
+}
+
+static void Initialize(Widget request, Widget new,
+ ArgList args, Cardinal *num_args)
+{
+ ScrollBoxWidget newsbw = (ScrollBoxWidget)new;
+
+ if (newsbw->core.width == 0)
+ newsbw->core.width = INITIAL_WIDTH;
+
+ if (newsbw->core.height == 0)
+ newsbw->core.height = INITIAL_HEIGHT;
+
+}
+
+static Boolean SetValues(Widget current, Widget request, Widget new,
+ ArgList args, Cardinal *num_args)
+{
+ ScrollBoxWidget sbwcurrent = (ScrollBoxWidget)current;
+ ScrollBoxWidget sbwnew = (ScrollBoxWidget)new;
+
+ /* need to relayout if h_space or v_space change */
+
+ if ((sbwnew->scrollBox.h_space != sbwcurrent->scrollBox.h_space) ||
+ (sbwnew->scrollBox.v_space != sbwcurrent->scrollBox.v_space))
+ DoLayout(new, True);
+
+ return False;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBox.h b/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBox.h
new file mode 100644
index 0000000000..5825862744
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBox.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 1989 O'Reilly and Associates, Inc.
+
+ The X Consortium, and any party obtaining a copy of these files from
+ the X Consortium, directly or indirectly, is granted, free of charge, a
+ full and unrestricted irrevocable, world-wide, paid up, royalty-free,
+ nonexclusive right and license to deal in this software and
+ documentation files (the "Software"), including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons who receive
+ copies from any such party to do so. This license includes without
+ limitation a license to do the foregoing actions under any patents of
+ the party supplying this software to the X Consortium.
+
+ $Id: ScrollBox.h,v 1.4 2008/07/14 04:24:52 wmcbrine Exp $
+ */
+
+#ifndef _XORAscrollBox_h
+#define _XORAscrollBox_h
+
+/************************************************************************
+ * *
+ * scrollBox Widget (subclass of CompositeClass) *
+ * *
+ ************************************************************************/
+
+/* Parameters:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ background Background Pixel XtDefaultBackground
+ border BorderColor Pixel XtDefaultForeground
+ borderWidth BorderWidth Dimension 1
+ destroyCallback Callback Pointer NULL
+ hSpace HSpace Dimension 4
+ height Height Dimension 0
+ mappedWhenManaged MappedWhenManaged Boolean True
+ vSpace VSpace Dimension 4
+ width Width Dimension 0
+ x Position Position 0
+ y Position Position 0
+
+*/
+
+
+/* Class record constants */
+
+extern WidgetClass scrollBoxWidgetClass;
+
+typedef struct _ScrollBoxClassRec *ScrollBoxWidgetClass;
+typedef struct _ScrollBoxRec *ScrollBoxWidget;
+
+#endif /* _XORAscrollBox_h */
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBoxP.h b/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBoxP.h
new file mode 100644
index 0000000000..069666da2f
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/ScrollBoxP.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright 1989 O'Reilly and Associates, Inc.
+
+ The X Consortium, and any party obtaining a copy of these files from
+ the X Consortium, directly or indirectly, is granted, free of charge, a
+ full and unrestricted irrevocable, world-wide, paid up, royalty-free,
+ nonexclusive right and license to deal in this software and
+ documentation files (the "Software"), including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons who receive
+ copies from any such party to do so. This license includes without
+ limitation a license to do the foregoing actions under any patents of
+ the party supplying this software to the X Consortium.
+
+ $Id: ScrollBoxP.h,v 1.5 2008/07/14 04:24:52 wmcbrine Exp $
+ */
+
+/*
+ * scrollBoxP.h - Private definitions for scrollBox widget
+ *
+ */
+
+#ifndef _XORAscrollBoxP_h
+#define _XORAscrollBoxP_h
+
+/************************************************************************
+ * *
+ * scrollBox Widget Private Data *
+ * *
+ ************************************************************************/
+
+#include "x11/ScrollBox.h"
+
+#include <X11/CompositeP.h>
+
+/* New fields for the scrollBox widget class record */
+typedef struct _ScrollBoxClass {
+ int empty;
+} ScrollBoxClassPart;
+
+/* Full class record declaration */
+typedef struct _ScrollBoxClassRec {
+ CoreClassPart core_class;
+ CompositeClassPart composite_class;
+ ScrollBoxClassPart scrollBox_class;
+} ScrollBoxClassRec;
+
+extern ScrollBoxClassRec scrollBoxClassRec;
+
+/* New fields for the scrollBox widget record */
+typedef struct {
+ Dimension h_space, v_space;
+ Dimension preferred_width, preferred_height;
+ Dimension last_query_width, last_query_height;
+ Dimension increment_width, increment_height;
+ XtGeometryMask last_query_mode;
+} ScrollBoxPart;
+
+
+/************************************************************************
+ * *
+ * Full instance record declaration *
+ * *
+ ************************************************************************/
+
+typedef struct _ScrollBoxRec {
+ CorePart core;
+ CompositePart composite;
+ ScrollBoxPart scrollBox;
+} ScrollBoxRec;
+
+#endif /* _XORAscrollBoxP_h */
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/big_icon.xbm b/payloads/libpayload/curses/PDCurses-3.4/x11/big_icon.xbm
new file mode 100644
index 0000000000..04b98a5bf5
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/big_icon.xbm
@@ -0,0 +1,46 @@
+#define big_icon_width 64
+#define big_icon_height 64
+static unsigned char big_icon_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
+ 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xc1, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0xff, 0xc3, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
+ 0xc3, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xc0, 0xc7, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0x80, 0xc7, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x80,
+ 0xc7, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x80, 0xc7, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0x80, 0xc7, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xc0,
+ 0xc7, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xe0, 0xc3, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0xf0, 0xe3, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf8,
+ 0xf1, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xfc, 0xf8, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0x7e, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f,
+ 0xfe, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0xff, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0x8f, 0xdf, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xc7,
+ 0xcf, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xe3, 0xc7, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0xf1, 0xc3, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0,
+ 0xc1, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf8, 0xc0, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0x78, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x78,
+ 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x78, 0xc0, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0x78, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf8,
+ 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xff, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0xf0, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xe0,
+ 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xc0, 0xff, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x23, 0x50, 0x1e,
+ 0x7c, 0xf0, 0xe0, 0x03, 0x60, 0x26, 0x50, 0x33, 0xc6, 0x98, 0x31, 0x06,
+ 0x30, 0x2c, 0xd0, 0x61, 0x83, 0x0d, 0x1b, 0x0c, 0x10, 0x28, 0xd0, 0x40,
+ 0x01, 0x05, 0x0a, 0x08, 0x10, 0x20, 0x50, 0x00, 0x01, 0x05, 0x0a, 0x08,
+ 0x10, 0x20, 0x50, 0x00, 0x03, 0x04, 0x1a, 0x00, 0x10, 0x20, 0x50, 0x00,
+ 0x06, 0x04, 0x32, 0x00, 0x10, 0x20, 0x50, 0x00, 0x7c, 0xfc, 0xe3, 0x03,
+ 0x10, 0x20, 0x50, 0x00, 0xc0, 0x04, 0x00, 0x06, 0x10, 0x20, 0x50, 0x00,
+ 0x80, 0x05, 0x00, 0x0c, 0x10, 0x20, 0x50, 0x00, 0x01, 0x05, 0x0a, 0x08,
+ 0x10, 0x28, 0x50, 0x00, 0x01, 0x05, 0x0a, 0x08, 0x30, 0x6c, 0x58, 0x00,
+ 0x83, 0x0d, 0x1b, 0x0c, 0x60, 0xc6, 0x4c, 0x00, 0xc6, 0x98, 0x31, 0x06,
+ 0xc0, 0x83, 0x47, 0x00, 0x7c, 0xf0, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/compose.h b/payloads/libpayload/curses/PDCurses-3.4/x11/compose.h
new file mode 100644
index 0000000000..12b85fa133
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/compose.h
@@ -0,0 +1,203 @@
+/* Public Domain Curses */
+
+/* $Id: compose.h,v 1.3 2008/07/14 04:24:52 wmcbrine Exp $ */
+
+/* Tables and variables for the built-in compose key system. This file
+ is not included when PDCurses is built with XIM support. */
+
+#define MAX_COMPOSE_CHARS 14
+#define MAX_COMPOSE_PRE 60
+
+static const char *compose_chars =
+ "`'~^,/\"AaPpSs!?0123CcRr-_<>Xx.=Yy |EeIiOoUu+NnLlgDd:*TtMmVv";
+
+/*
+ ` : À È Ì Ò Ù à è ì ò ù
+ ' : ´ Á É Í Ó Ú Ý á é í ó ú ý ´
+ ~ : Ã Ñ Õ ã ñ õ
+ ^ : Â Ê Î Ô Û â ê î ô û ° ¹ ² ³
+ , : ¸ Ç ç ¸
+ / : Ø ø µ µ
+ " : ¨ Ä Ë Ï Ö Ü ä ë ï ö ü ÿ ¨
+ A : Æ À Á Ã Â Å Å Ã Â ª
+ a : æ à á ã â å å ã â ª
+ P : Þ ¶ ¶
+ p : þ ¶ ¶
+ S : § § § º ª
+ s : ß § ª ¹ ² ³ º §
+ ! : ¡ ¡
+ ? : ¿ ¿
+ 0 : ° °
+ 1 : ¹ ½ ¼ ¹
+ 2 : ² ²
+ 3 : ³ ¾ ³
+ C : © Ç ¢ ¢
+ c : ¢ © ç ¢ ¢
+ R : ®
+ r : ®
+ - : ­ ± ¬ ­ ¯ ÷
+ _ : ¯ ¯
+ < : «
+ > : «
+ X : ¤ ×
+ x : × ¤ ×
+ . : · · ·
+ = : ¥ ¥
+ Y : ¥ Ý ¥
+ y : ¥ ý ÿ ¥ ¥
+ :
+ | : ¦ ¢ ¦ Þ þ ¦ £
+ E : È É Ê Ë Ê
+ e : è é ê ë ê
+ I : Ì Í Î Ï Î
+ i : ì í î ï î
+ O : Ò Ó Ô Õ Ö Ø © ® Õ Ô Å å
+ o : ° Å å ¤ õ ò ó ô õ ö ø ô º
+ U : Ù Ú Û Ü Û
+ u : ù ú û ü µ û
+ + : ±
+ N : Ñ Ñ ¬
+ n : ñ ñ ¬
+ L : £ £ £
+ l : £ £ £
+ g : ¤
+ D : ° Ð
+ d : ° ð
+ : : ÷
+ * : µ µ å Å
+ T : Þ
+ t : þ
+ M : ×
+ m : ×
+ V : ¦
+ v : ¦
+*/
+
+static const char compose_lookups[MAX_COMPOSE_PRE][MAX_COMPOSE_CHARS] =
+{
+/* ` */ {'A','E','I','O','U','a','e','i','o','u', 0, 0, 0, 0},
+/* ' */ {' ','A','E','I','O','U','Y','a','e','i','o','u','y', 39},
+/* ~ */ {'A','N','O','a','n','o', 0, 0, 0, 0, 0, 0, 0, 0},
+/* ^ */ {'A','E','I','O','U','a','e','i','o','u','0','1','2','3'},
+/* , */ {' ','C','c',',', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* / */ {'O','o','u','U', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* " */ {' ','A','E','I','O','U','a','e','i','o','u','y','\"', 0},
+/* A */ {'E','`', 39,'~','^','"','o','*','-','>','_', 0, 0, 0},
+/* a */ {'e','`', 39,'~','^','"','o','*','-','>','_', 0, 0, 0},
+/* P */ {' ','G','!', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* p */ {' ','g','!', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* S */ {'S','!','O','0','A', 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* s */ {'s','!','a','1','2','3','0','o', 0, 0, 0, 0, 0, 0},
+/* ! */ {' ','!', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* ? */ {' ','?', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* 0 */ {'^','*', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* 1 */ {' ','2','4','^', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* 2 */ {' ','^', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* 3 */ {' ','4','^', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* C */ {'O',',','$','|', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* c */ {'|','o',',','/','$', 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* R */ {'O', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* r */ {'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* - */ {' ','+',',','-','^',':', 0, 0, 0, 0, 0, 0, 0, 0},
+/* _ */ {'_','^', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* < */ {'<', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* > */ {'>', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* X */ {'O','X', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* x */ {' ','o','x', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* . */ {' ','^','.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* = */ {'Y','y', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* Y */ {'=', 39,'-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* y */ {'=', 39,'"','$','-', 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* */ {' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* | */ {' ','c','|','P','p','^','-', 0, 0, 0, 0, 0, 0, 0},
+/* E */ {'`', 39,'^','"','>', 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* e */ {'`', 39,'^','"','>', 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* I */ {'`', 39,'^','"','>', 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* i */ {'`', 39,'^','"','>', 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* O */ {'`', 39,'^','~','"','/','C','R','-','>','A','a', 0, 0},
+/* o */ {' ','A','a','x','-','`', 39,'^','~','"','/','>','_', 0},
+/* U */ {'`', 39,'^','"','>', 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* u */ {'`', 39,'^','"',' ','>', 0, 0, 0, 0, 0, 0, 0, 0},
+/* + */ {'-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* N */ {'~','-','O', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* n */ {'~','-','o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* L */ {'$','=','-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* l */ {'$','=','-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* g */ {'$', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* D */ {'E','-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* d */ {'e','-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* : */ {'-', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* * */ {'m','M','a','A', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* T */ {'H', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* t */ {'h', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* M */ {'U', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* m */ {'u', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* V */ {'B', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* v */ {'b', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+};
+
+static const unsigned char compose_keys[MAX_COMPOSE_PRE][MAX_COMPOSE_CHARS] =
+{
+/* ` */ {192,200,204,210,217,224,232,236,242,249, 0, 0, 0, 0},
+/* ' */ {180,193,201,205,211,218,221,225,233,237,243,250,253,180},
+/* ~ */ {195,209,213,227,241,245, 0, 0, 0, 0, 0, 0, 0, 0},
+/* ^ */ {194,202,206,212,219,226,234,238,244,251,176,185,178,179},
+/* , */ {184,199,231,184, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* / */ {216,248,181,181, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* " */ {168,196,203,207,214,220,228,235,239,246,252,255,168, 0},
+/* A */ {198,192,193,195,194,196,197,197,195,194,170, 0, 0, 0},
+/* a */ {230,224,225,227,226,228,229,229,227,226,170, 0, 0, 0},
+/* P */ {222,182,182, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* p */ {254,182,182, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* S */ {167,167,167,186,170, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* s */ {223,167,170,185,178,179,186,167, 0, 0, 0, 0, 0, 0},
+/* ! */ {161,161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* ? */ {191,191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* 0 */ {176,176, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* 1 */ {185,189,188,185, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* 2 */ {178,178, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* 3 */ {179,190,179, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* C */ {169,199,162,162, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* c */ {162,169,231,162,162, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* R */ {174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* r */ {174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* - */ {173,177,172,173,175,247, 0, 0, 0, 0, 0, 0, 0, 0},
+/* _ */ {175,175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* < */ {171, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* > */ {187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* X */ {164,215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* x */ {215,164,215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* . */ {183,183,183, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* = */ {165,165, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* Y */ {165,221,165, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* y */ {165,253,255,165,165, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* */ {160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* | */ {166,162,166,222,254,166,163, 0, 0, 0, 0, 0, 0, 0},
+/* E */ {200,201,202,203,202, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* e */ {232,233,234,235,234, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* I */ {204,205,206,207,206, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* i */ {236,237,238,239,238, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* O */ {210,211,212,213,214,216,169,174,213,212,197,229, 0, 0},
+/* o */ {176,197,229,164,245,242,243,244,245,246,248,244,186, 0},
+/* U */ {217,218,219,220,219, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* u */ {249,250,251,252,181,251, 0, 0, 0, 0, 0, 0, 0, 0},
+/* + */ {177, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* N */ {209,209,172, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* n */ {241,241,172, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* L */ {163,163,163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* l */ {163,163,163, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* g */ {164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* D */ {176,208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* d */ {176,240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* : */ {247, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* * */ {181,181,229,197, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* T */ {222, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* t */ {254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* M */ {215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* u */ {215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* V */ {166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/* v */ {166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+};
+
+static KeySym compose_key = 0;
+static int compose_mask = 0;
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/little_icon.xbm b/payloads/libpayload/curses/PDCurses-3.4/x11/little_icon.xbm
new file mode 100644
index 0000000000..d3e777e8df
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/little_icon.xbm
@@ -0,0 +1,14 @@
+#define little_icon_width 32
+#define little_icon_height 32
+static unsigned char little_icon_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfc, 0x30, 0x00, 0x00, 0xfc, 0x31, 0x00, 0x00, 0x8c, 0x33, 0x00,
+ 0x00, 0x0c, 0x33, 0x00, 0x00, 0x0c, 0x33, 0x00, 0x00, 0x8c, 0x33, 0x00,
+ 0x00, 0xcc, 0x39, 0x00, 0x00, 0xec, 0x3c, 0x00, 0x00, 0x7c, 0x3e, 0x00,
+ 0x00, 0x3c, 0x37, 0x00, 0x00, 0x9c, 0x33, 0x00, 0x00, 0xcc, 0x31, 0x00,
+ 0x00, 0xcc, 0x30, 0x00, 0x00, 0xcc, 0x30, 0x00, 0x00, 0xcc, 0x31, 0x00,
+ 0x00, 0x8c, 0x3f, 0x00, 0x00, 0x0c, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x4c, 0x2a, 0xc6, 0x18, 0x52, 0x5a, 0x29, 0x25,
+ 0x42, 0x0a, 0x21, 0x05, 0x42, 0x0a, 0xe6, 0x18, 0x42, 0x0a, 0x28, 0x20,
+ 0x52, 0x0a, 0x29, 0x25, 0x8c, 0x09, 0xc6, 0x18, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/ncurses_cfg.h b/payloads/libpayload/curses/PDCurses-3.4/x11/ncurses_cfg.h
new file mode 100644
index 0000000000..42571180b2
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/ncurses_cfg.h
@@ -0,0 +1,47 @@
+/* $Id: ncurses_cfg.h,v 1.8 2006/12/28 01:02:03 wmcbrine Exp $
+ *
+ * This file is only used with the ncurses test programs.
+ *
+ * Have ncurses-5.6 unpacked in your $(HOME) (you don't need to build
+ * it), or edit ncurses_testdir appropriately in the Makefile. Configure
+ * and build PDCurses for X11. (Sorry, other ports won't work yet.)
+ * Change to this directory, and:
+ *
+ * "make ncurses_tests" to start.
+ * "make ncurses_clean" when you're done.
+ *
+ * Builds: bs gdc hanoi knight tclock ncurses
+ */
+
+#define NCURSES_MOUSE_VERSION 2
+
+#include "../config.h"
+#include <curses.h>
+
+#define ExitProgram exit
+
+#define HAVE_CURSES_VERSION 1
+#define HAVE_GETBEGX 1
+#define HAVE_GETCURX 1
+#define HAVE_GETMAXX 1
+#define HAVE_GETNSTR 1
+#define HAVE_GETTIMEOFDAY 1
+#define HAVE_GETWIN 1
+#define HAVE_LIBPANEL 1
+#define HAVE_LOCALE_H 1
+#define HAVE_NAPMS 1
+#define HAVE_PANEL_H 1
+#define HAVE_PUTWIN 1
+#define HAVE_SLK_COLOR 1
+#define HAVE_SLK_INIT 1
+#define HAVE_WRESIZE 1
+
+#ifdef PDC_WIDE
+# define USE_WIDEC_SUPPORT 1
+#endif
+
+/* Fool ncurses.c so it gives us all the tests, and doesn't redefine
+ ACS_ chars
+*/
+
+#define NCURSES_VERSION PDCURSES
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdcclip.c b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcclip.c
new file mode 100644
index 0000000000..1a3ce92a2d
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcclip.c
@@ -0,0 +1,170 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: pdcclip.c,v 1.35 2008/07/14 04:24:52 wmcbrine Exp $")
+
+#include <stdlib.h>
+
+/*man-start**************************************************************
+
+ Name: clipboard
+
+ Synopsis:
+ int PDC_getclipboard(char **contents, long *length);
+ int PDC_setclipboard(const char *contents, long length);
+ int PDC_freeclipboard(char *contents);
+ int PDC_clearclipboard(void);
+
+ Description:
+ PDC_getclipboard() gets the textual contents of the system's
+ clipboard. This function returns the contents of the clipboard
+ in the contents argument. It is the responsibilitiy of the
+ caller to free the memory returned, via PDC_freeclipboard().
+ The length of the clipboard contents is returned in the length
+ argument.
+
+ PDC_setclipboard copies the supplied text into the system's
+ clipboard, emptying the clipboard prior to the copy.
+
+ PDC_clearclipboard() clears the internal clipboard.
+
+ Return Values:
+ indicator of success/failure of call.
+ PDC_CLIP_SUCCESS the call was successful
+ PDC_CLIP_MEMORY_ERROR unable to allocate sufficient memory for
+ the clipboard contents
+ PDC_CLIP_EMPTY the clipboard contains no text
+ PDC_CLIP_ACCESS_ERROR no clipboard support
+
+ Portability X/Open BSD SYS V
+ PDC_getclipboard - - -
+ PDC_setclipboard - - -
+ PDC_freeclipboard - - -
+ PDC_clearclipboard - - -
+
+**man-end****************************************************************/
+
+int PDC_getclipboard(char **contents, long *length)
+{
+#ifdef PDC_WIDE
+ wchar_t *wcontents;
+#endif
+ int result = 0;
+ int len;
+
+ PDC_LOG(("PDC_getclipboard() - called\n"));
+
+ XCursesInstructAndWait(CURSES_GET_SELECTION);
+
+ if (XC_read_socket(xc_display_sock, &result, sizeof(int)) < 0)
+ XCursesExitCursesProcess(5, "exiting from PDC_getclipboard");
+
+ if (result == PDC_CLIP_SUCCESS)
+ {
+ if (XC_read_socket(xc_display_sock, &len, sizeof(int)) < 0)
+ XCursesExitCursesProcess(5, "exiting from PDC_getclipboard");
+#ifdef PDC_WIDE
+ wcontents = malloc((len + 1) * sizeof(wchar_t));
+ *contents = malloc(len * 3 + 1);
+
+ if (!wcontents || !*contents)
+#else
+ *contents = malloc(len + 1);
+
+ if (!*contents)
+#endif
+ XCursesExitCursesProcess(6, "exiting from PDC_getclipboard - "
+ "synchronization error");
+
+ if (len)
+ {
+ if (XC_read_socket(xc_display_sock,
+#ifdef PDC_WIDE
+ wcontents, len * sizeof(wchar_t)) < 0)
+#else
+ *contents, len) < 0)
+#endif
+ XCursesExitCursesProcess(5, "exiting from PDC_getclipboard");
+ }
+
+#ifdef PDC_WIDE
+ wcontents[len] = 0;
+ len = PDC_wcstombs(*contents, wcontents, len * 3);
+ free(wcontents);
+#endif
+ (*contents)[len] = '\0';
+ *length = len;
+ }
+
+ return result;
+}
+
+int PDC_setclipboard(const char *contents, long length)
+{
+#ifdef PDC_WIDE
+ wchar_t *wcontents;
+#endif
+ int rc;
+
+ PDC_LOG(("PDC_setclipboard() - called\n"));
+
+#ifdef PDC_WIDE
+ wcontents = malloc((length + 1) * sizeof(wchar_t));
+ if (!wcontents)
+ return PDC_CLIP_MEMORY_ERROR;
+
+ length = PDC_mbstowcs(wcontents, contents, length);
+#endif
+ XCursesInstruct(CURSES_SET_SELECTION);
+
+ /* Write, then wait for X to do its stuff; expect return code. */
+
+ if (XC_write_socket(xc_display_sock, &length, sizeof(long)) >= 0)
+ {
+ if (XC_write_socket(xc_display_sock,
+#ifdef PDC_WIDE
+ wcontents, length * sizeof(wchar_t)) >= 0)
+ {
+ free(wcontents);
+#else
+ contents, length) >= 0)
+ {
+#endif
+ if (XC_read_socket(xc_display_sock, &rc, sizeof(int)) >= 0)
+ return rc;
+ }
+ }
+
+ XCursesExitCursesProcess(5, "exiting from PDC_setclipboard");
+
+ return PDC_CLIP_ACCESS_ERROR; /* not reached */
+}
+
+int PDC_freeclipboard(char *contents)
+{
+ PDC_LOG(("PDC_freeclipboard() - called\n"));
+
+ free(contents);
+ return PDC_CLIP_SUCCESS;
+}
+
+int PDC_clearclipboard(void)
+{
+ int rc;
+ long len = 0;
+
+ PDC_LOG(("PDC_clearclipboard() - called\n"));
+
+ XCursesInstruct(CURSES_CLEAR_SELECTION);
+
+ /* Write, then wait for X to do its stuff; expect return code. */
+
+ if (XC_write_socket(xc_display_sock, &len, sizeof(long)) >= 0)
+ if (XC_read_socket(xc_display_sock, &rc, sizeof(int)) >= 0)
+ return rc;
+
+ XCursesExitCursesProcess(5, "exiting from PDC_clearclipboard");
+
+ return PDC_CLIP_ACCESS_ERROR; /* not reached */
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdcdisp.c b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcdisp.c
new file mode 100644
index 0000000000..3700edb558
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcdisp.c
@@ -0,0 +1,132 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: pdcdisp.c,v 1.46 2008/07/14 04:24:52 wmcbrine Exp $")
+
+#include <string.h>
+
+#ifdef CHTYPE_LONG
+
+# define A(x) ((chtype)x | A_ALTCHARSET)
+
+chtype acs_map[128] =
+{
+ A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9), A(10),
+ A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18), A(19),
+ A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27), A(28),
+ A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&', '\'', '(',
+ ')', '*',
+
+# ifdef PDC_WIDE
+ 0x2192, 0x2190, 0x2191, 0x2193,
+# else
+ '>', '<', '^', 'v',
+# endif
+
+ '/',
+
+# ifdef PDC_WIDE
+ 0x2588,
+# else
+ A(0),
+# endif
+
+ '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
+ '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
+ 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
+
+# ifdef PDC_WIDE
+ 0x2666, 0x2592,
+# else
+ A(1), A(2),
+# endif
+
+ 'b', 'c', 'd', 'e',
+
+# ifdef PDC_WIDE
+ 0x00b0, 0x00b1, 0x2591, 0x00a4, 0x2518, 0x2510, 0x250c, 0x2514,
+ 0x253c, 0x23ba, 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524,
+ 0x2534, 0x252c, 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3,
+ 0x00b7,
+# else
+ A(7), A(8), '#', 0xa4, A(11), A(12), A(13), A(14), A(15), A(16),
+ A(17), A(18), A(19), A(20), A(21), A(22), A(23), A(24), A(25),
+ A(26), A(27), A(28), A(29), A(30), 0xb7,
+# endif
+
+ A(127)
+};
+
+# undef A
+
+#endif
+
+int PDC_display_cursor(int oldrow, int oldcol, int newrow, int newcol,
+ int visibility)
+{
+ char buf[30];
+ int idx, pos;
+
+ PDC_LOG(("%s:PDC_display_cursor() - called: NEW row %d col %d, vis %d\n",
+ XCLOGMSG, newrow, newcol, visibility));
+
+ if (visibility == -1)
+ {
+ /* Only send the CURSES_DISPLAY_CURSOR message, no data */
+
+ idx = CURSES_DISPLAY_CURSOR;
+ memcpy(buf, &idx, sizeof(int));
+ idx = sizeof(int);
+ }
+ else
+ {
+ idx = CURSES_CURSOR;
+ memcpy(buf, &idx, sizeof(int));
+
+ idx = sizeof(int);
+ pos = oldrow + (oldcol << 8);
+ memcpy(buf + idx, &pos, sizeof(int));
+
+ idx += sizeof(int);
+ pos = newrow + (newcol << 8);
+ memcpy(buf + idx, &pos, sizeof(int));
+
+ idx += sizeof(int);
+ }
+
+ if (XC_write_socket(xc_display_sock, buf, idx) < 0)
+ XCursesExitCursesProcess(1, "exiting from PDC_display_cursor");
+
+ return OK;
+}
+
+/* position hardware cursor at (y, x) */
+
+void PDC_gotoyx(int row, int col)
+{
+ PDC_LOG(("PDC_gotoyx() - called: row %d col %d\n", row, col));
+
+ PDC_display_cursor(SP->cursrow, SP->curscol, row, col, SP->visibility);
+}
+
+/* update the given physical line to look like the corresponding line in
+ curscr */
+
+void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
+{
+ PDC_LOG(("PDC_transform_line() - called: line %d\n", lineno));
+
+ XC_get_line_lock(lineno);
+
+ memcpy(Xcurscr + XCURSCR_Y_OFF(lineno) + (x * sizeof(chtype)), srcp,
+ len * sizeof(chtype));
+
+ *(Xcurscr + XCURSCR_START_OFF + lineno) = x;
+ *(Xcurscr + XCURSCR_LENGTH_OFF + lineno) = len;
+
+ XC_release_line_lock(lineno);
+
+ XCursesInstructAndWait(CURSES_REFRESH);
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdcgetsc.c b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcgetsc.c
new file mode 100644
index 0000000000..8f7c0ad91f
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcgetsc.c
@@ -0,0 +1,30 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: pdcgetsc.c,v 1.26 2008/07/14 04:24:52 wmcbrine Exp $")
+
+/* return width of screen/viewport */
+
+int PDC_get_columns(void)
+{
+ PDC_LOG(("PDC_get_columns() - called\n"));
+
+ return XCursesCOLS;
+}
+
+/* get the cursor size/shape */
+
+int PDC_get_cursor_mode(void)
+{
+ return 0;
+}
+
+/* return number of screen rows */
+
+int PDC_get_rows(void)
+{
+ PDC_LOG(("PDC_get_rows() - called\n"));
+
+ return XCursesLINES;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdckbd.c b/payloads/libpayload/curses/PDCurses-3.4/x11/pdckbd.c
new file mode 100644
index 0000000000..30c37a87c1
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdckbd.c
@@ -0,0 +1,102 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: pdckbd.c,v 1.62 2008/07/14 04:24:52 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: pdckbd
+
+ Synopsis:
+ unsigned long PDC_get_input_fd(void);
+
+ Description:
+ PDC_get_input_fd() returns the file descriptor that PDCurses
+ reads its input from. It can be used for select().
+
+ Portability X/Open BSD SYS V
+ PDC_get_input_fd - - -
+
+**man-end****************************************************************/
+
+/* check if a key or mouse event is waiting */
+
+bool PDC_check_key(void)
+{
+ struct timeval socket_timeout = {0};
+ int s;
+
+ /* Is something ready to be read on the socket ? Must be a key. */
+
+ FD_ZERO(&xc_readfds);
+ FD_SET(xc_key_sock, &xc_readfds);
+
+ if ((s = select(FD_SETSIZE, (FD_SET_CAST)&xc_readfds, NULL,
+ NULL, &socket_timeout)) < 0)
+ XCursesExitCursesProcess(3, "child - exiting from "
+ "PDC_check_key select failed");
+
+ PDC_LOG(("%s:PDC_check_key() - returning %s\n", XCLOGMSG,
+ s ? "TRUE" : "FALSE"));
+
+ return !!s;
+}
+
+/* return the next available key or mouse event */
+
+int PDC_get_key(void)
+{
+ unsigned long newkey = 0;
+ int key = 0;
+
+ if (XC_read_socket(xc_key_sock, &newkey, sizeof(unsigned long)) < 0)
+ XCursesExitCursesProcess(2, "exiting from PDC_get_key");
+
+ pdc_key_modifiers = (newkey >> 24) & 0xFF;
+ key = (int)(newkey & 0x00FFFFFF);
+
+ if (key == KEY_MOUSE && SP->key_code)
+ {
+ if (XC_read_socket(xc_key_sock, &pdc_mouse_status,
+ sizeof(MOUSE_STATUS)) < 0)
+ XCursesExitCursesProcess(2, "exiting from PDC_get_key");
+ }
+
+ PDC_LOG(("%s:PDC_get_key() - key %d returned\n", XCLOGMSG, key));
+
+ return key;
+}
+
+unsigned long PDC_get_input_fd(void)
+{
+ PDC_LOG(("PDC_get_input_fd() - called\n"));
+
+ return xc_key_sock;
+}
+
+void PDC_set_keyboard_binary(bool on)
+{
+ PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
+}
+
+/* discard any pending keyboard or mouse input -- this is the core
+ routine for flushinp() */
+
+void PDC_flushinp(void)
+{
+ PDC_LOG(("PDC_flushinp() - called\n"));
+
+ while (PDC_check_key())
+ PDC_get_key();
+}
+
+int PDC_mouse_set(void)
+{
+ return OK;
+}
+
+int PDC_modifiers_set(void)
+{
+ return OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdcscrn.c b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcscrn.c
new file mode 100644
index 0000000000..07b1a042ce
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcscrn.c
@@ -0,0 +1,150 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: pdcscrn.c,v 1.55 2008/07/14 04:24:52 wmcbrine Exp $")
+
+/* COLOR_PAIR to attribute encoding table. */
+
+short *xc_atrtab = (short *)NULL;
+
+/* close the physical screen */
+
+void PDC_scr_close(void)
+{
+ PDC_LOG(("PDC_scr_close() - called\n"));
+}
+
+void PDC_scr_free(void)
+{
+ XCursesExit();
+
+ xc_atrtab = (short *)NULL;
+}
+
+/* open the physical screen -- allocate SP, miscellaneous intialization */
+
+int PDC_scr_open(int argc, char **argv)
+{
+ extern bool sb_started;
+
+ PDC_LOG(("PDC_scr_open() - called\n"));
+
+ if ((XCursesInitscr(argc, argv) == ERR) || !SP)
+ return ERR;
+
+ SP->cursrow = SP->curscol = 0;
+ SP->orig_attr = FALSE;
+ SP->sb_on = sb_started;
+ SP->sb_total_y = 0;
+ SP->sb_viewport_y = 0;
+ SP->sb_cur_y = 0;
+ SP->sb_total_x = 0;
+ SP->sb_viewport_x = 0;
+ SP->sb_cur_x = 0;
+
+ return OK;
+}
+
+/* the core of resize_term() */
+
+int PDC_resize_screen(int nlines, int ncols)
+{
+ PDC_LOG(("PDC_resize_screen() - called. Lines: %d Cols: %d\n",
+ nlines, ncols));
+
+ if (nlines || ncols || !SP->resized)
+ return ERR;
+
+ shmdt((char *)Xcurscr);
+ XCursesInstructAndWait(CURSES_RESIZE);
+
+ if ((shmid_Xcurscr = shmget(shmkey_Xcurscr,
+ SP->XcurscrSize + XCURSESSHMMIN, 0700)) < 0)
+ {
+ perror("Cannot allocate shared memory for curscr");
+ kill(xc_otherpid, SIGKILL);
+ return ERR;
+ }
+
+ XCursesLINES = SP->lines;
+ XCursesCOLS = SP->cols;
+
+ PDC_LOG(("%s:shmid_Xcurscr %d shmkey_Xcurscr %d SP->lines %d "
+ "SP->cols %d\n", XCLOGMSG, shmid_Xcurscr,
+ shmkey_Xcurscr, SP->lines, SP->cols));
+
+ Xcurscr = (unsigned char*)shmat(shmid_Xcurscr, 0, 0);
+ xc_atrtab = (short *)(Xcurscr + XCURSCR_ATRTAB_OFF);
+
+ SP->resized = FALSE;
+
+ return OK;
+}
+
+void PDC_reset_prog_mode(void)
+{
+ PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
+}
+
+void PDC_reset_shell_mode(void)
+{
+ PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
+}
+
+void PDC_restore_screen_mode(int i)
+{
+}
+
+void PDC_save_screen_mode(int i)
+{
+}
+
+void PDC_init_pair(short pair, short fg, short bg)
+{
+ xc_atrtab[pair * 2] = fg;
+ xc_atrtab[pair * 2 + 1] = bg;
+}
+
+int PDC_pair_content(short pair, short *fg, short *bg)
+{
+ *fg = xc_atrtab[pair * 2];
+ *bg = xc_atrtab[pair * 2 + 1];
+
+ return OK;
+}
+
+bool PDC_can_change_color(void)
+{
+ return TRUE;
+}
+
+int PDC_color_content(short color, short *red, short *green, short *blue)
+{
+ XColor *tmp = (XColor *)(Xcurscr + XCURSCR_XCOLOR_OFF);
+
+ tmp->pixel = color;
+
+ XCursesInstructAndWait(CURSES_GET_COLOR);
+
+ *red = ((double)(tmp->red) * 1000 / 65535) + 0.5;
+ *green = ((double)(tmp->green) * 1000 / 65535) + 0.5;
+ *blue = ((double)(tmp->blue) * 1000 / 65535) + 0.5;
+
+ return OK;
+}
+
+int PDC_init_color(short color, short red, short green, short blue)
+{
+ XColor *tmp = (XColor *)(Xcurscr + XCURSCR_XCOLOR_OFF);
+
+ tmp->pixel = color;
+
+ tmp->red = ((double)red * 65535 / 1000) + 0.5;
+ tmp->green = ((double)green * 65535 / 1000) + 0.5;
+ tmp->blue = ((double)blue * 65535 / 1000) + 0.5;
+
+ XCursesInstructAndWait(CURSES_SET_COLOR);
+
+ return OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdcsetsc.c b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcsetsc.c
new file mode 100644
index 0000000000..395060e867
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcsetsc.c
@@ -0,0 +1,74 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: pdcsetsc.c,v 1.33 2008/07/14 04:24:52 wmcbrine Exp $")
+
+#include <string.h>
+
+/*man-start**************************************************************
+
+ Name: pdcsetsc
+
+ Synopsis:
+ int PDC_set_blink(bool blinkon);
+ void PDC_set_title(const char *title);
+
+ Description:
+ PDC_set_blink() toggles whether the A_BLINK attribute sets an
+ actual blink mode (TRUE), or sets the background color to high
+ intensity (FALSE). The default is platform-dependent (FALSE in
+ most cases). It returns OK if it could set the state to match
+ the given parameter, ERR otherwise. Current platforms also
+ adjust the value of COLORS according to this function -- 16 for
+ FALSE, and 8 for TRUE.
+
+ PDC_set_title() sets the title of the window in which the curses
+ program is running. This function may not do anything on some
+ platforms. (Currently it only works in Win32 and X11.)
+
+ Portability X/Open BSD SYS V
+ PDC_set_blink - - -
+ PDC_set_title - - -
+
+**man-end****************************************************************/
+
+int PDC_curs_set(int visibility)
+{
+ int ret_vis = SP->visibility;
+
+ PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
+
+ if (visibility != -1)
+ SP->visibility = visibility;
+
+ PDC_display_cursor(SP->cursrow, SP->curscol, SP->cursrow,
+ SP->curscol, visibility);
+
+ return ret_vis;
+}
+
+void PDC_set_title(const char *title)
+{
+ int len;
+
+ PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
+
+ len = strlen(title) + 1; /* write nul character */
+
+ XCursesInstruct(CURSES_TITLE);
+
+ if (XC_write_display_socket_int(len) >= 0)
+ if (XC_write_socket(xc_display_sock, title, len) >= 0)
+ return;
+
+ XCursesExitCursesProcess(1, "exiting from PDC_set_title");
+}
+
+int PDC_set_blink(bool blinkon)
+{
+ if (pdc_color_started)
+ COLORS = 16;
+
+ return blinkon ? ERR : OK;
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdcutil.c b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcutil.c
new file mode 100644
index 0000000000..5b5109f84e
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcutil.c
@@ -0,0 +1,39 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: pdcutil.c,v 1.10 2008/07/14 04:24:52 wmcbrine Exp $")
+
+#if defined(HAVE_POLL) && !defined(HAVE_USLEEP)
+# include <poll.h>
+#endif
+
+void PDC_beep(void)
+{
+ PDC_LOG(("PDC_beep() - called\n"));
+
+ XCursesInstruct(CURSES_BELL);
+}
+
+void PDC_napms(int ms)
+{
+ PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
+
+#if defined(HAVE_USLEEP)
+
+ usleep(1000 * ms);
+
+#elif defined(HAVE_POLL)
+ {
+ struct pollfd fd;
+ fd.fd = -1;
+ fd.events = 0;
+ poll(&fd, 1, ms);
+ }
+#endif
+}
+
+const char *PDC_sysname(void)
+{
+ return "X11";
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdcx11.c b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcx11.c
new file mode 100644
index 0000000000..1e8d0d163c
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcx11.c
@@ -0,0 +1,317 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: pdcx11.c,v 1.96 2008/07/14 04:24:52 wmcbrine Exp $")
+
+#include <errno.h>
+#include <stdlib.h>
+
+/*** Functions that are called by both processes ***/
+
+unsigned char *Xcurscr;
+
+int XCursesProcess = 1;
+int shmidSP;
+int shmid_Xcurscr;
+int shmkeySP;
+int shmkey_Xcurscr;
+int xc_otherpid;
+int XCursesLINES = 24;
+int XCursesCOLS = 80;
+int xc_display_sock;
+int xc_key_sock;
+int xc_display_sockets[2];
+int xc_key_sockets[2];
+int xc_exit_sock;
+
+fd_set xc_readfds;
+
+static void _dummy_function(void)
+{
+}
+
+void XC_get_line_lock(int row)
+{
+ /* loop until we can write to the line -- Patch by:
+ Georg Fuchs, georg.fuchs@rz.uni-regensburg.de */
+
+ while (*(Xcurscr + XCURSCR_FLAG_OFF + row))
+ _dummy_function();
+
+ *(Xcurscr + XCURSCR_FLAG_OFF + row) = 1;
+}
+
+void XC_release_line_lock(int row)
+{
+ *(Xcurscr + XCURSCR_FLAG_OFF + row) = 0;
+}
+
+int XC_write_socket(int sock_num, const void *buf, int len)
+{
+ int start = 0, rc;
+
+ PDC_LOG(("%s:XC_write_socket called: sock_num %d len %d\n",
+ XCLOGMSG, sock_num, len));
+
+#ifdef MOUSE_DEBUG
+ if (sock_num == xc_key_sock)
+ printf("%s:XC_write_socket(key) len: %d\n", XCLOGMSG, len);
+#endif
+ while (1)
+ {
+ rc = write(sock_num, buf + start, len);
+
+ if (rc < 0 || rc == len)
+ return rc;
+
+ len -= rc;
+ start = rc;
+ }
+}
+
+int XC_read_socket(int sock_num, void *buf, int len)
+{
+ int start = 0, length = len, rc;
+
+ PDC_LOG(("%s:XC_read_socket called: sock_num %d len %d\n",
+ XCLOGMSG, sock_num, len));
+
+ while (1)
+ {
+ rc = read(sock_num, buf + start, length);
+
+#ifdef MOUSE_DEBUG
+ if (sock_num == xc_key_sock)
+ printf("%s:XC_read_socket(key) rc %d errno %d "
+ "resized: %d\n", XCLOGMSG, rc, errno, SP->resized);
+#endif
+ if (rc < 0 && sock_num == xc_key_sock && errno == EINTR
+ && SP->resized != FALSE)
+ {
+ MOUSE_LOG(("%s:continuing\n", XCLOGMSG));
+
+ rc = 0;
+
+ if (SP->resized > 1)
+ SP->resized = TRUE;
+ else
+ SP->resized = FALSE;
+
+ memcpy(buf, &rc, sizeof(int));
+
+ return 0;
+ }
+
+ if (rc <= 0 || rc == length)
+ return rc;
+
+ length -= rc;
+ start = rc;
+ }
+}
+
+int XC_write_display_socket_int(int x)
+{
+ return XC_write_socket(xc_display_sock, &x, sizeof(int));
+}
+
+#ifdef PDCDEBUG
+void XC_say(const char *msg)
+{
+ PDC_LOG(("%s:%s", XCLOGMSG, msg));
+}
+#endif
+
+/*** Functions that are called by the "curses" process ***/
+
+int XCursesInstruct(int flag)
+{
+ PDC_LOG(("%s:XCursesInstruct() - called flag %d\n", XCLOGMSG, flag));
+
+ /* Send a request to X */
+
+ if (XC_write_display_socket_int(flag) < 0)
+ XCursesExitCursesProcess(4, "exiting from XCursesInstruct");
+
+ return OK;
+}
+
+int XCursesInstructAndWait(int flag)
+{
+ int result;
+
+ XC_LOG(("XCursesInstructAndWait() - called\n"));
+
+ /* tell X we want to do something */
+
+ XCursesInstruct(flag);
+
+ /* wait for X to say the refresh has occurred*/
+
+ if (XC_read_socket(xc_display_sock, &result, sizeof(int)) < 0)
+ XCursesExitCursesProcess(5, "exiting from XCursesInstructAndWait");
+
+ if (result != CURSES_CONTINUE)
+ XCursesExitCursesProcess(6, "exiting from XCursesInstructAndWait"
+ " - synchronization error");
+
+ return OK;
+}
+
+static int _setup_curses(void)
+{
+ int wait_value;
+
+ XC_LOG(("_setup_curses called\n"));
+
+ close(xc_display_sockets[1]);
+ close(xc_key_sockets[1]);
+
+ xc_display_sock = xc_display_sockets[0];
+ xc_key_sock = xc_key_sockets[0];
+
+ FD_ZERO(&xc_readfds);
+
+ XC_read_socket(xc_display_sock, &wait_value, sizeof(int));
+
+ if (wait_value != CURSES_CHILD)
+ return ERR;
+
+ /* Set LINES and COLS now so that the size of the shared memory
+ segment can be allocated */
+
+ if ((shmidSP = shmget(shmkeySP, sizeof(SCREEN) + XCURSESSHMMIN, 0700)) < 0)
+ {
+ perror("Cannot allocate shared memory for SCREEN");
+ kill(xc_otherpid, SIGKILL);
+ return ERR;
+ }
+
+ SP = (SCREEN*)shmat(shmidSP, 0, 0);
+
+ XCursesLINES = SP->lines;
+ LINES = XCursesLINES - SP->linesrippedoff - SP->slklines;
+ XCursesCOLS = COLS = SP->cols;
+
+ if ((shmid_Xcurscr = shmget(shmkey_Xcurscr,
+ SP->XcurscrSize + XCURSESSHMMIN, 0700)) < 0)
+ {
+ perror("Cannot allocate shared memory for curscr");
+ kill(xc_otherpid, SIGKILL);
+ return ERR;
+ }
+
+ PDC_LOG(("%s:shmid_Xcurscr %d shmkey_Xcurscr %d LINES %d COLS %d\n",
+ XCLOGMSG, shmid_Xcurscr, shmkey_Xcurscr, LINES, COLS));
+
+ Xcurscr = (unsigned char *)shmat(shmid_Xcurscr, 0, 0);
+ xc_atrtab = (short *)(Xcurscr + XCURSCR_ATRTAB_OFF);
+
+ XC_LOG(("cursesprocess exiting from Xinitscr\n"));
+
+ /* Always trap SIGWINCH if the C library supports SIGWINCH */
+
+ XCursesSetSignal(SIGWINCH, XCursesSigwinchHandler);
+
+ atexit(XCursesExit);
+
+ return OK;
+}
+
+int XCursesInitscr(int argc, char *argv[])
+{
+ int pid, rc;
+
+ XC_LOG(("XCursesInitscr() - called\n"));
+
+ shmkeySP = getpid();
+
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, xc_display_sockets) < 0)
+ {
+ fprintf(stderr, "ERROR: cannot create display socketpair\n");
+ return ERR;
+ }
+
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, xc_key_sockets) < 0)
+ {
+ fprintf(stderr, "ERROR: cannot create key socketpair\n");
+ return ERR;
+ }
+
+ pid = fork();
+
+ switch(pid)
+ {
+ case -1:
+ fprintf(stderr, "ERROR: cannot fork()\n");
+ return ERR;
+ break;
+
+ case 0: /* child */
+ shmkey_Xcurscr = getpid();
+#ifdef XISPARENT
+ XCursesProcess = 0;
+ rc = _setup_curses();
+#else
+ XCursesProcess = 1;
+ xc_otherpid = getppid();
+ rc = XCursesSetupX(argc, argv);
+#endif
+ break;
+
+ default: /* parent */
+ shmkey_Xcurscr = pid;
+#ifdef XISPARENT
+ XCursesProcess = 1;
+ xc_otherpid = pid;
+ rc = XCursesSetupX(argc, argv);
+#else
+ XCursesProcess = 0;
+ rc = _setup_curses();
+#endif
+ }
+
+ return rc;
+}
+
+static void _cleanup_curses_process(int rc)
+{
+ PDC_LOG(("%s:_cleanup_curses_process() - called: %d\n", XCLOGMSG, rc));
+
+ shutdown(xc_display_sock, 2);
+ close(xc_display_sock);
+
+ shutdown(xc_key_sock, 2);
+ close(xc_key_sock);
+
+ shmdt((char *)SP);
+ shmdt((char *)Xcurscr);
+
+ if (rc)
+ _exit(rc);
+}
+
+void XCursesExitCursesProcess(int rc, char *msg)
+{
+ PDC_LOG(("%s:XCursesExitCursesProcess() - called: %d %s\n",
+ XCLOGMSG, rc, msg));
+
+ endwin();
+ _cleanup_curses_process(rc);
+}
+
+void XCursesExit(void)
+{
+ static bool called = FALSE;
+
+ XC_LOG(("XCursesExit() - called\n"));
+
+ if (FALSE == called)
+ {
+ XCursesInstruct(CURSES_EXIT);
+ _cleanup_curses_process(0);
+
+ called = TRUE;
+ }
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/pdcx11.h b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcx11.h
new file mode 100644
index 0000000000..0b66c8809e
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/pdcx11.h
@@ -0,0 +1,188 @@
+/* Public Domain Curses */
+
+/* $Id: pdcx11.h,v 1.64 2008/07/14 04:24:52 wmcbrine Exp $ */
+
+#include <curspriv.h>
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <signal.h>
+#include <ctype.h>
+#include <pwd.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+#ifdef HAVE_SYS_SELECT_H
+# include <sys/select.h> /* AIX needs this for FD_ZERO etc macros */
+#endif
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
+#ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+#include <Intrinsic.h>
+#include <StringDefs.h>
+#include <Shell.h>
+
+#ifdef USE_XAW3D
+# include <Xaw3d/Box.h>
+# include <Xaw3d/Scrollbar.h>
+#elif defined(USE_NEXTAW)
+# include <neXtaw/Box.h>
+# include <neXtaw/Scrollbar.h>
+#else
+# include <Xaw/Box.h>
+# include <Xaw/Scrollbar.h>
+#endif
+#include "x11/ScrollBox.h"
+
+#include "Xmu/StdSel.h"
+#include "Xmu/Atoms.h"
+
+#include <keysym.h>
+#include <Xatom.h>
+
+#define XCURSCR_Y_SIZE (XCursesLINES * XCursesCOLS * sizeof(chtype))
+#define XCURSCR_FLAG_SIZE (XCursesLINES * sizeof(int))
+#define XCURSCR_START_SIZE (XCursesLINES * sizeof(int))
+#define XCURSCR_LENGTH_SIZE (XCursesLINES * sizeof(int))
+#define XCURSCR_ATRTAB_SIZE (PDC_COLOR_PAIRS * 2 * sizeof(short))
+#define XCURSCR_SIZE (XCURSCR_FLAG_SIZE + XCURSCR_START_SIZE + \
+ XCURSCR_LENGTH_SIZE + XCURSCR_Y_SIZE + XCURSCR_ATRTAB_SIZE + \
+ sizeof(XColor))
+
+#define XCURSCR_Y_OFF(y) ((y) * XCursesCOLS * sizeof(chtype))
+#define XCURSCR_FLAG_OFF (XCURSCR_Y_OFF(0) + XCURSCR_Y_SIZE)
+#define XCURSCR_START_OFF (XCURSCR_FLAG_OFF + XCURSCR_FLAG_SIZE)
+#define XCURSCR_LENGTH_OFF (XCURSCR_START_OFF + XCURSCR_START_SIZE)
+#define XCURSCR_ATRTAB_OFF (XCURSCR_LENGTH_OFF + XCURSCR_LENGTH_SIZE)
+#define XCURSCR_XCOLOR_OFF (XCURSCR_ATRTAB_OFF + XCURSCR_ATRTAB_SIZE)
+
+typedef struct
+{
+ int lines;
+ int cols;
+ Pixel cursorColor;
+ Pixel colorBlack;
+ Pixel colorRed;
+ Pixel colorGreen;
+ Pixel colorYellow;
+ Pixel colorBlue;
+ Pixel colorMagenta;
+ Pixel colorCyan;
+ Pixel colorWhite;
+ Pixel colorBoldBlack;
+ Pixel colorBoldRed;
+ Pixel colorBoldGreen;
+ Pixel colorBoldYellow;
+ Pixel colorBoldBlue;
+ Pixel colorBoldMagenta;
+ Pixel colorBoldCyan;
+ Pixel colorBoldWhite;
+ Pixel pointerForeColor;
+ Pixel pointerBackColor;
+ XFontStruct *normalFont;
+ XFontStruct *italicFont;
+ char *bitmap;
+#ifdef HAVE_XPM_H
+ char *pixmap;
+#endif
+ char *composeKey;
+ Cursor pointer;
+ int shmmin;
+ int borderWidth;
+ int borderColor;
+ int clickPeriod;
+ int doubleClickPeriod;
+ int scrollbarWidth;
+ int cursorBlinkRate;
+ char *textCursor;
+} XCursesAppData;
+
+extern XCursesAppData xc_app_data;
+
+#define XCURSESSHMMIN xc_app_data.shmmin
+
+#define XCLOGMSG (XCursesProcess ? " X" : "CURSES")
+
+void XC_get_line_lock(int);
+void XC_release_line_lock(int);
+
+int PDC_display_cursor(int, int, int, int, int);
+
+void XCursesExitCursesProcess(int, char *);
+int XCursesInstruct(int);
+int XCursesInstructAndWait(int);
+int XCursesInitscr(int, char **);
+
+int XC_write_socket(int, const void *, int);
+int XC_read_socket(int, void *, int);
+int XC_write_display_socket_int(int);
+
+int XCursesSetupX(int argc, char *argv[]);
+RETSIGTYPE XCursesSigwinchHandler(int signo);
+
+#ifdef _HPUX_SOURCE
+# define FD_SET_CAST int *
+#else
+# define FD_SET_CAST fd_set *
+#endif
+
+extern fd_set xc_readfds;
+
+extern unsigned char *Xcurscr;
+extern int XCursesProcess;
+extern int shmidSP;
+extern int shmid_Xcurscr;
+extern int shmkeySP;
+extern int shmkey_Xcurscr;
+extern int xc_otherpid;
+extern int XCursesLINES;
+extern int XCursesCOLS;
+extern int xc_display_sock;
+extern int xc_key_sock;
+extern int xc_display_sockets[2];
+extern int xc_key_sockets[2];
+extern int xc_exit_sock;
+
+typedef RETSIGTYPE (*signal_handler)();
+
+signal_handler XCursesSetSignal(int, signal_handler);
+
+#ifdef PDCDEBUG
+void XC_say(const char *msg);
+# define XC_LOG(x) XC_say x
+#else
+# define XC_LOG(x)
+#endif
+
+#ifdef MOUSE_DEBUG
+# define MOUSE_LOG(x) printf x
+#else
+# define MOUSE_LOG(x)
+#endif
+
+enum
+{
+ CURSES_CLEAR_SELECTION, CURSES_DISPLAY_CURSOR, CURSES_SET_SELECTION,
+ CURSES_GET_SELECTION, CURSES_TITLE, CURSES_REFRESH_SCROLLBAR,
+ CURSES_RESIZE, CURSES_BELL, CURSES_CONTINUE, CURSES_CURSOR,
+ CURSES_CHILD, CURSES_REFRESH, CURSES_GET_COLOR, CURSES_SET_COLOR,
+ CURSES_EXIT
+};
+
+extern short *xc_atrtab;
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/sb.c b/payloads/libpayload/curses/PDCurses-3.4/x11/sb.c
new file mode 100644
index 0000000000..a34f502b24
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/sb.c
@@ -0,0 +1,153 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: sb.c,v 1.27 2008/07/14 04:24:52 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: sb
+
+ Synopsis:
+ int sb_init(void)
+ int sb_set_horz(int total, int viewport, int cur)
+ int sb_set_vert(int total, int viewport, int cur)
+ int sb_get_horz(int *total, int *viewport, int *cur)
+ int sb_get_vert(int *total, int *viewport, int *cur)
+ int sb_refresh(void);
+
+ Description:
+ These functions manipulate the scrollbar.
+
+ Return Value:
+ All functions return OK on success and ERR on error.
+
+ Portability X/Open BSD SYS V
+ sb_init - - -
+ sb_set_horz - - -
+ sb_set_vert - - -
+ sb_get_horz - - -
+ sb_get_vert - - -
+ sb_refresh - - -
+
+**man-end****************************************************************/
+
+bool sb_started = FALSE;
+
+/* sb_init() is the sb initialization routine.
+ This must be called before initscr(). */
+
+int sb_init(void)
+{
+ PDC_LOG(("sb_init() - called\n"));
+
+ if (SP)
+ return ERR;
+
+ sb_started = TRUE;
+
+ return OK;
+}
+
+/* sb_set_horz() - Used to set horizontal scrollbar.
+
+ total = total number of columns
+ viewport = size of viewport in columns
+ cur = current column in total */
+
+int sb_set_horz(int total, int viewport, int cur)
+{
+ PDC_LOG(("sb_set_horz() - called: total %d viewport %d cur %d\n",
+ total, viewport, cur));
+
+ if (!SP)
+ return ERR;
+
+ SP->sb_total_x = total;
+ SP->sb_viewport_x = viewport;
+ SP->sb_cur_x = cur;
+
+ return OK;
+}
+
+/* sb_set_vert() - Used to set vertical scrollbar.
+
+ total = total number of columns on line
+ viewport = size of viewport in columns
+ cur = current column in total */
+
+int sb_set_vert(int total, int viewport, int cur)
+{
+ PDC_LOG(("sb_set_vert() - called: total %d viewport %d cur %d\n",
+ total, viewport, cur));
+
+ if (!SP)
+ return ERR;
+
+ SP->sb_total_y = total;
+ SP->sb_viewport_y = viewport;
+ SP->sb_cur_y = cur;
+
+ return OK;
+}
+
+/* sb_get_horz() - Used to get horizontal scrollbar.
+
+ total = total number of lines
+ viewport = size of viewport in lines
+ cur = current line in total */
+
+int sb_get_horz(int *total, int *viewport, int *cur)
+{
+ PDC_LOG(("sb_get_horz() - called\n"));
+
+ if (!SP)
+ return ERR;
+
+ if (total)
+ *total = SP->sb_total_x;
+ if (viewport)
+ *viewport = SP->sb_viewport_x;
+ if (cur)
+ *cur = SP->sb_cur_x;
+
+ return OK;
+}
+
+/* sb_get_vert() - Used to get vertical scrollbar.
+
+ total = total number of lines
+ viewport = size of viewport in lines
+ cur = current line in total */
+
+int sb_get_vert(int *total, int *viewport, int *cur)
+{
+ PDC_LOG(("sb_get_vert() - called\n"));
+
+ if (!SP)
+ return ERR;
+
+ if (total)
+ *total = SP->sb_total_y;
+ if (viewport)
+ *viewport = SP->sb_viewport_y;
+ if (cur)
+ *cur = SP->sb_cur_y;
+
+ return OK;
+}
+
+/* sb_refresh() - Used to draw the scrollbars. */
+
+int sb_refresh(void)
+{
+ PDC_LOG(("sb_refresh() - called\n"));
+
+ if (!SP)
+ return ERR;
+
+ XCursesInstruct(CURSES_REFRESH_SCROLLBAR);
+
+ return OK;
+}
+
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/x11.c b/payloads/libpayload/curses/PDCurses-3.4/x11/x11.c
new file mode 100644
index 0000000000..97d44985e5
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/x11.c
@@ -0,0 +1,3229 @@
+/* Public Domain Curses */
+
+#include "pdcx11.h"
+
+RCSID("$Id: x11.c,v 1.94 2008/07/14 04:33:26 wmcbrine Exp $")
+
+#ifdef HAVE_DECKEYSYM_H
+# include <DECkeysym.h>
+#endif
+
+#ifdef HAVE_SUNKEYSYM_H
+# include <Sunkeysym.h>
+#endif
+
+#ifdef HAVE_XPM_H
+# include <xpm.h>
+#endif
+
+#if defined PDC_XIM
+# include <Xlocale.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef XPOINTER_TYPEDEFED
+typedef char * XPointer;
+#endif
+
+#ifndef MAX_PATH
+# define MAX_PATH 256
+#endif
+
+XCursesAppData xc_app_data;
+
+#if NeedWidePrototypes
+# define PDC_SCROLLBAR_TYPE double
+#else
+# define PDC_SCROLLBAR_TYPE float
+#endif
+
+#define MAX_COLORS 16 /* maximum of "normal" colors */
+#define COLOR_CURSOR MAX_COLORS /* color of cursor */
+#define COLOR_BORDER MAX_COLORS + 1 /* color of border */
+
+#define XCURSESDISPLAY (XtDisplay(drawing))
+#define XCURSESWIN (XtWindow(drawing))
+
+/* Default icons for XCurses applications. */
+
+#include "big_icon.xbm"
+#include "little_icon.xbm"
+
+static void _selection_off(void);
+static void _display_cursor(int, int, int, int);
+static void _redraw_cursor(void);
+static void _exit_process(int, int, char *);
+static void _send_key_to_curses(unsigned long, MOUSE_STATUS *, bool);
+
+static void XCursesButton(Widget, XEvent *, String *, Cardinal *);
+static void XCursesHandleString(Widget, XEvent *, String *, Cardinal *);
+static void XCursesKeyPress(Widget, XEvent *, String *, Cardinal *);
+static void XCursesPasteSelection(Widget, XButtonEvent *);
+
+static struct
+{
+ KeySym keycode;
+ bool numkeypad;
+ unsigned short normal;
+ unsigned short shifted;
+ unsigned short control;
+ unsigned short alt;
+} key_table[] =
+{
+/* keycode keypad normal shifted control alt*/
+ {XK_Left, FALSE, KEY_LEFT, KEY_SLEFT, CTL_LEFT, ALT_LEFT},
+ {XK_Right, FALSE, KEY_RIGHT, KEY_SRIGHT, CTL_RIGHT, ALT_RIGHT},
+ {XK_Up, FALSE, KEY_UP, KEY_SUP, CTL_UP, ALT_UP},
+ {XK_Down, FALSE, KEY_DOWN, KEY_SDOWN, CTL_DOWN, ALT_DOWN},
+ {XK_Home, FALSE, KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME},
+/* Sun Type 4 keyboard */
+ {XK_R7, FALSE, KEY_HOME, KEY_SHOME, CTL_HOME, ALT_HOME},
+ {XK_End, FALSE, KEY_END, KEY_SEND, CTL_END, ALT_END},
+/* Sun Type 4 keyboard */
+ {XK_R13, FALSE, KEY_END, KEY_SEND, CTL_END, ALT_END},
+ {XK_Prior, FALSE, KEY_PPAGE, KEY_SPREVIOUS,CTL_PGUP, ALT_PGUP},
+/* Sun Type 4 keyboard */
+ {XK_R9, FALSE, KEY_PPAGE, KEY_SPREVIOUS,CTL_PGUP, ALT_PGUP},
+ {XK_Next, FALSE, KEY_NPAGE, KEY_SNEXT, CTL_PGDN, ALT_PGDN},
+/* Sun Type 4 keyboard */
+ {XK_R15, FALSE, KEY_NPAGE, KEY_SNEXT, CTL_PGDN, ALT_PGDN},
+ {XK_Insert, FALSE, KEY_IC, KEY_SIC, CTL_INS, ALT_INS},
+ {XK_Delete, FALSE, KEY_DC, KEY_SDC, CTL_DEL, ALT_DEL},
+ {XK_F1, FALSE, KEY_F(1), KEY_F(13), KEY_F(25), KEY_F(37)},
+ {XK_F2, FALSE, KEY_F(2), KEY_F(14), KEY_F(26), KEY_F(38)},
+ {XK_F3, FALSE, KEY_F(3), KEY_F(15), KEY_F(27), KEY_F(39)},
+ {XK_F4, FALSE, KEY_F(4), KEY_F(16), KEY_F(28), KEY_F(40)},
+ {XK_F5, FALSE, KEY_F(5), KEY_F(17), KEY_F(29), KEY_F(41)},
+ {XK_F6, FALSE, KEY_F(6), KEY_F(18), KEY_F(30), KEY_F(42)},
+ {XK_F7, FALSE, KEY_F(7), KEY_F(19), KEY_F(31), KEY_F(43)},
+ {XK_F8, FALSE, KEY_F(8), KEY_F(20), KEY_F(32), KEY_F(44)},
+ {XK_F9, FALSE, KEY_F(9), KEY_F(21), KEY_F(33), KEY_F(45)},
+ {XK_F10, FALSE, KEY_F(10), KEY_F(22), KEY_F(34), KEY_F(46)},
+ {XK_F11, FALSE, KEY_F(11), KEY_F(23), KEY_F(35), KEY_F(47)},
+ {XK_F12, FALSE, KEY_F(12), KEY_F(24), KEY_F(36), KEY_F(48)},
+ {XK_F13, FALSE, KEY_F(13), KEY_F(25), KEY_F(37), KEY_F(49)},
+ {XK_F14, FALSE, KEY_F(14), KEY_F(26), KEY_F(38), KEY_F(50)},
+ {XK_F15, FALSE, KEY_F(15), KEY_F(27), KEY_F(39), KEY_F(51)},
+ {XK_F16, FALSE, KEY_F(16), KEY_F(28), KEY_F(40), KEY_F(52)},
+ {XK_F17, FALSE, KEY_F(17), KEY_F(29), KEY_F(41), KEY_F(53)},
+ {XK_F18, FALSE, KEY_F(18), KEY_F(30), KEY_F(42), KEY_F(54)},
+ {XK_F19, FALSE, KEY_F(19), KEY_F(31), KEY_F(43), KEY_F(55)},
+ {XK_F20, FALSE, KEY_F(20), KEY_F(32), KEY_F(44), KEY_F(56)},
+ {XK_BackSpace, FALSE, 0x08, 0x08, CTL_BKSP, ALT_BKSP},
+ {XK_Tab, FALSE, 0x09, KEY_BTAB, CTL_TAB, ALT_TAB},
+ {XK_Select, FALSE, KEY_SELECT, KEY_SELECT, KEY_SELECT, KEY_SELECT},
+ {XK_Print, FALSE, KEY_PRINT, KEY_SPRINT, KEY_PRINT, KEY_PRINT},
+ {XK_Find, FALSE, KEY_FIND, KEY_SFIND, KEY_FIND, KEY_FIND},
+ {XK_Pause, FALSE, KEY_SUSPEND, KEY_SSUSPEND, KEY_SUSPEND, KEY_SUSPEND},
+ {XK_Clear, FALSE, KEY_CLEAR, KEY_CLEAR, KEY_CLEAR, KEY_CLEAR},
+ {XK_Cancel, FALSE, KEY_CANCEL, KEY_SCANCEL, KEY_CANCEL, KEY_CANCEL},
+ {XK_Break, FALSE, KEY_BREAK, KEY_BREAK, KEY_BREAK, KEY_BREAK},
+ {XK_Help, FALSE, KEY_HELP, KEY_SHELP, KEY_LHELP, KEY_HELP},
+ {XK_L4, FALSE, KEY_UNDO, KEY_SUNDO, KEY_UNDO, KEY_UNDO},
+ {XK_L6, FALSE, KEY_COPY, KEY_SCOPY, KEY_COPY, KEY_COPY},
+ {XK_L9, FALSE, KEY_FIND, KEY_SFIND, KEY_FIND, KEY_FIND},
+ {XK_Menu, FALSE, KEY_OPTIONS, KEY_SOPTIONS, KEY_OPTIONS, KEY_OPTIONS},
+#ifdef HAVE_SUNKEYSYM_H
+ {SunXK_F36, FALSE, KEY_F(41), KEY_F(43), KEY_F(45), KEY_F(47)},
+ {SunXK_F37, FALSE, KEY_F(42), KEY_F(44), KEY_F(46), KEY_F(48)},
+#endif
+#ifdef HAVE_DECKEYSYM_H
+ {DXK_Remove, FALSE, KEY_DC, KEY_SDC, CTL_DEL, ALT_DEL},
+#endif
+ {XK_Escape, FALSE, 0x1B, 0x1B, 0x1B, ALT_ESC},
+ {XK_KP_Enter, TRUE, PADENTER, PADENTER, CTL_PADENTER,ALT_PADENTER},
+ {XK_KP_Add, TRUE, PADPLUS, '+', CTL_PADPLUS, ALT_PADPLUS},
+ {XK_KP_Subtract,TRUE, PADMINUS, '-', CTL_PADMINUS,ALT_PADMINUS},
+ {XK_KP_Multiply,TRUE, PADSTAR, '*', CTL_PADSTAR, ALT_PADSTAR},
+/* Sun Type 4 keyboard */
+ {XK_R6, TRUE, PADSTAR, '*', CTL_PADSTAR, ALT_PADSTAR},
+ {XK_KP_Divide, TRUE, PADSLASH, '/', CTL_PADSLASH,ALT_PADSLASH},
+/* Sun Type 4 keyboard */
+ {XK_R5, TRUE, PADSLASH, '/', CTL_PADSLASH,ALT_PADSLASH},
+ {XK_KP_Decimal,TRUE, PADSTOP, '.', CTL_PADSTOP, ALT_PADSTOP},
+ {XK_KP_0, TRUE, PAD0, '0', CTL_PAD0, ALT_PAD0},
+ {XK_KP_1, TRUE, KEY_C1, '1', CTL_PAD1, ALT_PAD1},
+ {XK_KP_2, TRUE, KEY_C2, '2', CTL_PAD2, ALT_PAD2},
+ {XK_KP_3, TRUE, KEY_C3, '3', CTL_PAD3, ALT_PAD3},
+ {XK_KP_4, TRUE, KEY_B1, '4', CTL_PAD4, ALT_PAD4},
+ {XK_KP_5, TRUE, KEY_B2, '5', CTL_PAD5, ALT_PAD5},
+/* Sun Type 4 keyboard */
+ {XK_R11, TRUE, KEY_B2, '5', CTL_PAD5, ALT_PAD5},
+ {XK_KP_6, TRUE, KEY_B3, '6', CTL_PAD6, ALT_PAD6},
+ {XK_KP_7, TRUE, KEY_A1, '7', CTL_PAD7, ALT_PAD7},
+ {XK_KP_8, TRUE, KEY_A2, '8', CTL_PAD8, ALT_PAD8},
+ {XK_KP_9, TRUE, KEY_A3, '9', CTL_PAD9, ALT_PAD9},
+/* the following added to support Sun Type 5 keyboards */
+ {XK_F21, FALSE, KEY_SUSPEND, KEY_SSUSPEND, KEY_SUSPEND, KEY_SUSPEND},
+ {XK_F22, FALSE, KEY_PRINT, KEY_SPRINT, KEY_PRINT, KEY_PRINT},
+ {XK_F24, TRUE, PADMINUS, '-', CTL_PADMINUS,ALT_PADMINUS},
+/* Sun Type 4 keyboard */
+ {XK_F25, TRUE, PADSLASH, '/', CTL_PADSLASH,ALT_PADSLASH},
+/* Sun Type 4 keyboard */
+ {XK_F26, TRUE, PADSTAR, '*', CTL_PADSTAR, ALT_PADSTAR},
+ {XK_F27, TRUE, KEY_A1, '7', CTL_PAD7, ALT_PAD7},
+ {XK_F29, TRUE, KEY_A3, '9', CTL_PAD9, ALT_PAD9},
+ {XK_F31, TRUE, KEY_B2, '5', CTL_PAD5, ALT_PAD5},
+ {XK_F35, TRUE, KEY_C3, '3', CTL_PAD3, ALT_PAD3},
+#ifdef HAVE_XK_KP_DELETE
+ {XK_KP_Delete, TRUE, PADSTOP, '.', CTL_PADSTOP, ALT_PADSTOP},
+#endif
+#ifdef HAVE_XK_KP_INSERT
+ {XK_KP_Insert, TRUE, PAD0, '0', CTL_PAD0, ALT_PAD0},
+#endif
+#ifdef HAVE_XK_KP_END
+ {XK_KP_End, TRUE, KEY_C1, '1', CTL_PAD1, ALT_PAD1},
+#endif
+#ifdef HAVE_XK_KP_DOWN
+ {XK_KP_Down, TRUE, KEY_C2, '2', CTL_PAD2, ALT_PAD2},
+#endif
+#ifdef HAVE_XK_KP_NEXT
+ {XK_KP_Next, TRUE, KEY_C3, '3', CTL_PAD3, ALT_PAD3},
+#endif
+#ifdef HAVE_XK_KP_LEFT
+ {XK_KP_Left, TRUE, KEY_B1, '4', CTL_PAD4, ALT_PAD4},
+#endif
+#ifdef HAVE_XK_KP_BEGIN
+ {XK_KP_Begin, TRUE, KEY_B2, '5', CTL_PAD5, ALT_PAD5},
+#endif
+#ifdef HAVE_XK_KP_RIGHT
+ {XK_KP_Right, TRUE, KEY_B3, '6', CTL_PAD6, ALT_PAD6},
+#endif
+#ifdef HAVE_XK_KP_HOME
+ {XK_KP_Home, TRUE, KEY_A1, '7', CTL_PAD7, ALT_PAD7},
+#endif
+#ifdef HAVE_XK_KP_UP
+ {XK_KP_Up, TRUE, KEY_A2, '8', CTL_PAD8, ALT_PAD8},
+#endif
+#ifdef HAVE_XK_KP_PRIOR
+ {XK_KP_Prior, TRUE, KEY_A3, '9', CTL_PAD9, ALT_PAD9},
+#endif
+ {0, 0, 0, 0, 0, 0}
+};
+
+#ifndef PDC_XIM
+# include "compose.h"
+#endif
+
+#define BITMAPDEPTH 1
+
+unsigned long pdc_key_modifiers = 0L;
+
+static GC normal_gc, block_cursor_gc, rect_cursor_gc, italic_gc, border_gc;
+static int font_height, font_width, font_ascent, font_descent,
+ window_width, window_height;
+static int resize_window_width = 0, resize_window_height = 0;
+static char *bitmap_file = NULL;
+#ifdef HAVE_XPM_H
+static char *pixmap_file = NULL;
+#endif
+static KeySym keysym = 0;
+
+static int state_mask[8] =
+{
+ ShiftMask,
+ LockMask,
+ ControlMask,
+ Mod1Mask,
+ Mod2Mask,
+ Mod3Mask,
+ Mod4Mask,
+ Mod5Mask
+};
+
+static Atom wm_atom[2];
+static String class_name = "XCurses";
+static XtAppContext app_context;
+static Widget topLevel, drawing, scrollBox, scrollVert, scrollHoriz;
+static int received_map_notify = 0;
+static bool mouse_selection = FALSE;
+static chtype *tmpsel = NULL;
+static unsigned long tmpsel_length = 0;
+static int selection_start_x = 0, selection_start_y = 0,
+ selection_end_x = 0, selection_end_y = 0;
+static Pixmap icon_bitmap;
+#ifdef HAVE_XPM_H
+static Pixmap icon_pixmap;
+static Pixmap icon_pixmap_mask;
+#endif
+static bool visible_cursor = FALSE;
+static bool window_entered = TRUE;
+static char *program_name;
+
+/* Macros just for app_resources */
+
+#ifdef PDC_WIDE
+# define DEFFONT "-misc-fixed-medium-r-normal--20-200-75-75-c-100-iso10646-1"
+#else
+# define DEFFONT "7x13"
+#endif
+
+#define APPDATAOFF(n) XtOffsetOf(XCursesAppData, n)
+
+#define RINT(name1, name2, value) { \
+ #name1, #name2, XtRInt, \
+ sizeof(int), APPDATAOFF(name1), XtRImmediate, \
+ (XtPointer)value \
+ }
+
+#define RPIXEL(name1, name2, value) { \
+ #name1, #name2, XtRPixel, \
+ sizeof(Pixel), APPDATAOFF(name1), XtRString, \
+ (XtPointer)#value \
+ }
+
+#define RCOLOR(name, value) RPIXEL(color##name, Color##name, value)
+
+
+#define RSTRINGP(name1, name2, param) { \
+ #name1, #name2, XtRString, \
+ MAX_PATH, APPDATAOFF(name1), XtRString, (XtPointer)param \
+ }
+
+#define RSTRING(name1, name2) RSTRINGP(name1, name2, "")
+
+#define RFONT(name1, name2, value) { \
+ #name1, #name2, XtRFontStruct, \
+ sizeof(XFontStruct), APPDATAOFF(name1), XtRString, \
+ (XtPointer)value \
+ }
+
+#define RCURSOR(name1, name2, value) { \
+ #name1, #name2, XtRCursor, \
+ sizeof(Cursor), APPDATAOFF(name1), XtRString, \
+ (XtPointer)#value \
+ }
+
+static XtResource app_resources[] =
+{
+ RINT(lines, Lines, 24),
+ RINT(cols, Cols, 80),
+
+ RPIXEL(cursorColor, CursorColor, Red),
+
+ RCOLOR(Black, Black),
+ RCOLOR(Red, red3),
+ RCOLOR(Green, green3),
+ RCOLOR(Yellow, yellow3),
+ RCOLOR(Blue, blue3),
+ RCOLOR(Magenta, magenta3),
+ RCOLOR(Cyan, cyan3),
+ RCOLOR(White, Grey),
+
+ RCOLOR(BoldBlack, grey40),
+ RCOLOR(BoldRed, red1),
+ RCOLOR(BoldGreen, green1),
+ RCOLOR(BoldYellow, yellow1),
+ RCOLOR(BoldBlue, blue1),
+ RCOLOR(BoldMagenta, magenta1),
+ RCOLOR(BoldCyan, cyan1),
+ RCOLOR(BoldWhite, White),
+
+ RFONT(normalFont, NormalFont, DEFFONT),
+ RFONT(italicFont, ItalicFont, DEFFONT),
+
+ RSTRING(bitmap, Bitmap),
+#ifdef HAVE_XPM_H
+ RSTRING(pixmap, Pixmap),
+#endif
+ RSTRINGP(composeKey, ComposeKey, "Multi_key"),
+
+ RCURSOR(pointer, Pointer, xterm),
+
+ RPIXEL(pointerForeColor, PointerForeColor, Black),
+ RPIXEL(pointerBackColor, PointerBackColor, White),
+
+ RINT(shmmin, Shmmin, 0),
+ RINT(borderWidth, BorderWidth, 0),
+
+ RPIXEL(borderColor, BorderColor, Black),
+
+ RINT(doubleClickPeriod, DoubleClickPeriod, (PDC_CLICK_PERIOD * 2)),
+ RINT(clickPeriod, ClickPeriod, PDC_CLICK_PERIOD),
+ RINT(scrollbarWidth, ScrollbarWidth, 15),
+ RINT(cursorBlinkRate, CursorBlinkRate, 0),
+
+ RSTRING(textCursor, TextCursor)
+};
+
+#undef RCURSOR
+#undef RFONT
+#undef RSTRING
+#undef RCOLOR
+#undef RPIXEL
+#undef RINT
+#undef APPDATAOFF
+#undef DEFFONT
+
+/* Macros for options */
+
+#define COPT(name) {"-" #name, "*" #name, XrmoptionSepArg, NULL}
+#define CCOLOR(name) COPT(color##name)
+
+static XrmOptionDescRec options[] =
+{
+ COPT(lines), COPT(cols), COPT(normalFont), COPT(italicFont),
+ COPT(bitmap),
+#ifdef HAVE_XPM_H
+ COPT(pixmap),
+#endif
+ COPT(pointer), COPT(shmmin), COPT(composeKey), COPT(clickPeriod),
+ COPT(doubleClickPeriod), COPT(scrollbarWidth),
+ COPT(pointerForeColor), COPT(pointerBackColor),
+ COPT(cursorBlinkRate), COPT(cursorColor), COPT(textCursor),
+
+ CCOLOR(Black), CCOLOR(Red), CCOLOR(Green), CCOLOR(Yellow),
+ CCOLOR(Blue), CCOLOR(Magenta), CCOLOR(Cyan), CCOLOR(White),
+
+ CCOLOR(BoldBlack), CCOLOR(BoldRed), CCOLOR(BoldGreen),
+ CCOLOR(BoldYellow), CCOLOR(BoldBlue), CCOLOR(BoldMagenta),
+ CCOLOR(BoldCyan), CCOLOR(BoldWhite)
+};
+
+#undef CCOLOR
+#undef COPT
+
+static XtActionsRec action_table[] =
+{
+ {"XCursesButton", (XtActionProc)XCursesButton},
+ {"XCursesKeyPress", (XtActionProc)XCursesKeyPress},
+ {"XCursesPasteSelection", (XtActionProc)XCursesPasteSelection},
+ {"string", (XtActionProc)XCursesHandleString}
+};
+
+static bool after_first_curses_request = FALSE;
+static Pixel colors[MAX_COLORS + 2];
+static bool vertical_cursor = FALSE;
+
+#ifdef PDC_XIM
+static XIM Xim = NULL;
+static XIC Xic = NULL;
+#endif
+
+static const char *default_translations =
+{
+ "<Key>: XCursesKeyPress() \n" \
+ "<KeyUp>: XCursesKeyPress() \n" \
+ "<BtnDown>: XCursesButton() \n" \
+ "<BtnUp>: XCursesButton() \n" \
+ "<BtnMotion>: XCursesButton()"
+};
+
+static int _to_utf8(char *outcode, chtype code)
+{
+#ifdef PDC_WIDE
+ if (code & A_ALTCHARSET && !(code & 0xff80))
+ code = acs_map[code & 0x7f];
+#endif
+ code &= A_CHARTEXT;
+
+ if (code < 0x80)
+ {
+ outcode[0] = code;
+ return 1;
+ }
+ else
+ if (code < 0x800)
+ {
+ outcode[0] = ((code & 0x07c0) >> 6) | 0xc0;
+ outcode[1] = (code & 0x003f) | 0x80;
+ return 2;
+ }
+ else
+ {
+ outcode[0] = ((code & 0xf000) >> 12) | 0xe0;
+ outcode[1] = ((code & 0x0fc0) >> 6) | 0x80;
+ outcode[2] = (code & 0x003f) | 0x80;
+ return 3;
+ }
+}
+
+static int _from_utf8(wchar_t *pwc, const char *s, size_t n)
+{
+ wchar_t key;
+ int i = -1;
+ const unsigned char *string;
+
+ if (!s || (n < 1))
+ return -1;
+
+ if (!*s)
+ return 0;
+
+ string = (const unsigned char *)s;
+
+ key = string[0];
+
+ /* Simplistic UTF-8 decoder -- only does the BMP, minimal validation */
+
+ if (key & 0x80)
+ {
+ if ((key & 0xe0) == 0xc0)
+ {
+ if (1 < n)
+ {
+ key = ((key & 0x1f) << 6) | (string[1] & 0x3f);
+ i = 2;
+ }
+ }
+ else if ((key & 0xe0) == 0xe0)
+ {
+ if (2 < n)
+ {
+ key = ((key & 0x0f) << 12) |
+ ((string[1] & 0x3f) << 6) | (string[2] & 0x3f);
+ i = 3;
+ }
+ }
+ }
+ else
+ i = 1;
+
+ if (i)
+ *pwc = key;
+
+ return i;
+}
+
+#ifndef X_HAVE_UTF8_STRING
+static Atom XA_UTF8_STRING(Display *dpy)
+{
+ static AtomPtr p = NULL;
+
+ if (!p)
+ p = XmuMakeAtom("UTF8_STRING");
+
+ return XmuInternAtom(dpy, p);
+}
+#endif
+
+signal_handler XCursesSetSignal(int signo, signal_handler action)
+{
+#if defined(SA_INTERRUPT) || defined(SA_RESTART)
+ struct sigaction sigact, osigact;
+
+ sigact.sa_handler = action;
+
+ sigact.sa_flags =
+# ifdef SA_INTERRUPT
+# ifdef SA_RESTART
+ SA_INTERRUPT | SA_RESTART;
+# else
+ SA_INTERRUPT;
+# endif
+# else /* must be SA_RESTART */
+ SA_RESTART;
+# endif
+ sigemptyset(&sigact.sa_mask);
+
+ if (sigaction(signo, &sigact, &osigact))
+ return SIG_ERR;
+
+ return osigact.sa_handler;
+
+#else /* not SA_INTERRUPT or SA_RESTART, use plain signal */
+ return signal(signo, action);
+#endif
+}
+
+RETSIGTYPE XCursesSigwinchHandler(int signo)
+{
+ PDC_LOG(("%s:XCursesSigwinchHandler() - called: SIGNO: %d\n",
+ XCLOGMSG, signo));
+
+ /* Patch by: Georg Fuchs, georg.fuchs@rz.uni-regensburg.de
+ 02-Feb-1999 */
+
+ SP->resized += 1;
+
+ /* Always trap SIGWINCH if the C library supports SIGWINCH */
+
+#ifdef SIGWINCH
+ XCursesSetSignal(SIGWINCH, XCursesSigwinchHandler);
+#endif
+}
+
+/* Convert character positions x and y to pixel positions, stored in
+ xpos and ypos */
+
+static void _make_xy(int x, int y, int *xpos, int *ypos)
+{
+ *xpos = (x * font_width) + xc_app_data.borderWidth;
+ *ypos = xc_app_data.normalFont->ascent + (y * font_height) +
+ xc_app_data.borderWidth;
+}
+
+/* Output a block of characters with common attributes */
+
+static int _new_packet(chtype attr, bool rev, int len, int col, int row,
+#ifdef PDC_WIDE
+ XChar2b *text)
+#else
+ char *text)
+#endif
+{
+ GC gc;
+ int xpos, ypos;
+ short fore, back;
+
+ PDC_pair_content(PAIR_NUMBER(attr), &fore, &back);
+
+#ifdef PDC_WIDE
+ text[len].byte1 = text[len].byte2 = 0;
+#else
+ text[len] = '\0';
+#endif
+
+ /* Specify the color table offsets */
+
+ fore |= (attr & A_BOLD) ? 8 : 0;
+ back |= (attr & A_BLINK) ? 8 : 0;
+
+ /* Reverse flag = highlighted selection XOR A_REVERSE set */
+
+ rev ^= !!(attr & A_REVERSE);
+
+ /* Determine which GC to use - normal or italic */
+
+ gc = (attr & A_ITALIC) ? italic_gc : normal_gc;
+
+ /* Draw it */
+
+ XSetForeground(XCURSESDISPLAY, gc, colors[rev ? back : fore]);
+ XSetBackground(XCURSESDISPLAY, gc, colors[rev ? fore : back]);
+
+ _make_xy(col, row, &xpos, &ypos);
+
+#ifdef PDC_WIDE
+ XDrawImageString16(
+#else
+ XDrawImageString(
+#endif
+ XCURSESDISPLAY, XCURSESWIN, gc, xpos, ypos, text, len);
+
+ /* Underline, etc. */
+
+ if (attr & (A_LEFTLINE|A_RIGHTLINE|A_UNDERLINE))
+ {
+ int k;
+
+ if (SP->line_color != -1)
+ XSetForeground(XCURSESDISPLAY, gc, colors[SP->line_color]);
+
+ if (attr & A_UNDERLINE) /* UNDER */
+ XDrawLine(XCURSESDISPLAY, XCURSESWIN, gc,
+ xpos, ypos + 1, xpos + font_width * len, ypos + 1);
+
+ if (attr & A_LEFTLINE) /* LEFT */
+ for (k = 0; k < len; k++)
+ {
+ int x = xpos + font_width * k - 1;
+ XDrawLine(XCURSESDISPLAY, XCURSESWIN, gc,
+ x, ypos - font_ascent, x, ypos + font_descent);
+ }
+
+ if (attr & A_RIGHTLINE) /* RIGHT */
+ for (k = 0; k < len; k++)
+ {
+ int x = xpos + font_width * (k + 1) - 1;
+ XDrawLine(XCURSESDISPLAY, XCURSESWIN, gc,
+ x, ypos - font_ascent, x, ypos + font_descent);
+ }
+ }
+
+ PDC_LOG(("%s:_new_packet() - row: %d col: %d "
+ "num_cols: %d fore: %d back: %d text:<%s>\n",
+ XCLOGMSG, row, col, len, fore, back, text));
+
+ return OK;
+}
+
+/* The core display routine -- update one line of text */
+
+static int _display_text(const chtype *ch, int row, int col,
+ int num_cols, bool highlight)
+{
+#ifdef PDC_WIDE
+ XChar2b text[513];
+#else
+ char text[513];
+#endif
+ chtype old_attr, attr;
+ int i, j;
+
+ PDC_LOG(("%s:_display_text() - called: row: %d col: %d "
+ "num_cols: %d\n", XCLOGMSG, row, col, num_cols));
+
+ if (!num_cols)
+ return OK;
+
+ old_attr = *ch & A_ATTRIBUTES;
+
+ for (i = 0, j = 0; j < num_cols; j++)
+ {
+ chtype curr = ch[j];
+
+ attr = curr & A_ATTRIBUTES;
+
+#ifdef CHTYPE_LONG
+ if (attr & A_ALTCHARSET && !(curr & 0xff80))
+ {
+ attr ^= A_ALTCHARSET;
+ curr = acs_map[curr & 0x7f];
+ }
+#endif
+
+#ifndef PDC_WIDE
+ /* Special handling for ACS_BLOCK */
+
+ if (!(curr & A_CHARTEXT))
+ {
+ curr |= ' ';
+ attr ^= A_REVERSE;
+ }
+#endif
+ if (attr != old_attr)
+ {
+ if (_new_packet(old_attr, highlight, i, col, row, text) == ERR)
+ return ERR;
+
+ old_attr = attr;
+ col += i;
+ i = 0;
+ }
+
+#ifdef PDC_WIDE
+ text[i].byte1 = (curr & 0xff00) >> 8;
+ text[i++].byte2 = curr & 0x00ff;
+#else
+ text[i++] = curr & 0xff;
+#endif
+ }
+
+ return _new_packet(old_attr, highlight, i, col, row, text);
+}
+
+static void _get_gc(GC *gc, XFontStruct *font_info, int fore, int back)
+{
+ XGCValues values;
+
+ /* Create default Graphics Context */
+
+ *gc = XCreateGC(XCURSESDISPLAY, XCURSESWIN, 0L, &values);
+
+ /* specify font */
+
+ XSetFont(XCURSESDISPLAY, *gc, font_info->fid);
+
+ XSetForeground(XCURSESDISPLAY, *gc, colors[fore]);
+ XSetBackground(XCURSESDISPLAY, *gc, colors[back]);
+}
+
+static void _initialize_colors(void)
+{
+ colors[COLOR_BLACK] = xc_app_data.colorBlack;
+ colors[COLOR_RED] = xc_app_data.colorRed;
+ colors[COLOR_GREEN] = xc_app_data.colorGreen;
+ colors[COLOR_YELLOW] = xc_app_data.colorYellow;
+ colors[COLOR_BLUE] = xc_app_data.colorBlue;
+ colors[COLOR_MAGENTA] = xc_app_data.colorMagenta;
+ colors[COLOR_CYAN] = xc_app_data.colorCyan;
+ colors[COLOR_WHITE] = xc_app_data.colorWhite;
+
+ colors[COLOR_BLACK + 8] = xc_app_data.colorBoldBlack;
+ colors[COLOR_RED + 8] = xc_app_data.colorBoldRed;
+ colors[COLOR_GREEN + 8] = xc_app_data.colorBoldGreen;
+ colors[COLOR_YELLOW + 8] = xc_app_data.colorBoldYellow;
+ colors[COLOR_BLUE + 8] = xc_app_data.colorBoldBlue;
+ colors[COLOR_MAGENTA + 8] = xc_app_data.colorBoldMagenta;
+ colors[COLOR_CYAN + 8] = xc_app_data.colorBoldCyan;
+ colors[COLOR_WHITE + 8] = xc_app_data.colorBoldWhite;
+
+ colors[COLOR_CURSOR] = xc_app_data.cursorColor;
+ colors[COLOR_BORDER] = xc_app_data.borderColor;
+}
+
+static void _refresh_scrollbar(void)
+{
+ XC_LOG(("_refresh_scrollbar() - called\n"));
+
+ if (SP->sb_on)
+ {
+ PDC_SCROLLBAR_TYPE total_y = SP->sb_total_y;
+ PDC_SCROLLBAR_TYPE total_x = SP->sb_total_x;
+
+ if (total_y)
+ XawScrollbarSetThumb(scrollVert,
+ (PDC_SCROLLBAR_TYPE)(SP->sb_cur_y) / total_y,
+ (PDC_SCROLLBAR_TYPE)(SP->sb_viewport_y) / total_y);
+
+ if (total_x)
+ XawScrollbarSetThumb(scrollHoriz,
+ (PDC_SCROLLBAR_TYPE)(SP->sb_cur_x) / total_x,
+ (PDC_SCROLLBAR_TYPE)(SP->sb_viewport_x) / total_x);
+ }
+}
+
+static void _set_cursor_color(chtype *ch, short *fore, short *back)
+{
+ int attr;
+ short f, b;
+
+ attr = PAIR_NUMBER(*ch);
+
+ if (attr)
+ {
+ PDC_pair_content(attr, &f, &b);
+ *fore = 7 - (f % 8);
+ *back = 7 - (b % 8);
+ }
+ else
+ {
+ if (*ch & A_REVERSE)
+ {
+ *back = COLOR_BLACK;
+ *fore = COLOR_WHITE;
+ }
+ else
+ {
+ *back = COLOR_WHITE;
+ *fore = COLOR_BLACK;
+ }
+ }
+}
+
+static void _get_icon(void)
+{
+ XIconSize *icon_size;
+ int size_count = 0;
+ Status rc;
+ unsigned char *bitmap_bits = NULL;
+ unsigned icon_bitmap_width = 0, icon_bitmap_height = 0,
+ file_bitmap_width = 0, file_bitmap_height = 0;
+
+ XC_LOG(("_get_icon() - called\n"));
+
+ icon_size = XAllocIconSize();
+
+ rc = XGetIconSizes(XtDisplay(topLevel),
+ RootWindowOfScreen(XtScreen(topLevel)),
+ &icon_size, &size_count);
+
+ /* if the WM can advise on icon sizes... */
+
+ if (rc && size_count)
+ {
+ int i, max_height = 0, max_width = 0;
+
+ PDC_LOG(("%s:size_count: %d rc: %d\n", XCLOGMSG, size_count, rc));
+
+ for (i = 0; i < size_count; i++)
+ {
+ if (icon_size[i].max_width > max_width)
+ max_width = icon_size[i].max_width;
+ if (icon_size[i].max_height > max_height)
+ max_height = icon_size[i].max_height;
+
+ PDC_LOG(("%s:min: %d %d\n", XCLOGMSG,
+ icon_size[i].min_width, icon_size[i].min_height));
+
+ PDC_LOG(("%s:max: %d %d\n", XCLOGMSG,
+ icon_size[i].max_width, icon_size[i].max_height));
+
+ PDC_LOG(("%s:inc: %d %d\n", XCLOGMSG,
+ icon_size[i].width_inc, icon_size[i].height_inc));
+ }
+
+ if (max_width >= big_icon_width && max_height >= big_icon_height)
+ {
+ icon_bitmap_width = big_icon_width;
+ icon_bitmap_height = big_icon_height;
+ bitmap_bits = (unsigned char *)big_icon_bits;
+ }
+ else
+ {
+ icon_bitmap_width = little_icon_width;
+ icon_bitmap_height = little_icon_height;
+ bitmap_bits = (unsigned char *)little_icon_bits;
+ }
+
+ }
+ else /* use small icon */
+ {
+ icon_bitmap_width = little_icon_width;
+ icon_bitmap_height = little_icon_height;
+ bitmap_bits = (unsigned char *)little_icon_bits;
+ }
+
+ XFree(icon_size);
+
+#ifdef HAVE_XPM_H
+ if (xc_app_data.pixmap && xc_app_data.pixmap[0]) /* supplied pixmap */
+ {
+ XpmReadFileToPixmap(XtDisplay(topLevel),
+ RootWindowOfScreen(XtScreen(topLevel)),
+ (char *)xc_app_data.pixmap,
+ &icon_pixmap, &icon_pixmap_mask, NULL);
+ return;
+ }
+#endif
+
+ if (xc_app_data.bitmap && xc_app_data.bitmap[0]) /* supplied bitmap */
+ {
+ int x_hot = 0, y_hot = 0;
+
+ rc = XReadBitmapFile(XtDisplay(topLevel),
+ RootWindowOfScreen(XtScreen(topLevel)),
+ (char *)xc_app_data.bitmap,
+ &file_bitmap_width, &file_bitmap_height,
+ &icon_bitmap, &x_hot, &y_hot);
+
+ switch(rc)
+ {
+ case BitmapOpenFailed:
+ fprintf(stderr, "bitmap file %s: not found\n",
+ xc_app_data.bitmap);
+ break;
+ case BitmapFileInvalid:
+ fprintf(stderr, "bitmap file %s: contents invalid\n",
+ xc_app_data.bitmap);
+ break;
+ default:
+ return;
+ }
+ }
+
+ icon_bitmap = XCreateBitmapFromData(XtDisplay(topLevel),
+ RootWindowOfScreen(XtScreen(topLevel)),
+ (char *)bitmap_bits, icon_bitmap_width, icon_bitmap_height);
+}
+
+static void _draw_border(void)
+{
+ /* Draw the border if required */
+
+ if (xc_app_data.borderWidth)
+ XDrawRectangle(XCURSESDISPLAY, XCURSESWIN, border_gc,
+ xc_app_data.borderWidth / 2,
+ xc_app_data.borderWidth / 2,
+ window_width - xc_app_data.borderWidth,
+ window_height - xc_app_data.borderWidth);
+}
+
+/* Redraw the entire screen */
+
+static void _display_screen(void)
+{
+ int row;
+
+ XC_LOG(("_display_screen() - called\n"));
+
+ for (row = 0; row < XCursesLINES; row++)
+ {
+ XC_get_line_lock(row);
+
+ _display_text((const chtype *)(Xcurscr + XCURSCR_Y_OFF(row)),
+ row, 0, COLS, FALSE);
+
+ XC_release_line_lock(row);
+ }
+
+ _redraw_cursor();
+ _draw_border();
+}
+
+/* Draw changed portions of the screen */
+
+static void _refresh_screen(void)
+{
+ int row, start_col, num_cols;
+
+ XC_LOG(("_refresh_screen() - called\n"));
+
+ for (row = 0; row < XCursesLINES; row++)
+ {
+ num_cols = (int)*(Xcurscr + XCURSCR_LENGTH_OFF + row);
+
+ if (num_cols)
+ {
+ XC_get_line_lock(row);
+
+ start_col = (int)*(Xcurscr + XCURSCR_START_OFF + row);
+
+ _display_text((const chtype *)(Xcurscr + XCURSCR_Y_OFF(row) +
+ (start_col * sizeof(chtype))), row, start_col,
+ num_cols, FALSE);
+
+ *(Xcurscr + XCURSCR_LENGTH_OFF + row) = 0;
+
+ XC_release_line_lock(row);
+ }
+ }
+
+ if (mouse_selection)
+ _selection_off();
+}
+
+static void _handle_expose(Widget w, XtPointer client_data, XEvent *event,
+ Boolean *unused)
+{
+ XC_LOG(("_handle_expose() - called\n"));
+
+ /* ignore all Exposes except last */
+
+ if (event->xexpose.count)
+ return;
+
+ if (after_first_curses_request && received_map_notify)
+ _display_screen();
+}
+
+static void _handle_nonmaskable(Widget w, XtPointer client_data, XEvent *event,
+ Boolean *unused)
+{
+ XClientMessageEvent *client_event = (XClientMessageEvent *)event;
+
+ PDC_LOG(("%s:_handle_nonmaskable called: xc_otherpid %d event %d\n",
+ XCLOGMSG, xc_otherpid, event->type));
+
+ if (event->type == ClientMessage)
+ {
+ XC_LOG(("ClientMessage received\n"));
+
+ /* This code used to include handling of WM_SAVE_YOURSELF, but
+ it resulted in continual failure of THE on my Toshiba laptop.
+ Removed on 3-3-2001. Now only exits on WM_DELETE_WINDOW. */
+
+ if ((Atom)client_event->data.s[0] == wm_atom[0])
+ _exit_process(0, SIGKILL, "");
+ }
+}
+
+static void XCursesKeyPress(Widget w, XEvent *event, String *params,
+ Cardinal *nparams)
+{
+ enum { STATE_NORMAL, STATE_COMPOSE, STATE_CHAR };
+
+#ifdef PDC_XIM
+ Status status;
+ wchar_t buffer[120];
+#else
+ unsigned char buffer[120];
+ XComposeStatus compose;
+ static int compose_state = STATE_NORMAL;
+ static int compose_index = 0;
+ int char_idx = 0;
+#endif
+ unsigned long key = 0;
+ int buflen = 40;
+ int i, count;
+ unsigned long modifier = 0;
+ bool key_code = FALSE;
+
+ XC_LOG(("XCursesKeyPress() - called\n"));
+
+ /* Handle modifier keys first; ignore other KeyReleases */
+
+ if (event->type == KeyRelease)
+ {
+ /* The keysym value was set by a previous call to this function
+ with a KeyPress event (or reset by the mouse event handler) */
+
+ if (SP->return_key_modifiers &&
+#ifndef PDC_XIM
+ keysym != compose_key &&
+#endif
+ IsModifierKey(keysym))
+ {
+ switch (keysym) {
+ case XK_Shift_L:
+ key = KEY_SHIFT_L;
+ break;
+ case XK_Shift_R:
+ key = KEY_SHIFT_R;
+ break;
+ case XK_Control_L:
+ key = KEY_CONTROL_L;
+ break;
+ case XK_Control_R:
+ key = KEY_CONTROL_R;
+ break;
+ case XK_Alt_L:
+ key = KEY_ALT_L;
+ break;
+ case XK_Alt_R:
+ key = KEY_ALT_R;
+ }
+
+ if (key)
+ _send_key_to_curses(key, NULL, TRUE);
+ }
+
+ return;
+ }
+
+ buffer[0] = '\0';
+
+#ifdef PDC_XIM
+ count = XwcLookupString(Xic, &(event->xkey), buffer, buflen,
+ &keysym, &status);
+#else
+ count = XLookupString(&(event->xkey), (char *)buffer, buflen,
+ &keysym, &compose);
+#endif
+
+ /* translate keysym into curses key code */
+
+ PDC_LOG(("%s:Key mask: %x\n", XCLOGMSG, event->xkey.state));
+
+#ifdef PDCDEBUG
+ for (i = 0; i < 4; i++)
+ PDC_debug("%s:Keysym %x %d\n", XCLOGMSG,
+ XKeycodeToKeysym(XCURSESDISPLAY, event->xkey.keycode, i), i);
+#endif
+
+#ifndef PDC_XIM
+
+ /* Check if the key just pressed is the user-specified compose
+ key; if it is, set the compose state and exit. */
+
+ if (keysym == compose_key)
+ {
+ chtype *ch;
+ int xpos, ypos, save_visibility = SP->visibility;
+ short fore = 0, back = 0;
+
+ /* Change the shape of the cursor to an outline rectangle to
+ indicate we are in "compose" status */
+
+ SP->visibility = 0;
+
+ _redraw_cursor();
+
+ SP->visibility = save_visibility;
+ _make_xy(SP->curscol, SP->cursrow, &xpos, &ypos);
+
+ ch = (chtype *)(Xcurscr + XCURSCR_Y_OFF(SP->cursrow) +
+ (SP->curscol * sizeof(chtype)));
+
+ _set_cursor_color(ch, &fore, &back);
+
+ XSetForeground(XCURSESDISPLAY, rect_cursor_gc, colors[back]);
+
+ XDrawRectangle(XCURSESDISPLAY, XCURSESWIN, rect_cursor_gc,
+ xpos + 1, ypos - font_height +
+ xc_app_data.normalFont->descent + 1,
+ font_width - 2, font_height - 2);
+
+ compose_state = STATE_COMPOSE;
+ return;
+ }
+
+ switch (compose_state)
+ {
+ case STATE_COMPOSE:
+ if (IsModifierKey(keysym))
+ return;
+
+ if (event->xkey.state & compose_mask)
+ {
+ compose_state = STATE_NORMAL;
+ _redraw_cursor();
+ break;
+ }
+
+ if (buffer[0] && count == 1)
+ key = buffer[0];
+
+ compose_index = -1;
+
+ for (i = 0; i < (int)strlen(compose_chars); i++)
+ if (compose_chars[i] == key)
+ {
+ compose_index = i;
+ break;
+ }
+
+ if (compose_index == -1)
+ {
+ compose_state = STATE_NORMAL;
+ compose_index = 0;
+ _redraw_cursor();
+ break;
+ }
+
+ compose_state = STATE_CHAR;
+ return;
+
+ case STATE_CHAR:
+ if (IsModifierKey(keysym))
+ return;
+
+ if (event->xkey.state & compose_mask)
+ {
+ compose_state = STATE_NORMAL;
+ _redraw_cursor();
+ break;
+ }
+
+ if (buffer[0] && count == 1)
+ key = buffer[0];
+
+ char_idx = -1;
+
+ for (i = 0; i < MAX_COMPOSE_CHARS; i++)
+ if (compose_lookups[compose_index][i] == key)
+ {
+ char_idx = i;
+ break;
+ }
+
+ if (char_idx == -1)
+ {
+ compose_state = STATE_NORMAL;
+ compose_index = 0;
+ _redraw_cursor();
+ break;
+ }
+
+ _send_key_to_curses(compose_keys[compose_index][char_idx],
+ NULL, FALSE);
+
+ compose_state = STATE_NORMAL;
+ compose_index = 0;
+
+ _redraw_cursor();
+
+ return;
+ }
+
+#endif /* PDC_XIM */
+
+ /* To get here we are procesing "normal" keys */
+
+ PDC_LOG(("%s:Keysym %x %d\n", XCLOGMSG,
+ XKeycodeToKeysym(XCURSESDISPLAY, event->xkey.keycode, key), key));
+
+ if (SP->save_key_modifiers)
+ {
+ /* 0x10: usually, numlock modifier */
+
+ if (event->xkey.state & Mod2Mask)
+ modifier |= PDC_KEY_MODIFIER_NUMLOCK;
+
+ /* 0x01: shift modifier */
+
+ if (event->xkey.state & ShiftMask)
+ modifier |= PDC_KEY_MODIFIER_SHIFT;
+
+ /* 0x04: control modifier */
+
+ if (event->xkey.state & ControlMask)
+ modifier |= PDC_KEY_MODIFIER_CONTROL;
+
+ /* 0x08: usually, alt modifier */
+
+ if (event->xkey.state & Mod1Mask)
+ modifier |= PDC_KEY_MODIFIER_ALT;
+ }
+
+ for (i = 0; key_table[i].keycode; i++)
+ {
+ if (key_table[i].keycode == keysym)
+ {
+ PDC_LOG(("%s:State %x\n", XCLOGMSG, event->xkey.state));
+
+ /* ControlMask: 0x04: control modifier
+ Mod1Mask: 0x08: usually, alt modifier
+ Mod2Mask: 0x10: usually, numlock modifier
+ ShiftMask: 0x01: shift modifier */
+
+ if ((event->xkey.state & ShiftMask) ||
+ (key_table[i].numkeypad &&
+ (event->xkey.state & Mod2Mask)))
+ {
+ key = key_table[i].shifted;
+ }
+ else if (event->xkey.state & ControlMask)
+ {
+ key = key_table[i].control;
+ }
+ else if (event->xkey.state & Mod1Mask)
+ {
+ key = key_table[i].alt;
+ }
+
+ /* To get here, we ignore all other modifiers */
+
+ else
+ key = key_table[i].normal;
+
+ key_code = (key > 0x100);
+ break;
+ }
+ }
+
+ if (!key && buffer[0] && count == 1)
+ key = buffer[0];
+
+ PDC_LOG(("%s:Key: %s pressed - %x Mod: %x\n", XCLOGMSG,
+ XKeysymToString(keysym), key, event->xkey.state));
+
+ /* Handle ALT letters and numbers */
+
+ if (event->xkey.state == Mod1Mask)
+ {
+ if (key >= 'A' && key <= 'Z')
+ {
+ key += ALT_A - 'A';
+ key_code = TRUE;
+ }
+
+ if (key >= 'a' && key <= 'z')
+ {
+ key += ALT_A - 'a';
+ key_code = TRUE;
+ }
+
+ if (key >= '0' && key <= '9')
+ {
+ key += ALT_0 - '0';
+ key_code = TRUE;
+ }
+ }
+
+ /* After all that, send the key back to the application if is
+ NOT zero. */
+
+ if (key)
+ {
+ key |= (modifier << 24);
+
+ _send_key_to_curses(key, NULL, key_code);
+ }
+}
+
+static void XCursesHandleString(Widget w, XEvent *event, String *params,
+ Cardinal *nparams)
+{
+ unsigned char *ptr;
+
+ if (*nparams != 1)
+ return;
+
+ ptr = (unsigned char *)*params;
+
+ if (ptr[0] == '0' && ptr[1] == 'x' && ptr[2] != '\0')
+ {
+ unsigned char c;
+ unsigned long total = 0;
+
+ for (ptr += 2; (c = tolower(*ptr)); ptr++)
+ {
+ total <<= 4;
+
+ if (c >= '0' && c <= '9')
+ total += c - '0';
+ else
+ if (c >= 'a' && c <= 'f')
+ total += c - ('a' - 10);
+ else
+ break;
+ }
+
+ if (c == '\0')
+ _send_key_to_curses(total, NULL, FALSE);
+ }
+ else
+ for (; *ptr; ptr++)
+ _send_key_to_curses((unsigned long)*ptr, NULL, FALSE);
+}
+
+static void _paste_string(Widget w, XtPointer data, Atom *selection, Atom *type,
+ XtPointer value, unsigned long *length, int *format)
+{
+ unsigned long i, key;
+ unsigned char *string = value;
+
+ XC_LOG(("_paste_string() - called\n"));
+
+ if (!*type || !*length || !string)
+ return;
+
+ for (i = 0; string[i] && (i < (*length)); i++)
+ {
+ key = string[i];
+
+ if (key == 10) /* new line - convert to ^M */
+ key = 13;
+
+ _send_key_to_curses(key, NULL, FALSE);
+ }
+
+ XtFree(value);
+}
+
+static void _paste_utf8(Widget w, XtPointer event, Atom *selection, Atom *type,
+ XtPointer value, unsigned long *length, int *format)
+{
+ wchar_t key;
+ size_t i = 0, len;
+ char *string = value;
+
+ XC_LOG(("_paste_utf8() - called\n"));
+
+ if (!*type || !*length)
+ {
+ XtGetSelectionValue(w, XA_PRIMARY, XA_STRING, _paste_string,
+ event, ((XButtonEvent *)event)->time);
+ return;
+ }
+
+ len = *length;
+
+ if (!string)
+ return;
+
+ while (string[i] && (i < len))
+ {
+ int retval = _from_utf8(&key, string + i, len - i);
+
+ if (retval < 1)
+ return;
+
+ if (key == 10) /* new line - convert to ^M */
+ key = 13;
+
+ _send_key_to_curses(key, NULL, FALSE);
+
+ i += retval;
+ }
+
+ XtFree(value);
+}
+
+static void XCursesPasteSelection(Widget w, XButtonEvent *button_event)
+{
+ XC_LOG(("XCursesPasteSelection() - called\n"));
+
+ XtGetSelectionValue(w, XA_PRIMARY, XA_UTF8_STRING(XtDisplay(w)),
+ _paste_utf8, (XtPointer)button_event,
+ button_event->time);
+}
+
+static Boolean _convert_proc(Widget w, Atom *selection, Atom *target,
+ Atom *type_return, XtPointer *value_return,
+ unsigned long *length_return, int *format_return)
+{
+ XC_LOG(("_convert_proc() - called\n"));
+
+ if (*target == XA_TARGETS(XtDisplay(topLevel)))
+ {
+ XSelectionRequestEvent *req = XtGetSelectionRequest(w,
+ *selection, (XtRequestId)NULL);
+
+ Atom *targetP;
+ XPointer std_targets;
+ unsigned long std_length;
+
+ XmuConvertStandardSelection(topLevel, req->time, selection,
+ target, type_return, &std_targets,
+ &std_length, format_return);
+
+ *length_return = std_length + 2;
+ *value_return = XtMalloc(sizeof(Atom) * (*length_return));
+
+ targetP = *(Atom**)value_return;
+ *targetP++ = XA_STRING;
+ *targetP++ = XA_UTF8_STRING(XtDisplay(topLevel));
+
+ memmove((void *)targetP, (const void *)std_targets,
+ sizeof(Atom) * std_length);
+
+ XtFree((char *)std_targets);
+ *type_return = XA_ATOM;
+ *format_return = sizeof(Atom) * 8;
+
+ return True;
+ }
+ else if (*target == XA_UTF8_STRING(XtDisplay(topLevel)) ||
+ *target == XA_STRING)
+ {
+ bool utf8 = !(*target == XA_STRING);
+ char *data = XtMalloc(tmpsel_length * 3 + 1);
+ chtype *tmp = tmpsel;
+ int ret_length = 0;
+
+ if (utf8)
+ {
+ while (*tmp)
+ ret_length += _to_utf8(data + ret_length, *tmp++);
+ }
+ else
+ while (*tmp)
+ data[ret_length++] = *tmp++ & 0xff;
+
+ data[ret_length++] = '\0';
+
+ *value_return = data;
+ *length_return = ret_length;
+ *format_return = 8;
+ *type_return = *target;
+
+ return True;
+ }
+ else
+ return XmuConvertStandardSelection(topLevel, CurrentTime,
+ selection, target, type_return, (XPointer*)value_return,
+ length_return, format_return);
+}
+
+static void _lose_ownership(Widget w, Atom *type)
+{
+ XC_LOG(("_lose_ownership() - called\n"));
+
+ if (tmpsel)
+ free(tmpsel);
+
+ tmpsel = NULL;
+ tmpsel_length = 0;
+ _selection_off();
+}
+
+static void _show_selection(int start_x, int start_y, int end_x, int end_y,
+ bool highlight)
+{
+ int i, num_cols, start_col, row;
+
+ PDC_LOG(("%s:_show_selection() - called StartX: %d StartY: %d "
+ "EndX: %d EndY: %d Highlight: %d\n", XCLOGMSG,
+ start_x, start_y, end_x, end_y, highlight));
+
+ for (i = 0; i < end_y - start_y + 1; i++)
+ {
+ if (start_y == end_y) /* only one line */
+ {
+ start_col = start_x;
+ num_cols = end_x - start_x + 1;
+ row = start_y;
+ }
+ else if (!i) /* first line */
+ {
+ start_col = start_x;
+ num_cols = COLS - start_x;
+ row = start_y;
+ }
+ else if (start_y + i == end_y) /* last line */
+ {
+ start_col = 0;
+ num_cols = end_x + 1;
+ row = end_y;
+ }
+ else /* full line */
+ {
+ start_col = 0;
+ num_cols = COLS;
+ row = start_y + i;
+ }
+
+ XC_get_line_lock(row);
+
+ _display_text((const chtype *)(Xcurscr + XCURSCR_Y_OFF(row) +
+ (start_col * sizeof(chtype))), row, start_col,
+ num_cols, highlight);
+
+ XC_release_line_lock(row);
+ }
+}
+
+static void _selection_off(void)
+{
+ XC_LOG(("_selection_off() - called\n"));
+
+ _display_screen();
+
+ selection_start_x = selection_start_y = selection_end_x =
+ selection_end_y = 0;
+
+ mouse_selection = FALSE;
+}
+
+static void _selection_on(int x, int y)
+{
+ XC_LOG(("_selection_on() - called\n"));
+
+ selection_start_x = selection_end_x = x;
+ selection_start_y = selection_end_y = y;
+}
+
+static void _selection_extend(int x, int y)
+{
+ int temp, current_start, current_end, current_start_x,
+ current_end_x, current_start_y, current_end_y, new_start,
+ new_end, new_start_x, new_end_x, new_start_y, new_end_y;
+
+ XC_LOG(("_selection_extend() - called\n"));
+
+ mouse_selection = TRUE;
+
+ /* convert x/y coordinates into start/stop */
+
+ current_start = (selection_start_y * COLS) + selection_start_x;
+ current_end = (selection_end_y * COLS) + selection_end_x;
+
+ if (current_start > current_end)
+ {
+ current_start_x = selection_end_x;
+ current_start_y = selection_end_y;
+ current_end_x = selection_start_x;
+ current_end_y = selection_start_y;
+ temp = current_start;
+ current_start = current_end;
+ current_end = temp;
+ }
+ else
+ {
+ current_end_x = selection_end_x;
+ current_end_y = selection_end_y;
+ current_start_x = selection_start_x;
+ current_start_y = selection_start_y;
+ }
+
+ /* Now we have the current selection as a linear expression.
+ Convert the new position to a linear expression. */
+
+ selection_end_x = x;
+ selection_end_y = y;
+
+ /* convert x/y coordinates into start/stop */
+
+ new_start = (selection_start_y * COLS) + selection_start_x;
+ new_end = (selection_end_y * COLS) + selection_end_x;
+
+ if (new_start > new_end)
+ {
+ new_start_x = selection_end_x;
+ new_start_y = selection_end_y;
+ new_end_x = selection_start_x;
+ new_end_y = selection_start_y;
+ temp = new_start;
+ new_start = new_end;
+ new_end = temp;
+ }
+ else
+ {
+ new_end_x = selection_end_x;
+ new_end_y = selection_end_y;
+ new_start_x = selection_start_x;
+ new_start_y = selection_start_y;
+ }
+
+ if (new_end > current_end)
+ _show_selection(current_end_x, current_end_y, new_end_x,
+ new_end_y, TRUE);
+ else if (new_end < current_end)
+ _show_selection(new_end_x, new_end_y, current_end_x,
+ current_end_y, FALSE);
+ else if (new_start < current_start)
+ _show_selection(new_start_x, new_start_y, current_start_x,
+ current_start_y, TRUE);
+ else if (new_start > current_start)
+ _show_selection(current_start_x, current_start_y,
+ new_start_x, new_start_y, FALSE);
+ else
+ _show_selection(current_start_x, current_start_y,
+ new_start_x, new_start_y, TRUE);
+}
+
+static void _selection_set(void)
+{
+ int i, j, start, end, start_x, end_x, start_y, end_y, num_cols,
+ start_col, row, num_chars, ch, last_nonblank, length, newlen;
+ chtype *ptr = NULL;
+
+ XC_LOG(("_selection_set() - called\n"));
+
+ /* convert x/y coordinates into start/stop */
+
+ start = (selection_start_y * COLS) + selection_start_x;
+ end = (selection_end_y * COLS) + selection_end_x;
+
+ if (start == end)
+ {
+ if (tmpsel)
+ free(tmpsel);
+
+ tmpsel = NULL;
+ tmpsel_length = 0;
+
+ return;
+ }
+
+ if (start > end)
+ {
+ start_x = selection_end_x;
+ start_y = selection_end_y;
+ end_x = selection_start_x;
+ end_y = selection_start_y;
+ length = start - end + 1;
+ }
+ else
+ {
+ end_x = selection_end_x;
+ end_y = selection_end_y;
+ start_x = selection_start_x;
+ start_y = selection_start_y;
+ length = end - start + 1;
+ }
+
+ newlen = length + end_y - start_y + 2;
+
+ if (length > (int)tmpsel_length)
+ {
+ if (!tmpsel_length)
+ tmpsel = malloc(newlen * sizeof(chtype));
+ else
+ tmpsel = realloc(tmpsel, newlen * sizeof(chtype));
+ }
+
+ if (!tmpsel)
+ {
+ tmpsel_length = 0;
+ return;
+ }
+
+ tmpsel_length = length;
+ num_chars = 0;
+
+ for (i = 0; i < end_y - start_y + 1; i++)
+ {
+
+ if (start_y == end_y) /* only one line */
+ {
+ start_col = start_x;
+ num_cols = end_x - start_x + 1;
+ row = start_y;
+ }
+ else if (!i) /* first line */
+ {
+ start_col = start_x;
+ num_cols = COLS - start_x;
+ row = start_y;
+ }
+ else if (start_y + i == end_y) /* last line */
+ {
+ start_col = 0;
+ num_cols = end_x + 1;
+ row = end_y;
+ }
+ else /* full line */
+ {
+ start_col = 0;
+ num_cols = COLS;
+ row = start_y + i;
+ }
+
+ XC_get_line_lock(row);
+
+ ptr = (chtype *)(Xcurscr + XCURSCR_Y_OFF(row) +
+ start_col * sizeof(chtype));
+
+ if (i < end_y - start_y)
+ {
+ last_nonblank = 0;
+
+ for (j = 0; j < num_cols; j++)
+ {
+ ch = (int)(ptr[j] & A_CHARTEXT);
+ if (ch != (int)' ')
+ last_nonblank = j;
+ }
+ }
+ else
+ last_nonblank = num_cols - 1;
+
+ for (j = 0; j <= last_nonblank; j++)
+ tmpsel[num_chars++] = ptr[j];
+
+ XC_release_line_lock(row);
+
+ if (i < end_y - start_y)
+ tmpsel[num_chars++] = '\n';
+ }
+
+ tmpsel[num_chars] = '\0';
+ tmpsel_length = num_chars;
+}
+
+static void _display_cursor(int old_row, int old_x, int new_row, int new_x)
+{
+ int xpos, ypos, i;
+ chtype *ch;
+ short fore = 0, back = 0;
+
+ PDC_LOG(("%s:_display_cursor() - draw char at row: %d col %d\n",
+ XCLOGMSG, old_row, old_x));
+
+ /* if the cursor position is outside the boundary of the screen,
+ ignore the request */
+
+ if (old_row >= XCursesLINES || old_x >= COLS ||
+ new_row >= XCursesLINES || new_x >= COLS)
+ return;
+
+ /* display the character at the current cursor position */
+
+ PDC_LOG(("%s:_display_cursor() - draw char at row: %d col %d\n",
+ XCLOGMSG, old_row, old_x));
+
+ _display_text((const chtype *)(Xcurscr + (XCURSCR_Y_OFF(old_row) +
+ (old_x * sizeof(chtype)))), old_row, old_x, 1, FALSE);
+
+ /* display the cursor at the new cursor position */
+
+ if (!SP->visibility)
+ return; /* cursor not displayed, no more to do */
+
+ _make_xy(new_x, new_row, &xpos, &ypos);
+
+ ch = (chtype *)(Xcurscr + XCURSCR_Y_OFF(new_row) + new_x * sizeof(chtype));
+
+ _set_cursor_color(ch, &fore, &back);
+
+ if (vertical_cursor)
+ {
+ XSetForeground(XCURSESDISPLAY, rect_cursor_gc, colors[back]);
+
+ for (i = 1; i <= SP->visibility; i++)
+ XDrawLine(XCURSESDISPLAY, XCURSESWIN, rect_cursor_gc,
+ xpos + i, ypos - xc_app_data.normalFont->ascent,
+ xpos + i, ypos - xc_app_data.normalFont->ascent +
+ font_height - 1);
+ }
+ else
+ {
+ if (SP->visibility == 1)
+ {
+ /* cursor visibility normal */
+
+ XSetForeground(XCURSESDISPLAY, rect_cursor_gc, colors[back]);
+
+ for (i = 0; i < xc_app_data.normalFont->descent + 2; i++)
+ XDrawLine(XCURSESDISPLAY, XCURSESWIN, rect_cursor_gc,
+ xpos, ypos - 2 + i, xpos + font_width, ypos - 2 + i);
+ }
+ else
+ {
+ /* cursor visibility high */
+#ifdef PDC_WIDE
+ XChar2b buf[2];
+
+ buf[0].byte1 = (*ch & 0xff00) >> 8;
+ buf[0].byte2 = *ch & 0x00ff;
+
+ buf[1].byte1 = buf[1].byte2 = 0;
+#else
+ char buf[2];
+
+ buf[0] = *ch & 0xff;
+ buf[1] = '\0';
+#endif
+ XSetForeground(XCURSESDISPLAY, block_cursor_gc, colors[fore]);
+ XSetBackground(XCURSESDISPLAY, block_cursor_gc, colors[back]);
+#ifdef PDC_WIDE
+ XDrawImageString16(
+#else
+ XDrawImageString(
+#endif
+ XCURSESDISPLAY, XCURSESWIN, block_cursor_gc,
+ xpos, ypos, buf, 1);
+ }
+ }
+
+ PDC_LOG(("%s:_display_cursor() - draw cursor at row %d col %d\n",
+ XCLOGMSG, new_row, new_x));
+}
+
+static void _redraw_cursor(void)
+{
+ _display_cursor(SP->cursrow, SP->curscol, SP->cursrow, SP->curscol);
+}
+
+static void _handle_enter_leave(Widget w, XtPointer client_data,
+ XEvent *event, Boolean *unused)
+{
+ XC_LOG(("_handle_enter_leave called\n"));
+
+ switch(event->type)
+ {
+ case EnterNotify:
+ XC_LOG(("EnterNotify received\n"));
+
+ window_entered = TRUE;
+ break;
+
+ case LeaveNotify:
+ XC_LOG(("LeaveNotify received\n"));
+
+ window_entered = FALSE;
+
+ /* Display the cursor so it stays on while the window is
+ not current */
+
+ _redraw_cursor();
+ break;
+
+ default:
+ PDC_LOG(("%s:_handle_enter_leave - unknown event %d\n",
+ XCLOGMSG, event->type));
+ }
+}
+
+static void _send_key_to_curses(unsigned long key, MOUSE_STATUS *ms,
+ bool key_code)
+{
+ PDC_LOG(("%s:_send_key_to_curses() - called: sending %d\n",
+ XCLOGMSG, key));
+
+ SP->key_code = key_code;
+
+ if (XC_write_socket(xc_key_sock, &key, sizeof(unsigned long)) < 0)
+ _exit_process(1, SIGKILL, "exiting from _send_key_to_curses");
+
+ if (ms)
+ {
+ MOUSE_LOG(("%s:writing mouse stuff\n", XCLOGMSG));
+
+ if (XC_write_socket(xc_key_sock, ms, sizeof(MOUSE_STATUS)) < 0)
+ _exit_process(1, SIGKILL, "exiting from _send_key_to_curses");
+ }
+}
+
+static void _blink_cursor(XtPointer unused, XtIntervalId *id)
+{
+ XC_LOG(("_blink_cursor() - called:\n"));
+
+ if (window_entered)
+ {
+ if (visible_cursor)
+ {
+ /* Cursor currently ON, turn it off */
+
+ int save_visibility = SP->visibility;
+ SP->visibility = 0;
+ _redraw_cursor();
+ SP->visibility = save_visibility;
+ visible_cursor = FALSE;
+ }
+ else
+ {
+ /* Cursor currently OFF, turn it on */
+
+ _redraw_cursor();
+ visible_cursor = TRUE;
+ }
+ }
+
+ XtAppAddTimeOut(app_context, xc_app_data.cursorBlinkRate,
+ _blink_cursor, NULL);
+}
+
+static void XCursesButton(Widget w, XEvent *event, String *params,
+ Cardinal *nparams)
+{
+ int button_no;
+ static int last_button_no = 0;
+ static Time last_button_press_time = 0;
+ MOUSE_STATUS save_mouse_status;
+ bool send_key = TRUE;
+ static bool remove_release;
+ static bool handle_real_release;
+
+ XC_LOG(("XCursesButton() - called\n"));
+
+ keysym = 0; /* suppress any modifier key return */
+
+ save_mouse_status = Mouse_status;
+ button_no = event->xbutton.button;
+
+ /* It appears that under X11R6 (at least on Linux), that an
+ event_type of ButtonMotion does not include the mouse button in
+ the event. The following code is designed to cater for this
+ situation. */
+
+ if (!button_no)
+ button_no = last_button_no;
+
+ last_button_no = button_no;
+
+ Mouse_status.changes = 0;
+
+ switch(event->type)
+ {
+ case ButtonPress:
+ /* Handle button 4 and 5, which are normally mapped to the wheel
+ mouse scroll up and down */
+
+ if (button_no == 4 || button_no == 5)
+ {
+ /* Send the KEY_MOUSE to curses program */
+
+ memset(&Mouse_status, 0, sizeof(Mouse_status));
+
+ Mouse_status.changes = (button_no == 5) ?
+ PDC_MOUSE_WHEEL_DOWN : PDC_MOUSE_WHEEL_UP;
+
+ MOUSE_X_POS = MOUSE_Y_POS = -1;
+ _send_key_to_curses(KEY_MOUSE, &Mouse_status, TRUE);
+ remove_release = TRUE;
+
+ return;
+ }
+
+ if (button_no == 2 &&
+ (!SP->_trap_mbe || (event->xbutton.state & ShiftMask)))
+ {
+ XCursesPasteSelection(drawing, (XButtonEvent *)event);
+ remove_release = TRUE;
+
+ return;
+ }
+
+ remove_release = False;
+ handle_real_release = False;
+
+ MOUSE_LOG(("\nButtonPress\n"));
+
+ if ((event->xbutton.time - last_button_press_time) <
+ xc_app_data.doubleClickPeriod)
+ {
+ MOUSE_X_POS = save_mouse_status.x;
+ MOUSE_Y_POS = save_mouse_status.y;
+ BUTTON_STATUS(button_no) = BUTTON_DOUBLE_CLICKED;
+
+ _selection_off();
+ remove_release = True;
+ }
+ else
+ {
+ napms(SP->mouse_wait);
+ event->type = ButtonRelease;
+ XSendEvent(event->xbutton.display, event->xbutton.window,
+ True, 0, event);
+ last_button_press_time = event->xbutton.time;
+
+ return;
+ }
+
+ last_button_press_time = event->xbutton.time;
+ break;
+
+ case MotionNotify:
+ MOUSE_LOG(("\nMotionNotify: y: %d x: %d Width: %d "
+ "Height: %d\n", event->xbutton.y, event->xbutton.x,
+ font_width, font_height));
+
+ MOUSE_X_POS = (event->xbutton.x - xc_app_data.borderWidth) /
+ font_width;
+ MOUSE_Y_POS = (event->xbutton.y - xc_app_data.borderWidth) /
+ font_height;
+
+ if (button_no == 1 &&
+ (!SP->_trap_mbe || (event->xbutton.state & ShiftMask)))
+ {
+ _selection_extend(MOUSE_X_POS, MOUSE_Y_POS);
+ send_key = FALSE;
+ }
+ else
+ _selection_off();
+
+ /* Throw away mouse movements if they are in the same character
+ position as the last mouse event, or if we are currently in
+ the middle of a double click event. */
+
+ if ((MOUSE_X_POS == save_mouse_status.x &&
+ MOUSE_Y_POS == save_mouse_status.y) ||
+ save_mouse_status.button[button_no - 1] == BUTTON_DOUBLE_CLICKED)
+ {
+ send_key = FALSE;
+ break;
+ }
+
+ Mouse_status.changes |= PDC_MOUSE_MOVED;
+ break;
+
+ case ButtonRelease:
+ if (remove_release)
+ {
+ MOUSE_LOG(("Release at: %ld - removed\n", event->xbutton.time));
+ return;
+ }
+ else
+ {
+ MOUSE_X_POS = (event->xbutton.x - xc_app_data.borderWidth) /
+ font_width;
+ MOUSE_Y_POS = (event->xbutton.y - xc_app_data.borderWidth) /
+ font_height;
+
+ if (!handle_real_release)
+ {
+ if ((event->xbutton.time - last_button_press_time) <
+ SP->mouse_wait &&
+ (event->xbutton.time != last_button_press_time))
+ {
+ /* The "real" release was shorter than usleep() time;
+ therefore generate a click event */
+
+ MOUSE_LOG(("Release at: %ld - click\n",
+ event->xbutton.time));
+
+ BUTTON_STATUS(button_no) = BUTTON_CLICKED;
+
+ if (button_no == 1 && mouse_selection &&
+ (!SP->_trap_mbe || (event->xbutton.state & ShiftMask)))
+ {
+ send_key = FALSE;
+
+ if (XtOwnSelection(topLevel, XA_PRIMARY,
+ event->xbutton.time, _convert_proc,
+ _lose_ownership, NULL) == False)
+ _selection_off();
+ }
+ else
+ _selection_off();
+
+ /* Ensure the "pseudo" release event is ignored */
+
+ remove_release = True;
+ handle_real_release = False;
+ break;
+ }
+ else
+ {
+ /* Button release longer than usleep() time;
+ therefore generate a press and wait for the real
+ release to occur later. */
+
+ MOUSE_LOG(("Generated Release at: %ld - "
+ "press & release\n", event->xbutton.time));
+
+ BUTTON_STATUS(button_no) = BUTTON_PRESSED;
+
+ if (button_no == 1 &&
+ (!SP->_trap_mbe || (event->xbutton.state & ShiftMask)))
+ {
+ _selection_off();
+ _selection_on(MOUSE_X_POS, MOUSE_Y_POS);
+ }
+
+ handle_real_release = True;
+ break;
+ }
+ }
+ else
+ {
+ MOUSE_LOG(("Release at: %ld - released\n",
+ event->xbutton.time));
+ }
+ }
+
+ MOUSE_LOG(("\nButtonRelease\n"));
+
+ BUTTON_STATUS(button_no) = BUTTON_RELEASED;
+
+ if (button_no == 1 && mouse_selection &&
+ (!SP->_trap_mbe || (event->xbutton.state & ShiftMask)))
+ {
+ send_key = FALSE;
+
+ if (XtOwnSelection(topLevel, XA_PRIMARY,
+ event->xbutton.time, _convert_proc,
+ _lose_ownership, NULL) == False)
+ _selection_off();
+
+ _selection_set();
+ }
+ else
+ _selection_off();
+
+ break;
+ }
+
+ /* Set up the mouse status fields in preparation for sending */
+
+ Mouse_status.changes |= 1 << (button_no - 1);
+
+ if (Mouse_status.changes & PDC_MOUSE_MOVED &&
+ BUTTON_STATUS(button_no) == BUTTON_PRESSED)
+ BUTTON_STATUS(button_no) = BUTTON_MOVED;
+
+ if (event->xbutton.state & ShiftMask)
+ BUTTON_STATUS(button_no) |= BUTTON_SHIFT;
+ if (event->xbutton.state & ControlMask)
+ BUTTON_STATUS(button_no) |= BUTTON_CONTROL;
+ if (event->xbutton.state & Mod1Mask)
+ BUTTON_STATUS(button_no) |= BUTTON_ALT;
+
+ /* If we are ignoring the event, or the mouse position is outside
+ the bounds of the screen (because of the border), return here */
+
+ MOUSE_LOG(("Button: %d x: %d y: %d Button status: %x "
+ "Mouse status: %x\n", button_no, MOUSE_X_POS, MOUSE_Y_POS,
+ BUTTON_STATUS(button_no), Mouse_status.changes));
+
+ MOUSE_LOG(("Send: %d Button1: %x Button2: %x Button3: %x %d %d\n",
+ send_key, BUTTON_STATUS(1), BUTTON_STATUS(2),
+ BUTTON_STATUS(3), XCursesLINES, XCursesCOLS));
+
+ if (!send_key || MOUSE_X_POS < 0 || MOUSE_X_POS >= XCursesCOLS ||
+ MOUSE_Y_POS < 0 || MOUSE_Y_POS >= XCursesLINES)
+ return;
+
+ /* Send the KEY_MOUSE to curses program */
+
+ _send_key_to_curses(KEY_MOUSE, &Mouse_status, TRUE);
+}
+
+static void _scroll_up_down(Widget w, XtPointer client_data,
+ XtPointer call_data)
+{
+ int pixels = (long) call_data;
+ int total_y = SP->sb_total_y * font_height;
+ int viewport_y = SP->sb_viewport_y * font_height;
+ int cur_y = SP->sb_cur_y * font_height;
+
+ /* When pixels is negative, right button pressed, move data down,
+ thumb moves up. Otherwise, left button pressed, pixels positive,
+ move data up, thumb down. */
+
+ cur_y += pixels;
+
+ /* limit panning to size of overall */
+
+ if (cur_y < 0)
+ cur_y = 0;
+ else
+ if (cur_y > (total_y - viewport_y))
+ cur_y = total_y - viewport_y;
+
+ SP->sb_cur_y = cur_y / font_height;
+
+ XawScrollbarSetThumb(w, (double)((double)cur_y / (double)total_y),
+ (double)((double)viewport_y / (double)total_y));
+
+ /* Send a key: if pixels negative, send KEY_SCROLL_DOWN */
+
+ _send_key_to_curses(KEY_SF, NULL, TRUE);
+}
+
+static void _scroll_left_right(Widget w, XtPointer client_data,
+ XtPointer call_data)
+{
+ int pixels = (long) call_data;
+ int total_x = SP->sb_total_x * font_width;
+ int viewport_x = SP->sb_viewport_x * font_width;
+ int cur_x = SP->sb_cur_x * font_width;
+
+ cur_x += pixels;
+
+ /* limit panning to size of overall */
+
+ if (cur_x < 0)
+ cur_x = 0;
+ else
+ if (cur_x > (total_x - viewport_x))
+ cur_x = total_x - viewport_x;
+
+ SP->sb_cur_x = cur_x / font_width;
+
+ XawScrollbarSetThumb(w, (double)((double)cur_x / (double)total_x),
+ (double)((double)viewport_x / (double)total_x));
+
+ _send_key_to_curses(KEY_SR, NULL, TRUE);
+}
+
+static void _thumb_up_down(Widget w, XtPointer client_data,
+ XtPointer call_data)
+{
+ double percent = *(double *) call_data;
+ double total_y = (double)SP->sb_total_y;
+ double viewport_y = (double)SP->sb_viewport_y;
+ int cur_y = SP->sb_cur_y;
+
+ /* If the size of the viewport is > overall area simply return,
+ as no scrolling is permitted. */
+
+ if (SP->sb_viewport_y >= SP->sb_total_y)
+ return;
+
+ if ((SP->sb_cur_y = (int)((double)total_y * percent)) >=
+ (total_y - viewport_y))
+ SP->sb_cur_y = total_y - viewport_y;
+
+ XawScrollbarSetThumb(w, (double)(cur_y / total_y),
+ (double)(viewport_y / total_y));
+
+ _send_key_to_curses(KEY_SF, NULL, TRUE);
+}
+
+static void _thumb_left_right(Widget w, XtPointer client_data,
+ XtPointer call_data)
+{
+ double percent = *(double *) call_data;
+ double total_x = (double)SP->sb_total_x;
+ double viewport_x = (double)SP->sb_viewport_x;
+ int cur_x = SP->sb_cur_x;
+
+ if (SP->sb_viewport_x >= SP->sb_total_x)
+ return;
+
+ if ((SP->sb_cur_x = (int)((float)total_x * percent)) >=
+ (total_x - viewport_x))
+ SP->sb_cur_x = total_x - viewport_x;
+
+ XawScrollbarSetThumb(w, (double)(cur_x / total_x),
+ (double)(viewport_x / total_x));
+
+ _send_key_to_curses(KEY_SR, NULL, TRUE);
+}
+
+static void _exit_process(int rc, int sig, char *msg)
+{
+ if (rc || sig)
+ fprintf(stderr, "%s:_exit_process() - called: rc:%d sig:%d <%s>\n",
+ XCLOGMSG, rc, sig, msg);
+
+ shmdt((char *)SP);
+ shmdt((char *)Xcurscr);
+ shmctl(shmidSP, IPC_RMID, 0);
+ shmctl(shmid_Xcurscr, IPC_RMID, 0);
+
+ if (bitmap_file)
+ {
+ XFreePixmap(XCURSESDISPLAY, icon_bitmap);
+ free(bitmap_file);
+ }
+
+#ifdef HAVE_XPM_H
+ if (pixmap_file)
+ {
+ XFreePixmap(XCURSESDISPLAY, icon_pixmap);
+ XFreePixmap(XCURSESDISPLAY, icon_pixmap_mask);
+ free(pixmap_file);
+ }
+#endif
+ XFreeGC(XCURSESDISPLAY, normal_gc);
+ XFreeGC(XCURSESDISPLAY, italic_gc);
+ XFreeGC(XCURSESDISPLAY, block_cursor_gc);
+ XFreeGC(XCURSESDISPLAY, rect_cursor_gc);
+ XFreeGC(XCURSESDISPLAY, border_gc);
+#ifdef PDC_XIM
+ XDestroyIC(Xic);
+#endif
+
+ shutdown(xc_display_sock, 2);
+ close(xc_display_sock);
+
+ shutdown(xc_exit_sock, 2);
+ close(xc_exit_sock);
+
+ shutdown(xc_key_sock, 2);
+ close(xc_key_sock);
+
+ if (sig)
+ kill(xc_otherpid, sig); /* to kill parent process */
+
+ _exit(rc);
+}
+
+static void _resize(void)
+{
+ short save_atrtab[PDC_COLOR_PAIRS * 2];
+
+ after_first_curses_request = FALSE;
+
+ SP->lines = XCursesLINES = ((resize_window_height -
+ (2 * xc_app_data.borderWidth)) / font_height);
+
+ LINES = XCursesLINES - SP->linesrippedoff - SP->slklines;
+
+ SP->cols = COLS = XCursesCOLS = ((resize_window_width -
+ (2 * xc_app_data.borderWidth)) / font_width);
+
+ window_width = resize_window_width;
+ window_height = resize_window_height;
+ visible_cursor = TRUE;
+
+ _draw_border();
+
+ /* Detach and drop the current shared memory segment and create and
+ attach to a new segment */
+
+ memcpy(save_atrtab, xc_atrtab, sizeof(save_atrtab));
+
+ SP->XcurscrSize = XCURSCR_SIZE;
+ shmdt((char *)Xcurscr);
+ shmctl(shmid_Xcurscr, IPC_RMID, 0);
+
+ if ((shmid_Xcurscr = shmget(shmkey_Xcurscr,
+ SP->XcurscrSize + XCURSESSHMMIN, 0700 | IPC_CREAT)) < 0)
+ {
+ perror("Cannot allocate shared memory for curscr");
+
+ _exit_process(4, SIGKILL, "exiting from _process_curses_requests");
+ }
+
+ Xcurscr = (unsigned char*)shmat(shmid_Xcurscr, 0, 0);
+ memset(Xcurscr, 0, SP->XcurscrSize);
+ xc_atrtab = (short *)(Xcurscr + XCURSCR_ATRTAB_OFF);
+ memcpy(xc_atrtab, save_atrtab, sizeof(save_atrtab));
+}
+
+/* For PDC_set_title() */
+
+static void _set_title(void)
+{
+ char title[1024]; /* big enough for window title */
+ int pos;
+
+ if ((XC_read_socket(xc_display_sock, &pos, sizeof(int)) < 0) ||
+ (XC_read_socket(xc_display_sock, title, pos) < 0))
+ {
+ _exit_process(5, SIGKILL, "exiting from _set_title");
+ }
+
+ XtVaSetValues(topLevel, XtNtitle, title, NULL);
+}
+
+/* For color_content() */
+
+static void _get_color(void)
+{
+ XColor *tmp = (XColor *)(Xcurscr + XCURSCR_XCOLOR_OFF);
+ int index = tmp->pixel;
+ Colormap cmap = DefaultColormap(XCURSESDISPLAY,
+ DefaultScreen(XCURSESDISPLAY));
+
+ if (index < 0 || index >= MAX_COLORS)
+ _exit_process(4, SIGKILL, "exiting from _get_color");
+
+ tmp->pixel = colors[index];
+ XQueryColor(XCURSESDISPLAY, cmap, tmp);
+}
+
+/* For init_color() */
+
+static void _set_color(void)
+{
+ XColor *tmp = (XColor *)(Xcurscr + XCURSCR_XCOLOR_OFF);
+ int index = tmp->pixel;
+ Colormap cmap = DefaultColormap(XCURSESDISPLAY,
+ DefaultScreen(XCURSESDISPLAY));
+
+ if (index < 0 || index >= MAX_COLORS)
+ _exit_process(4, SIGKILL, "exiting from _set_color");
+
+ if (XAllocColor(XCURSESDISPLAY, cmap, tmp))
+ {
+ XFreeColors(XCURSESDISPLAY, cmap, colors + index, 1, 0);
+ colors[index] = tmp->pixel;
+
+ _display_screen();
+ }
+}
+
+/* For PDC_getclipboard() */
+
+static void _get_selection(Widget w, XtPointer data, Atom *selection,
+ Atom *type, XtPointer value,
+ unsigned long *length, int *format)
+{
+ unsigned char *src = value;
+ int pos, len = *length;
+
+ XC_LOG(("_get_selection() - called\n"));
+
+ if (!value && !len)
+ {
+ if (XC_write_display_socket_int(PDC_CLIP_EMPTY) < 0)
+ _exit_process(4, SIGKILL, "exiting from _get_selection");
+ }
+ else
+ {
+ /* Here all is OK, send PDC_CLIP_SUCCESS, then length, then
+ contents */
+
+ if (XC_write_display_socket_int(PDC_CLIP_SUCCESS) < 0)
+ _exit_process(4, SIGKILL, "exiting from _get_selection");
+
+ if (XC_write_display_socket_int(len) < 0)
+ _exit_process(4, SIGKILL, "exiting from _get_selection");
+
+ for (pos = 0; pos < len; pos++)
+ {
+#ifdef PDC_WIDE
+ wchar_t c;
+#else
+ unsigned char c;
+#endif
+ c = *src++;
+
+ if (XC_write_socket(xc_display_sock, &c, sizeof(c)) < 0)
+ _exit_process(4, SIGKILL, "exiting from _get_selection");
+ }
+ }
+}
+
+#ifdef PDC_WIDE
+static void _get_selection_utf8(Widget w, XtPointer data, Atom *selection,
+ Atom *type, XtPointer value,
+ unsigned long *length, int *format)
+{
+ int len = *length;
+
+ XC_LOG(("_get_selection_utf8() - called\n"));
+
+ if (!*type || !*length)
+ {
+ XtGetSelectionValue(w, XA_PRIMARY, XA_STRING, _get_selection,
+ (XtPointer)NULL, 0);
+ return;
+ }
+
+ if (!value && !len)
+ {
+ if (XC_write_display_socket_int(PDC_CLIP_EMPTY) >= 0)
+ return;
+ }
+ else
+ {
+ wchar_t *wcontents = malloc((len + 1) * sizeof(wchar_t));
+ char *src = value;
+ int i = 0;
+
+ while (*src && i < (*length))
+ {
+ int retval = _from_utf8(wcontents + i, src, len);
+
+ src += retval;
+ len -= retval;
+ i++;
+ }
+
+ wcontents[i] = 0;
+ len = i;
+
+ /* Here all is OK, send PDC_CLIP_SUCCESS, then length, then
+ contents */
+
+ if (XC_write_display_socket_int(PDC_CLIP_SUCCESS) >= 0)
+ if (XC_write_display_socket_int(len) >= 0)
+ if (XC_write_socket(xc_display_sock,
+ wcontents, len * sizeof(wchar_t)) >= 0)
+ {
+ free(wcontents);
+ return;
+ }
+ }
+
+ _exit_process(4, SIGKILL, "exiting from _get_selection_utf8");
+}
+#endif
+
+/* For PDC_setclipboard() */
+
+static void _set_selection(void)
+{
+ long length, pos;
+ int status;
+
+ if (XC_read_socket(xc_display_sock, &length, sizeof(long)) < 0)
+ _exit_process(5, SIGKILL, "exiting from _set_selection");
+
+ if (length > (long)tmpsel_length)
+ {
+ if (!tmpsel_length)
+ tmpsel = malloc((length + 1) * sizeof(chtype));
+ else
+ tmpsel = realloc(tmpsel, (length + 1) * sizeof(chtype));
+ }
+
+ if (!tmpsel)
+ if (XC_write_display_socket_int(PDC_CLIP_MEMORY_ERROR) < 0)
+ _exit_process(4, SIGKILL, "exiting from _set_selection");
+
+ for (pos = 0; pos < length; pos++)
+ {
+#ifdef PDC_WIDE
+ wchar_t c;
+#else
+ unsigned char c;
+#endif
+ if (XC_read_socket(xc_display_sock, &c, sizeof(c)) < 0)
+ _exit_process(5, SIGKILL, "exiting from _set_selection");
+
+ tmpsel[pos] = c;
+ }
+
+ tmpsel_length = length;
+ tmpsel[length] = 0;
+
+ if (XtOwnSelection(topLevel, XA_PRIMARY, CurrentTime,
+ _convert_proc, _lose_ownership, NULL) == False)
+ {
+ status = PDC_CLIP_ACCESS_ERROR;
+ free(tmpsel);
+ tmpsel = NULL;
+ tmpsel_length = 0;
+ }
+ else
+ status = PDC_CLIP_SUCCESS;
+
+ _selection_off();
+
+ if (XC_write_display_socket_int(status) < 0)
+ _exit_process(4, SIGKILL, "exiting from _set_selection");
+}
+
+/* The curses process is waiting; tell it to continue */
+
+static void _resume_curses(void)
+{
+ if (XC_write_display_socket_int(CURSES_CONTINUE) < 0)
+ _exit_process(4, SIGKILL, "exiting from _process_curses_requests");
+}
+
+/* The curses process sent us a message */
+
+static void _process_curses_requests(XtPointer client_data, int *fid,
+ XtInputId *id)
+{
+ struct timeval socket_timeout = {0};
+ int s;
+ int old_row, new_row;
+ int old_x, new_x;
+ int pos, num_cols;
+
+ char buf[12]; /* big enough for 2 integers */
+
+ XC_LOG(("_process_curses_requests() - called\n"));
+
+ if (!received_map_notify)
+ return;
+
+ FD_ZERO(&xc_readfds);
+ FD_SET(xc_display_sock, &xc_readfds);
+
+ if ((s = select(FD_SETSIZE, (FD_SET_CAST)&xc_readfds, NULL,
+ NULL, &socket_timeout)) < 0)
+ _exit_process(2, SIGKILL, "exiting from _process_curses_requests"
+ " - select failed");
+
+ if (!s) /* no requests pending - should never happen! */
+ return;
+
+ if (FD_ISSET(xc_display_sock, &xc_readfds))
+ {
+ /* read first integer to determine total message has been
+ received */
+
+ XC_LOG(("_process_curses_requests() - before XC_read_socket()\n"));
+
+ if (XC_read_socket(xc_display_sock, &num_cols, sizeof(int)) < 0)
+ _exit_process(3, SIGKILL, "exiting from _process_curses_requests"
+ " - first read");
+
+ XC_LOG(("_process_curses_requests() - after XC_read_socket()\n"));
+
+ after_first_curses_request = TRUE;
+
+ switch(num_cols)
+ {
+ case CURSES_EXIT: /* request from curses to stop */
+ XC_LOG(("CURSES_EXIT received from child\n"));
+ _exit_process(0, 0, "XCursesProcess requested to exit by child");
+ break;
+
+ case CURSES_BELL:
+ XC_LOG(("CURSES_BELL received from child\n"));
+ XBell(XCURSESDISPLAY, 50);
+ break;
+
+ /* request from curses to confirm completion of display */
+
+ case CURSES_REFRESH:
+ XC_LOG(("CURSES_REFRESH received from child\n"));
+ _refresh_screen();
+ _resume_curses();
+ break;
+
+ case CURSES_REFRESH_SCROLLBAR:
+ _refresh_scrollbar();
+ break;
+
+ case CURSES_CURSOR:
+ XC_LOG(("CURSES_CURSOR received from child\n"));
+
+ if (XC_read_socket(xc_display_sock, buf, sizeof(int) * 2) < 0)
+ _exit_process(5, SIGKILL, "exiting from CURSES_CURSOR "
+ "_process_curses_requests");
+
+ memcpy(&pos, buf, sizeof(int));
+ old_row = pos & 0xFF;
+ old_x = pos >> 8;
+
+ memcpy(&pos, buf + sizeof(int), sizeof(int));
+ new_row = pos & 0xFF;
+ new_x = pos >> 8;
+
+ visible_cursor = TRUE;
+ _display_cursor(old_row, old_x, new_row, new_x);
+ break;
+
+ case CURSES_DISPLAY_CURSOR:
+ XC_LOG(("CURSES_DISPLAY_CURSOR received from child. Vis now: "));
+ XC_LOG((visible_cursor ? "1\n" : "0\n"));
+
+ /* If the window is not active, ignore this command. The
+ cursor will stay solid. */
+
+ if (window_entered)
+ {
+ if (visible_cursor)
+ {
+ /* Cursor currently ON, turn it off */
+
+ int save_visibility = SP->visibility;
+ SP->visibility = 0;
+ _redraw_cursor();
+ SP->visibility = save_visibility;
+ visible_cursor = FALSE;
+ }
+ else
+ {
+ /* Cursor currently OFF, turn it on */
+
+ _redraw_cursor();
+ visible_cursor = TRUE;
+ }
+ }
+
+ break;
+
+ case CURSES_TITLE:
+ XC_LOG(("CURSES_TITLE received from child\n"));
+ _set_title();
+ break;
+
+ case CURSES_RESIZE:
+ XC_LOG(("CURSES_RESIZE received from child\n"));
+ _resize();
+ _resume_curses();
+ break;
+
+ case CURSES_GET_SELECTION:
+ XC_LOG(("CURSES_GET_SELECTION received from child\n"));
+
+ _resume_curses();
+
+ XtGetSelectionValue(topLevel, XA_PRIMARY,
+#ifdef PDC_WIDE
+ XA_UTF8_STRING(XtDisplay(topLevel)),
+ _get_selection_utf8,
+#else
+ XA_STRING, _get_selection,
+#endif
+ (XtPointer)NULL, 0);
+
+ break;
+
+ case CURSES_SET_SELECTION:
+ XC_LOG(("CURSES_SET_SELECTION received from child\n"));
+ _set_selection();
+ break;
+
+ case CURSES_CLEAR_SELECTION:
+ XC_LOG(("CURSES_CLEAR_SELECTION received from child\n"));
+ _resume_curses();
+ _selection_off();
+ break;
+
+ case CURSES_GET_COLOR:
+ XC_LOG(("CURSES_GET_COLOR recieved from child\n"));
+ _get_color();
+ _resume_curses();
+ break;
+
+ case CURSES_SET_COLOR:
+ XC_LOG(("CURSES_SET_COLOR recieved from child\n"));
+ _set_color();
+ _resume_curses();
+ break;
+
+ default:
+ PDC_LOG(("%s:Unknown request %d\n", XCLOGMSG, num_cols));
+ }
+ }
+}
+
+static void _handle_structure_notify(Widget w, XtPointer client_data,
+ XEvent *event, Boolean *unused)
+{
+ XC_LOG(("_handle_structure_notify() - called\n"));
+
+ switch(event->type)
+ {
+ case ConfigureNotify:
+ XC_LOG(("ConfigureNotify received\n"));
+
+ /* Window has been resized, change width and height to send to
+ place_text and place_graphics in next Expose. Also will need
+ to kill (SIGWINCH) curses process if screen size changes. */
+
+ resize_window_width = event->xconfigure.width;
+ resize_window_height = event->xconfigure.height;
+
+ after_first_curses_request = FALSE;
+
+#ifdef SIGWINCH
+ SP->resized = 1;
+
+ kill(xc_otherpid, SIGWINCH);
+#endif
+ _send_key_to_curses(KEY_RESIZE, NULL, TRUE);
+ break;
+
+ case MapNotify:
+ XC_LOG(("MapNotify received\n"));
+
+ received_map_notify = 1;
+
+ _draw_border();
+ break;
+
+ default:
+ PDC_LOG(("%s:_handle_structure_notify - unknown event %d\n",
+ XCLOGMSG, event->type));
+ }
+}
+
+static RETSIGTYPE _handle_signals(int signo)
+{
+ int flag = CURSES_EXIT;
+
+ PDC_LOG(("%s:_handle_signals() - called: %d\n", XCLOGMSG, signo));
+
+ /* Patch by: Georg Fuchs */
+
+ XCursesSetSignal(signo, _handle_signals);
+
+#ifdef SIGTSTP
+ if (signo == SIGTSTP)
+ {
+ pause();
+ return;
+ }
+#endif
+#ifdef SIGCONT
+ if (signo == SIGCONT)
+ return;
+#endif
+#ifdef SIGCLD
+ if (signo == SIGCLD)
+ return;
+#endif
+#ifdef SIGTTIN
+ if (signo == SIGTTIN)
+ return;
+#endif
+#ifdef SIGWINCH
+ if (signo == SIGWINCH)
+ return;
+#endif
+
+ /* End of patch by: Georg Fuchs */
+
+ XCursesSetSignal(signo, SIG_IGN);
+
+ /* Send a CURSES_EXIT to myself */
+
+ if (XC_write_socket(xc_exit_sock, &flag, sizeof(int)) < 0)
+ _exit_process(7, signo, "exiting from _handle_signals");
+}
+
+#ifdef PDC_XIM
+static void _dummy_handler(Widget w, XtPointer client_data,
+ XEvent *event, Boolean *unused)
+{
+}
+#endif
+
+int XCursesSetupX(int argc, char *argv[])
+{
+ char *myargv[] = {"PDCurses", NULL};
+ extern bool sb_started;
+
+ int italic_font_valid;
+ XColor pointerforecolor, pointerbackcolor;
+ XrmValue rmfrom, rmto;
+ int i = 0;
+ int minwidth, minheight;
+
+ XC_LOG(("XCursesSetupX called\n"));
+
+ if (!argv)
+ {
+ argv = myargv;
+ argc = 1;
+ }
+
+ program_name = argv[0];
+
+ /* Keep open the 'write' end of the socket so the XCurses process
+ can send a CURSES_EXIT to itself from within the signal handler */
+
+ xc_exit_sock = xc_display_sockets[0];
+ xc_display_sock = xc_display_sockets[1];
+
+ close(xc_key_sockets[0]);
+ xc_key_sock = xc_key_sockets[1];
+
+ /* Trap all signals when XCurses is the child process, but only if
+ they haven't already been ignored by the application. */
+
+ for (i = 0; i < PDC_MAX_SIGNALS; i++)
+ if (XCursesSetSignal(i, _handle_signals) == SIG_IGN)
+ XCursesSetSignal(i, SIG_IGN);
+
+ /* Start defining X Toolkit things */
+
+#if XtSpecificationRelease > 4
+ XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL);
+#endif
+
+ /* Exit if no DISPLAY variable set */
+
+ if (!getenv("DISPLAY"))
+ {
+ fprintf(stderr, "Error: no DISPLAY variable set\n");
+ kill(xc_otherpid, SIGKILL);
+ return ERR;
+ }
+
+ /* Initialise the top level widget */
+
+ topLevel = XtVaAppInitialize(&app_context, class_name, options,
+ XtNumber(options), &argc, argv, NULL, NULL);
+
+ XtVaGetApplicationResources(topLevel, &xc_app_data, app_resources,
+ XtNumber(app_resources), NULL);
+
+ /* Check application resource values here */
+
+ font_width = xc_app_data.normalFont->max_bounds.rbearing -
+ xc_app_data.normalFont->min_bounds.lbearing;
+
+ font_height = xc_app_data.normalFont->max_bounds.ascent +
+ xc_app_data.normalFont->max_bounds.descent;
+
+ font_ascent = xc_app_data.normalFont->max_bounds.ascent;
+ font_descent = xc_app_data.normalFont->max_bounds.descent;
+
+ /* Check that the italic font and normal fonts are the same size */
+ /* This appears backwards */
+
+ italic_font_valid = font_width !=
+ xc_app_data.italicFont->max_bounds.rbearing -
+ xc_app_data.italicFont->min_bounds.lbearing ||
+ font_height !=
+ xc_app_data.italicFont->max_bounds.ascent +
+ xc_app_data.italicFont->max_bounds.descent;
+
+ /* Calculate size of display window */
+
+ XCursesCOLS = xc_app_data.cols;
+ XCursesLINES = xc_app_data.lines;
+
+ window_width = font_width * XCursesCOLS +
+ 2 * xc_app_data.borderWidth;
+
+ window_height = font_height * XCursesLINES +
+ 2 * xc_app_data.borderWidth;
+
+ minwidth = font_width * 2 + xc_app_data.borderWidth * 2;
+ minheight = font_height * 2 + xc_app_data.borderWidth * 2;
+
+ /* Set up the icon for the application; the default is an internal
+ one for PDCurses. Then set various application level resources. */
+
+ _get_icon();
+
+#ifdef HAVE_XPM_H
+ if (xc_app_data.pixmap && xc_app_data.pixmap[0])
+ XtVaSetValues(topLevel, XtNminWidth, minwidth, XtNminHeight,
+ minheight, XtNbaseWidth, xc_app_data.borderWidth * 2,
+ XtNbaseHeight, xc_app_data.borderWidth * 2,
+ XtNiconPixmap, icon_pixmap,
+ XtNiconMask, icon_pixmap_mask, NULL);
+ else
+#endif
+ XtVaSetValues(topLevel, XtNminWidth, minwidth, XtNminHeight,
+ minheight, XtNbaseWidth, xc_app_data.borderWidth * 2,
+ XtNbaseHeight, xc_app_data.borderWidth * 2,
+ XtNiconPixmap, icon_bitmap, NULL);
+
+ /* Create a BOX widget in which to draw */
+
+ if (xc_app_data.scrollbarWidth && sb_started)
+ {
+ scrollBox = XtVaCreateManagedWidget(program_name,
+ scrollBoxWidgetClass, topLevel, XtNwidth,
+ window_width + xc_app_data.scrollbarWidth,
+ XtNheight, window_height + xc_app_data.scrollbarWidth,
+ XtNwidthInc, font_width, XtNheightInc, font_height, NULL);
+
+ drawing = XtVaCreateManagedWidget(program_name,
+ boxWidgetClass, scrollBox, XtNwidth,
+ window_width, XtNheight, window_height, XtNwidthInc,
+ font_width, XtNheightInc, font_height, NULL);
+
+ scrollVert = XtVaCreateManagedWidget("scrollVert",
+ scrollbarWidgetClass, scrollBox, XtNorientation,
+ XtorientVertical, XtNheight, window_height, XtNwidth,
+ xc_app_data.scrollbarWidth, NULL);
+
+ XtAddCallback(scrollVert, XtNscrollProc, _scroll_up_down, drawing);
+ XtAddCallback(scrollVert, XtNjumpProc, _thumb_up_down, drawing);
+
+ scrollHoriz = XtVaCreateManagedWidget("scrollHoriz",
+ scrollbarWidgetClass, scrollBox, XtNorientation,
+ XtorientHorizontal, XtNwidth, window_width, XtNheight,
+ xc_app_data.scrollbarWidth, NULL);
+
+ XtAddCallback(scrollHoriz, XtNscrollProc, _scroll_left_right, drawing);
+ XtAddCallback(scrollHoriz, XtNjumpProc, _thumb_left_right, drawing);
+ }
+ else
+ {
+ drawing = XtVaCreateManagedWidget(program_name, boxWidgetClass,
+ topLevel, XtNwidth, window_width, XtNheight, window_height,
+ XtNwidthInc, font_width, XtNheightInc, font_height, NULL);
+
+ XtVaSetValues(topLevel, XtNwidthInc, font_width, XtNheightInc,
+ font_height, NULL);
+ }
+
+ /* Process any default translations */
+
+ XtAugmentTranslations(drawing,
+ XtParseTranslationTable(default_translations));
+ XtAppAddActions(app_context, action_table, XtNumber(action_table));
+
+ /* Process the supplied colors */
+
+ _initialize_colors();
+
+ /* Determine text cursor alignment from resources */
+
+ if (!strcmp(xc_app_data.textCursor, "vertical"))
+ vertical_cursor = TRUE;
+
+ /* Now have LINES and COLS. Set these in the shared SP so the curses
+ program can find them. */
+
+ LINES = XCursesLINES;
+ COLS = XCursesCOLS;
+
+ if ((shmidSP = shmget(shmkeySP, sizeof(SCREEN) + XCURSESSHMMIN,
+ 0700 | IPC_CREAT)) < 0)
+ {
+ perror("Cannot allocate shared memory for SCREEN");
+ kill(xc_otherpid, SIGKILL);
+ return ERR;
+ }
+
+ SP = (SCREEN*)shmat(shmidSP, 0, 0);
+ memset(SP, 0, sizeof(SCREEN));
+ SP->XcurscrSize = XCURSCR_SIZE;
+ SP->lines = XCursesLINES;
+ SP->cols = XCursesCOLS;
+
+ SP->mouse_wait = xc_app_data.clickPeriod;
+ SP->audible = TRUE;
+
+ PDC_LOG(("%s:SHM size for curscr %d\n", XCLOGMSG, SP->XcurscrSize));
+
+ if ((shmid_Xcurscr = shmget(shmkey_Xcurscr, SP->XcurscrSize +
+ XCURSESSHMMIN, 0700 | IPC_CREAT)) < 0)
+ {
+ perror("Cannot allocate shared memory for curscr");
+ kill(xc_otherpid, SIGKILL);
+ shmdt((char *)SP);
+ shmctl(shmidSP, IPC_RMID, 0);
+ return ERR;
+ }
+
+ Xcurscr = (unsigned char *)shmat(shmid_Xcurscr, 0, 0);
+ memset(Xcurscr, 0, SP->XcurscrSize);
+ xc_atrtab = (short *)(Xcurscr + XCURSCR_ATRTAB_OFF);
+
+ PDC_LOG(("%s:shmid_Xcurscr %d shmkey_Xcurscr %d LINES %d COLS %d\n",
+ XCLOGMSG, shmid_Xcurscr, shmkey_Xcurscr, LINES, COLS));
+
+ /* Add Event handlers to the drawing widget */
+
+ XtAddEventHandler(drawing, ExposureMask, False, _handle_expose, NULL);
+ XtAddEventHandler(drawing, StructureNotifyMask, False,
+ _handle_structure_notify, NULL);
+ XtAddEventHandler(drawing, EnterWindowMask | LeaveWindowMask, False,
+ _handle_enter_leave, NULL);
+ XtAddEventHandler(topLevel, 0, True, _handle_nonmaskable, NULL);
+
+ /* Add input handler from xc_display_sock (requests from curses
+ program) */
+
+ XtAppAddInput(app_context, xc_display_sock, (XtPointer)XtInputReadMask,
+ _process_curses_requests, NULL);
+
+ /* If there is a cursorBlink resource, start the Timeout event */
+
+ if (xc_app_data.cursorBlinkRate)
+ XtAppAddTimeOut(app_context, xc_app_data.cursorBlinkRate,
+ _blink_cursor, NULL);
+
+ /* Leave telling the curses process that it can start to here so
+ that when the curses process makes a request, the Xcurses
+ process can service the request. */
+
+ XC_write_display_socket_int(CURSES_CHILD);
+
+ XtRealizeWidget(topLevel);
+
+ /* Handle trapping of the WM_DELETE_WINDOW property */
+
+ wm_atom[0] = XInternAtom(XtDisplay(topLevel), "WM_DELETE_WINDOW", False);
+
+ XSetWMProtocols(XtDisplay(topLevel), XtWindow(topLevel), wm_atom, 1);
+
+ /* Create the Graphics Context for drawing. This MUST be done AFTER
+ the associated widget has been realized. */
+
+ XC_LOG(("before _get_gc\n"));
+
+ _get_gc(&normal_gc, xc_app_data.normalFont, COLOR_WHITE, COLOR_BLACK);
+
+ _get_gc(&italic_gc, italic_font_valid ? xc_app_data.italicFont :
+ xc_app_data.normalFont, COLOR_WHITE, COLOR_BLACK);
+
+ _get_gc(&block_cursor_gc, xc_app_data.normalFont,
+ COLOR_BLACK, COLOR_CURSOR);
+
+ _get_gc(&rect_cursor_gc, xc_app_data.normalFont,
+ COLOR_CURSOR, COLOR_BLACK);
+
+ _get_gc(&border_gc, xc_app_data.normalFont, COLOR_BORDER, COLOR_BLACK);
+
+ XSetLineAttributes(XCURSESDISPLAY, rect_cursor_gc, 2,
+ LineSolid, CapButt, JoinMiter);
+
+ XSetLineAttributes(XCURSESDISPLAY, border_gc, xc_app_data.borderWidth,
+ LineSolid, CapButt, JoinMiter);
+
+ /* Set the cursor for the application */
+
+ XDefineCursor(XCURSESDISPLAY, XCURSESWIN, xc_app_data.pointer);
+ rmfrom.size = sizeof(Pixel);
+ rmto.size = sizeof(XColor);
+
+ rmto.addr = (XPointer)&pointerforecolor;
+ rmfrom.addr = (XPointer)&(xc_app_data.pointerForeColor);
+ XtConvertAndStore(drawing, XtRPixel, &rmfrom, XtRColor, &rmto);
+
+ rmfrom.size = sizeof(Pixel);
+ rmto.size = sizeof(XColor);
+
+ rmfrom.addr = (XPointer)&(xc_app_data.pointerBackColor);
+ rmto.addr = (XPointer)&pointerbackcolor;
+ XtConvertAndStore(drawing, XtRPixel, &rmfrom, XtRColor, &rmto);
+
+ XRecolorCursor(XCURSESDISPLAY, xc_app_data.pointer,
+ &pointerforecolor, &pointerbackcolor);
+
+#ifndef PDC_XIM
+
+ /* Convert the supplied compose key to a Keysym */
+
+ compose_key = XStringToKeysym(xc_app_data.composeKey);
+
+ if (compose_key && IsModifierKey(compose_key))
+ {
+ int i, j;
+ KeyCode *kcp;
+ XModifierKeymap *map;
+ KeyCode compose_keycode = XKeysymToKeycode(XCURSESDISPLAY, compose_key);
+
+ map = XGetModifierMapping(XCURSESDISPLAY);
+ kcp = map->modifiermap;
+
+ for (i = 0; i < 8; i++)
+ {
+ for (j = 0; j < map->max_keypermod; j++, kcp++)
+ {
+ if (!*kcp)
+ continue;
+
+ if (compose_keycode == *kcp)
+ {
+ compose_mask = state_mask[i];
+ break;
+ }
+ }
+
+ if (compose_mask)
+ break;
+ }
+
+ XFreeModifiermap(map);
+ }
+
+#else
+ Xim = XOpenIM(XCURSESDISPLAY, NULL, NULL, NULL);
+
+ if (Xim)
+ {
+ Xic = XCreateIC(Xim, XNInputStyle,
+ XIMPreeditNothing | XIMStatusNothing,
+ XNClientWindow, XCURSESWIN, NULL);
+ }
+
+ if (Xic)
+ {
+ long im_event_mask;
+
+ XGetICValues(Xic, XNFilterEvents, &im_event_mask, NULL);
+ if (im_event_mask)
+ XtAddEventHandler(drawing, im_event_mask, False,
+ _dummy_handler, NULL);
+
+ XSetICFocus(Xic);
+ }
+ else
+ {
+ perror("ERROR: Cannot create input context");
+ kill(xc_otherpid, SIGKILL);
+ shmdt((char *)SP);
+ shmdt((char *)Xcurscr);
+ shmctl(shmidSP, IPC_RMID, 0);
+ shmctl(shmid_Xcurscr, IPC_RMID, 0);
+ return ERR;
+ }
+
+#endif
+
+ /* Wait for events */
+
+ XtAppMainLoop(app_context);
+ return OK; /* won't get here */
+}
diff --git a/payloads/libpayload/curses/PDCurses-3.4/x11/xcurses-config.in b/payloads/libpayload/curses/PDCurses-3.4/x11/xcurses-config.in
new file mode 100644
index 0000000000..55b4704c6c
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/x11/xcurses-config.in
@@ -0,0 +1,76 @@
+#! /bin/sh
+#
+# The idea to this kind of setup info script was stolen from numerous
+# other packages, such as neon, libxml and gnome.
+#
+# $Id: xcurses-config.in,v 1.6 2007/11/07 23:33:07 wmcbrine Exp $
+#
+
+verdot=3.4
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+includedir=@includedir@/xcurses
+
+usage()
+{
+ echo "Usage: xcurses-config [OPTION]"
+ echo ""
+ echo "Available values for OPTION include:"
+ echo ""
+ echo " --help display this help and exit"
+ echo " --cflags pre-processor and compiler flags"
+ echo " [-I$includedir]"
+ echo " --libs library linking information"
+ echo " [-L$prefix/lib -lXCurses @LDFLAGS@ @MH_XLIBS@ @MH_EXTRA_LIBS@"
+ echo " --prefix PDCurses install prefix"
+ echo " [$prefix]"
+ echo " --version output version information"
+ echo " [$verdot]"
+ exit $1
+}
+
+if test $# -eq 0; then
+ usage 1
+fi
+
+while test $# -gt 0; do
+ case "$1" in
+ # this deals with options in the style
+ # --option=value and extracts the value part
+ # [not currently used]
+ -*=*) value=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) value= ;;
+ esac
+
+ case "$1" in
+ --prefix)
+ echo $prefix
+ ;;
+
+ --version)
+ echo $verdot
+ exit 0
+ ;;
+
+ --help)
+ usage 0
+ ;;
+
+ --cflags)
+ echo -I$includedir
+ ;;
+
+ --libs)
+ echo -L$prefix/lib -lXCurses @LDFLAGS@ @MH_XLIBS@ @MH_EXTRA_LIBS@
+ ;;
+
+ *)
+ usage
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+exit 0
diff --git a/payloads/libpayload/include/curses.h b/payloads/libpayload/curses/curses.h
index 0c97941152..0c97941152 100644
--- a/payloads/libpayload/include/curses.h
+++ b/payloads/libpayload/curses/curses.h
diff --git a/payloads/libpayload/include/curses.priv.h b/payloads/libpayload/curses/curses.priv.h
index 78b7ff3cc9..78b7ff3cc9 100644
--- a/payloads/libpayload/include/curses.priv.h
+++ b/payloads/libpayload/curses/curses.priv.h
diff --git a/payloads/libpayload/curses/form/Makefile.in b/payloads/libpayload/curses/form/Makefile.in
new file mode 100644
index 0000000000..1a07e140d3
--- /dev/null
+++ b/payloads/libpayload/curses/form/Makefile.in
@@ -0,0 +1,170 @@
+# $Id: Makefile.in,v 1.53 2010/11/27 21:45:27 tom Exp $
+##############################################################################
+# Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. #
+# #
+# Permission is hereby granted, free of charge, to any person obtaining a #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation #
+# the rights to use, copy, modify, merge, publish, distribute, distribute #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the #
+# following conditions: #
+# #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software. #
+# #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
+# DEALINGS IN THE SOFTWARE. #
+# #
+# Except as contained in this notice, the name(s) of the above copyright #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written #
+# authorization. #
+##############################################################################
+#
+# Author: Thomas E. Dickey 1996-on
+#
+# Makefile for form source code.
+#
+# This makes the following:
+# libraries (normal/debug/profile/shared)
+#
+# The variable 'srcdir' refers to the source-distribution, and can be set with
+# the configure script by "--srcdir=DIR".
+#
+# The rules are organized to produce the libraries for the configured models,
+
+# turn off _all_ suffix rules; we'll generate our own
+.SUFFIXES:
+
+SHELL = /bin/sh
+VPATH = @srcdir@
+THIS = Makefile
+
+x = @EXEEXT@
+o = .@OBJEXT@
+
+MODEL = @DFT_LWR_MODEL@
+DESTDIR = @DESTDIR@
+srcdir = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+libdir = @libdir@
+includedir = @includedir@
+
+LIBTOOL = @LIBTOOL@
+LIBTOOL_CLEAN = @LIB_CLEAN@
+LIBTOOL_COMPILE = @LIB_COMPILE@
+LIBTOOL_LINK = @LIB_LINK@
+LIBTOOL_INSTALL = @LIB_INSTALL@
+LIBTOOL_UNINSTALL = @LIB_UNINSTALL@
+LT_UNDEF = @LT_UNDEF@
+
+INSTALL = @INSTALL@
+INSTALL_LIB = @INSTALL@ @INSTALL_LIB@
+INSTALL_PROG = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+AR = @AR@
+ARFLAGS = @ARFLAGS@
+AWK = @AWK@
+LD = @LD@
+LN_S = @LN_S@
+
+CTAGS = @CTAGS@
+ETAGS = @ETAGS@
+
+CC = @CC@
+CPP = @CPP@
+CFLAGS = @CFLAGS@
+
+CPPFLAGS = -I@top_srcdir@/ncurses -DHAVE_CONFIG_H @CPPFLAGS@
+
+CCFLAGS = $(CPPFLAGS) $(CFLAGS)
+
+CFLAGS_LIBTOOL = $(CCFLAGS)
+CFLAGS_NORMAL = $(CCFLAGS)
+CFLAGS_DEBUG = $(CCFLAGS) @CC_G_OPT@ -DTRACE
+CFLAGS_PROFILE = $(CCFLAGS) -pg
+CFLAGS_SHARED = $(CCFLAGS) @CC_SHARED_OPTS@
+
+CFLAGS_DEFAULT = $(CFLAGS_@DFT_UPR_MODEL@)
+
+LINK = $(LIBTOOL_LINK)
+LDFLAGS = @LDFLAGS@ @LD_MODEL@ @LIBS@
+
+SHLIB_DIRS = -L../lib
+SHLIB_LIST = $(SHLIB_DIRS) -lncurses@LIB_SUFFIX@ @SHLIB_LIST@
+
+MK_SHARED_LIB = @MK_SHARED_LIB@
+
+NCURSES_MAJOR = @NCURSES_MAJOR@
+NCURSES_MINOR = @NCURSES_MINOR@
+REL_VERSION = @cf_cv_rel_version@
+ABI_VERSION = @cf_cv_abi_version@
+
+RANLIB = @LIB_PREP@
+
+LIBRARIES = @LIBS_TO_MAKE@
+
+LINT = @LINT@
+LINT_OPTS = @LINT_OPTS@
+LINT_LIBS = -lform -lncurses @LIBS@
+
+AUTO_SRC = \
+ ../include/form.h
+
+################################################################################
+all \
+libs \
+install :: $(AUTO_SRC) $(LIBRARIES)
+
+sources : $(AUTO_SRC)
+
+$(DESTDIR)$(bindir) \
+$(DESTDIR)$(libdir) :
+ mkdir -p $@
+
+# make copies to simplify include-paths while still keeping form's include
+# file in this directory.
+../include/form.h : $(srcdir)/form.h
+ -rm -f $@
+ cp $(srcdir)/form.h $@
+
+HEADER_DEPS = \
+ $(srcdir)/form.priv.h \
+ $(srcdir)/form.h \
+ ../include/mf_common.h \
+ ../include/curses.h \
+ ../include/eti.h
+
+tags:
+ $(CTAGS) *.[ch]
+
+@MAKE_UPPER_TAGS@TAGS:
+@MAKE_UPPER_TAGS@ $(ETAGS) *.[ch]
+
+mostlyclean ::
+ -rm -f core tags TAGS *~ *.bak *.i *.ln *.atac trace
+
+clean :: mostlyclean
+ -rm -f $(AUTO_SRC)
+
+distclean :: clean
+ -rm -f Makefile
+
+realclean :: distclean
+
+../include/mf_common.h \
+../include/eti.h :
+ cd ../menu && $(MAKE) $@
+
+###############################################################################
+# The remainder of this file is automatically generated during configuration
+###############################################################################
diff --git a/payloads/libpayload/curses/form/READ.ME b/payloads/libpayload/curses/form/READ.ME
new file mode 100644
index 0000000000..da86bf6927
--- /dev/null
+++ b/payloads/libpayload/curses/form/READ.ME
@@ -0,0 +1,42 @@
+-------------------------------------------------------------------------------
+-- Copyright (c) 1998-2003,2006 Free Software Foundation, Inc. --
+-- --
+-- Permission is hereby granted, free of charge, to any person obtaining a --
+-- copy of this software and associated documentation files (the --
+-- "Software"), to deal in the Software without restriction, including --
+-- without limitation the rights to use, copy, modify, merge, publish, --
+-- distribute, distribute with modifications, sublicense, and/or sell copies --
+-- of the Software, and to permit persons to whom the Software is furnished --
+-- to do so, subject to the following conditions: --
+-- --
+-- The above copyright notice and this permission notice shall be included --
+-- in all copies or substantial portions of the Software. --
+-- --
+-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
+-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
+-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN --
+-- NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
+-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
+-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE --
+-- USE OR OTHER DEALINGS IN THE SOFTWARE. --
+-- --
+-- Except as contained in this notice, the name(s) of the above copyright --
+-- holders shall not be used in advertising or otherwise to promote the --
+-- sale, use or other dealings in this Software without prior written --
+-- authorization. --
+-------------------------------------------------------------------------------
+-- $Id: READ.ME,v 0.7 2006/04/22 23:13:05 tom Exp $
+-------------------------------------------------------------------------------
+
+This is a clone of the form library that is available with typical
+System V curses implementations (ETI).
+
+It is modelled after the documentation that comes for this library with
+a 386 based SVR4 implementation (ESIX).
+
+The development environment was and is an ELF based Linux system.
+
+For things that still need doing, see the TO-DO file in the top-level
+directory.
+
+Juergen Pfeifer
diff --git a/payloads/libpayload/curses/form/f_trace.c b/payloads/libpayload/curses/form/f_trace.c
new file mode 100644
index 0000000000..6044e03c6e
--- /dev/null
+++ b/payloads/libpayload/curses/form/f_trace.c
@@ -0,0 +1,70 @@
+/****************************************************************************
+ * Copyright (c) 2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: f_trace.c,v 1.2 2010/01/23 21:14:36 tom Exp $")
+
+NCURSES_EXPORT(FIELD **)
+_nc_retrace_field_ptr(FIELD **code)
+{
+ T((T_RETURN("%p"), (void *)code));
+ return code;
+}
+
+NCURSES_EXPORT(FIELD *)
+_nc_retrace_field(FIELD *code)
+{
+ T((T_RETURN("%p"), (void *)code));
+ return code;
+}
+
+NCURSES_EXPORT(FIELDTYPE *)
+_nc_retrace_field_type(FIELDTYPE *code)
+{
+ T((T_RETURN("%p"), (void *)code));
+ return code;
+}
+
+NCURSES_EXPORT(FORM *)
+_nc_retrace_form(FORM *code)
+{
+ T((T_RETURN("%p"), (void *)code));
+ return code;
+}
+
+NCURSES_EXPORT(Form_Hook)
+_nc_retrace_form_hook(Form_Hook code)
+{
+ T((T_RETURN("%p"), code));
+ return code;
+}
diff --git a/payloads/libpayload/curses/form/fld_arg.c b/payloads/libpayload/curses/form/fld_arg.c
new file mode 100644
index 0000000000..a07bdb1959
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_arg.c
@@ -0,0 +1,98 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_arg.c,v 1.12 2010/01/23 21:14:35 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_fieldtype_arg(
+| FIELDTYPE *typ,
+| void * (* const make_arg)(va_list *),
+| void * (* const copy_arg)(const void *),
+| void (* const free_arg)(void *) )
+|
+| Description : Connects to the type additional arguments necessary
+| for a set_field_type call. The various function pointer
+| arguments are:
+| make_arg : allocates a structure for the field
+| specific parameters.
+| copy_arg : duplicate the structure created by
+| make_arg
+| free_arg : Release the memory allocated by make_arg
+| or copy_arg
+|
+| At least make_arg must be non-NULL.
+| You may pass NULL for copy_arg and free_arg if your
+| make_arg function doesn't allocate memory and your
+| arg fits into the storage for a (void*).
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid argument
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_fieldtype_arg(FIELDTYPE *typ,
+ void *(*const make_arg)(va_list *),
+ void *(*const copy_arg)(const void *),
+ void (*const free_arg) (void *))
+{
+ T((T_CALLED("set_fieldtype_arg(%p,%p,%p,%p)"),
+ (void *)typ, make_arg, copy_arg, free_arg));
+
+ if (typ != 0 && make_arg != (void *)0)
+ {
+ typ->status |= _HAS_ARGS;
+ typ->makearg = make_arg;
+ typ->copyarg = copy_arg;
+ typ->freearg = free_arg;
+ RETURN(E_OK);
+ }
+ RETURN(E_BAD_ARGUMENT);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : void *field_arg(const FIELD *field)
+|
+| Description : Retrieve pointer to the fields argument structure.
+|
+| Return Values : Pointer to structure or NULL if none is defined.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(void *)
+field_arg(const FIELD *field)
+{
+ T((T_CALLED("field_arg(%p)"), (const void *)field));
+ returnVoidPtr(Normalize_Field(field)->arg);
+}
+
+/* fld_arg.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_attr.c b/payloads/libpayload/curses/form/fld_attr.c
new file mode 100644
index 0000000000..0112f009ec
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_attr.c
@@ -0,0 +1,119 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_attr.c,v 1.11 2010/01/23 21:12:08 tom Exp $")
+
+/*----------------------------------------------------------------------------
+ Field-Attribute manipulation routines
+ --------------------------------------------------------------------------*/
+/* "Template" macro to generate a function to set a fields attribute */
+#define GEN_FIELD_ATTR_SET_FCT( name ) \
+NCURSES_IMPEXP int NCURSES_API set_field_ ## name (FIELD * field, chtype attr)\
+{\
+ int res = E_BAD_ARGUMENT;\
+ T((T_CALLED("set_field_" #name "(%p,%s)"), field, _traceattr(attr)));\
+ if ( attr==A_NORMAL || ((attr & A_ATTRIBUTES)==attr) )\
+ {\
+ Normalize_Field( field );\
+ if (field != 0) \
+ { \
+ if ((field -> name) != attr)\
+ {\
+ field -> name = attr;\
+ res = _nc_Synchronize_Attributes( field );\
+ }\
+ else\
+ {\
+ res = E_OK;\
+ }\
+ }\
+ }\
+ RETURN(res);\
+}
+
+/* "Template" macro to generate a function to get a fields attribute */
+#define GEN_FIELD_ATTR_GET_FCT( name ) \
+NCURSES_IMPEXP chtype NCURSES_API field_ ## name (const FIELD * field)\
+{\
+ T((T_CALLED("field_" #name "(%p)"), (const void *) field));\
+ returnAttr( A_ATTRIBUTES & (Normalize_Field( field ) -> name) );\
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_field_fore(FIELD *field, chtype attr)
+|
+| Description : Sets the foreground of the field used to display the
+| field contents.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid attributes
+| E_SYSTEM_ERROR - system error
++--------------------------------------------------------------------------*/
+GEN_FIELD_ATTR_SET_FCT(fore)
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : chtype field_fore(const FIELD *)
+|
+| Description : Retrieve fields foreground attribute
+|
+| Return Values : The foreground attribute
++--------------------------------------------------------------------------*/
+GEN_FIELD_ATTR_GET_FCT(fore)
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_field_back(FIELD *field, chtype attr)
+|
+| Description : Sets the background of the field used to display the
+| fields extend.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid attributes
+| E_SYSTEM_ERROR - system error
++--------------------------------------------------------------------------*/
+GEN_FIELD_ATTR_SET_FCT(back)
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : chtype field_back(const
+|
+| Description : Retrieve fields background attribute
+|
+| Return Values : The background attribute
++--------------------------------------------------------------------------*/
+GEN_FIELD_ATTR_GET_FCT(back)
+
+/* fld_attr.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_current.c b/payloads/libpayload/curses/form/fld_current.c
new file mode 100644
index 0000000000..ef9ec007ec
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_current.c
@@ -0,0 +1,137 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_current.c,v 1.12 2010/01/23 21:14:35 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_current_field(FORM * form,FIELD * field)
+|
+| Description : Set the current field of the form to the specified one.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid form or field pointer
+| E_REQUEST_DENIED - field not selectable
+| E_BAD_STATE - called from a hook routine
+| E_INVALID_FIELD - current field can't be left
+| E_SYSTEM_ERROR - system error
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_current_field(FORM *form, FIELD *field)
+{
+ int err = E_OK;
+
+ T((T_CALLED("set_current_field(%p,%p)"), (void *)form, (void *)field));
+ if (form == 0 || field == 0)
+ {
+ RETURN(E_BAD_ARGUMENT);
+ }
+ else if ((form != field->form) || Field_Is_Not_Selectable(field))
+ {
+ RETURN(E_REQUEST_DENIED);
+ }
+ else if ((form->status & _POSTED) == 0)
+ {
+ form->current = field;
+ form->curpage = field->page;
+ }
+ else
+ {
+ if ((form->status & _IN_DRIVER) != 0)
+ {
+ err = E_BAD_STATE;
+ }
+ else
+ {
+ if (form->current != field)
+ {
+ if (!_nc_Internal_Validation(form))
+ {
+ err = E_INVALID_FIELD;
+ }
+ else
+ {
+ Call_Hook(form, fieldterm);
+ if (field->page != form->curpage)
+ {
+ Call_Hook(form, formterm);
+ err = _nc_Set_Form_Page(form, (int)field->page, field);
+ Call_Hook(form, forminit);
+ }
+ else
+ {
+ err = _nc_Set_Current_Field(form, field);
+ }
+ Call_Hook(form, fieldinit);
+ (void)_nc_Refresh_Current_Field(form);
+ }
+ }
+ }
+ }
+ RETURN(err);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : FIELD *current_field(const FORM * form)
+|
+| Description : Return the current field.
+|
+| Return Values : Pointer to the current field.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(FIELD *)
+current_field(const FORM *form)
+{
+ T((T_CALLED("current_field(%p)"), (const void *)form));
+ returnField(Normalize_Form(form)->current);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int field_index(const FIELD * field)
+|
+| Description : Return the index of the field in the field-array of
+| the form.
+|
+| Return Values : >= 0 : field index
+| -1 : fieldpointer invalid or field not connected
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+field_index(const FIELD *field)
+{
+ T((T_CALLED("field_index(%p)"), (const void *)field));
+ returnCode((field != 0 && field->form != 0) ? (int)field->index : -1);
+}
+
+/* fld_current.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_def.c b/payloads/libpayload/curses/form/fld_def.c
new file mode 100644
index 0000000000..6d7bd34a16
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_def.c
@@ -0,0 +1,399 @@
+/****************************************************************************
+ * Copyright (c) 1998-2007,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_def.c,v 1.38 2010/01/23 21:14:35 tom Exp $")
+
+/* this can't be readonly */
+static FIELD default_field =
+{
+ 0, /* status */
+ 0, /* rows */
+ 0, /* cols */
+ 0, /* frow */
+ 0, /* fcol */
+ 0, /* drows */
+ 0, /* dcols */
+ 0, /* maxgrow */
+ 0, /* nrow */
+ 0, /* nbuf */
+ NO_JUSTIFICATION, /* just */
+ 0, /* page */
+ 0, /* index */
+ (int)' ', /* pad */
+ A_NORMAL, /* fore */
+ A_NORMAL, /* back */
+ ALL_FIELD_OPTS, /* opts */
+ (FIELD *)0, /* snext */
+ (FIELD *)0, /* sprev */
+ (FIELD *)0, /* link */
+ (FORM *)0, /* form */
+ (FIELDTYPE *)0, /* type */
+ (char *)0, /* arg */
+ (FIELD_CELL *)0, /* buf */
+ (char *)0 /* usrptr */
+ NCURSES_FIELD_EXTENSION
+};
+
+NCURSES_EXPORT_VAR(FIELD *)
+_nc_Default_Field = &default_field;
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : TypeArgument *_nc_Make_Argument(
+| const FIELDTYPE *typ,
+| va_list *ap,
+| int *err )
+|
+| Description : Create an argument structure for the specified type.
+| Use the type-dependent argument list to construct
+| it.
+|
+| Return Values : Pointer to argument structure. Maybe NULL.
+| In case of an error in *err an error counter is increased.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(TypeArgument *)
+_nc_Make_Argument(const FIELDTYPE *typ, va_list *ap, int *err)
+{
+ TypeArgument *res = (TypeArgument *)0;
+ TypeArgument *p;
+
+ if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
+ {
+ assert(err != 0 && ap != (va_list *)0);
+ if ((typ->status & _LINKED_TYPE) != 0)
+ {
+ p = typeMalloc(TypeArgument, 1);
+
+ if (p != 0)
+ {
+ p->left = _nc_Make_Argument(typ->left, ap, err);
+ p->right = _nc_Make_Argument(typ->right, ap, err);
+ return p;
+ }
+ else
+ {
+ *err += 1;
+ }
+ }
+ else
+ {
+ assert(typ->makearg != (void *)0);
+ if (!(res = (TypeArgument *)typ->makearg(ap)))
+ {
+ *err += 1;
+ }
+ }
+ }
+ return res;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : TypeArgument *_nc_Copy_Argument(const FIELDTYPE *typ,
+| const TypeArgument *argp,
+| int *err )
+|
+| Description : Create a copy of an argument structure for the specified
+| type.
+|
+| Return Values : Pointer to argument structure. Maybe NULL.
+| In case of an error in *err an error counter is increased.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(TypeArgument *)
+_nc_Copy_Argument(const FIELDTYPE *typ, const TypeArgument *argp, int *err)
+{
+ TypeArgument *res = (TypeArgument *)0;
+ TypeArgument *p;
+
+ if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
+ {
+ assert(err != 0 && argp != 0);
+ if ((typ->status & _LINKED_TYPE) != 0)
+ {
+ p = typeMalloc(TypeArgument, 1);
+
+ if (p != 0)
+ {
+ p->left = _nc_Copy_Argument(typ, argp->left, err);
+ p->right = _nc_Copy_Argument(typ, argp->right, err);
+ return p;
+ }
+ *err += 1;
+ }
+ else
+ {
+ if (typ->copyarg != (void *)0)
+ {
+ if (!(res = (TypeArgument *)(typ->copyarg((const void *)argp))))
+ {
+ *err += 1;
+ }
+ }
+ else
+ {
+ res = (TypeArgument *)argp;
+ }
+ }
+ }
+ return res;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : void _nc_Free_Argument(const FIELDTYPE *typ,
+| TypeArgument * argp )
+|
+| Description : Release memory associated with the argument structure
+| for the given fieldtype.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(void)
+_nc_Free_Argument(const FIELDTYPE *typ, TypeArgument *argp)
+{
+ if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
+ {
+ if ((typ->status & _LINKED_TYPE) != 0)
+ {
+ assert(argp != 0);
+ _nc_Free_Argument(typ->left, argp->left);
+ _nc_Free_Argument(typ->right, argp->right);
+ free(argp);
+ }
+ else
+ {
+ if (typ->freearg != (void *)0)
+ {
+ typ->freearg((void *)argp);
+ }
+ }
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : bool _nc_Copy_Type( FIELD *dst, FIELD const *src )
+|
+| Description : Copy argument structure of field src to field dst
+|
+| Return Values : TRUE - copy worked
+| FALSE - error occurred
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(bool)
+_nc_Copy_Type(FIELD *dst, FIELD const *src)
+{
+ int err = 0;
+
+ assert(dst != 0 && src != 0);
+
+ dst->type = src->type;
+ dst->arg = (void *)_nc_Copy_Argument(src->type, (TypeArgument *)(src->arg), &err);
+
+ if (err != 0)
+ {
+ _nc_Free_Argument(dst->type, (TypeArgument *)(dst->arg));
+ dst->type = (FIELDTYPE *)0;
+ dst->arg = (void *)0;
+ return FALSE;
+ }
+ else
+ {
+ if (dst->type != 0)
+ {
+ dst->type->ref++;
+ }
+ return TRUE;
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : void _nc_Free_Type( FIELD *field )
+|
+| Description : Release Argument structure for this field
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(void)
+_nc_Free_Type(FIELD *field)
+{
+ assert(field != 0);
+ if (field->type != 0)
+ {
+ field->type->ref--;
+ _nc_Free_Argument(field->type, (TypeArgument *)(field->arg));
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : FIELD *new_field( int rows, int cols,
+| int frow, int fcol,
+| int nrow, int nbuf )
+|
+| Description : Create a new field with this many 'rows' and 'cols',
+| starting at 'frow/fcol' in the subwindow of the form.
+| Allocate 'nrow' off-screen rows and 'nbuf' additional
+| buffers. If an error occurs, errno is set to
+|
+| E_BAD_ARGUMENT - invalid argument
+| E_SYSTEM_ERROR - system error
+|
+| Return Values : Pointer to the new field or NULL if failure.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(FIELD *)
+new_field(int rows, int cols, int frow, int fcol, int nrow, int nbuf)
+{
+ static const FIELD_CELL blank = BLANK;
+ static const FIELD_CELL zeros = ZEROS;
+
+ FIELD *New_Field = (FIELD *)0;
+ int err = E_BAD_ARGUMENT;
+
+ T((T_CALLED("new_field(%d,%d,%d,%d,%d,%d)"), rows, cols, frow, fcol, nrow, nbuf));
+ if (rows > 0 &&
+ cols > 0 &&
+ frow >= 0 &&
+ fcol >= 0 &&
+ nrow >= 0 &&
+ nbuf >= 0 &&
+ ((err = E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */
+ (New_Field = typeMalloc(FIELD, 1)) != 0)
+ {
+ T((T_CREATE("field %p"), (void *)New_Field));
+ *New_Field = default_field;
+ New_Field->rows = rows;
+ New_Field->cols = cols;
+ New_Field->drows = rows + nrow;
+ New_Field->dcols = cols;
+ New_Field->frow = frow;
+ New_Field->fcol = fcol;
+ New_Field->nrow = nrow;
+ New_Field->nbuf = nbuf;
+ New_Field->link = New_Field;
+
+#if USE_WIDEC_SUPPORT
+ New_Field->working = newpad(1, Buffer_Length(New_Field) + 1);
+ New_Field->expanded = typeCalloc(char *, 1 + (unsigned)nbuf);
+#endif
+
+ if (_nc_Copy_Type(New_Field, &default_field))
+ {
+ size_t len;
+
+ len = Total_Buffer_Size(New_Field);
+ if ((New_Field->buf = (FIELD_CELL *)malloc(len)))
+ {
+ /* Prefill buffers with blanks and insert terminating zeroes
+ between buffers */
+ int i, j;
+ int cells = Buffer_Length(New_Field);
+
+ for (i = 0; i <= New_Field->nbuf; i++)
+ {
+ FIELD_CELL *buffer = &(New_Field->buf[(cells + 1) * i]);
+
+ for (j = 0; j < cells; ++j)
+ {
+ buffer[j] = blank;
+ }
+ buffer[j] = zeros;
+ }
+ returnField(New_Field);
+ }
+ }
+ }
+
+ if (New_Field)
+ free_field(New_Field);
+
+ SET_ERROR(err);
+ returnField((FIELD *)0);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int free_field( FIELD *field )
+|
+| Description : Frees the storage allocated for the field.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid field pointer
+| E_CONNECTED - field is connected
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+free_field(FIELD *field)
+{
+ T((T_CALLED("free_field(%p)"), (void *)field));
+ if (!field)
+ {
+ RETURN(E_BAD_ARGUMENT);
+ }
+ else if (field->form != 0)
+ {
+ RETURN(E_CONNECTED);
+ }
+ else if (field == field->link)
+ {
+ if (field->buf != 0)
+ free(field->buf);
+ }
+ else
+ {
+ FIELD *f;
+
+ for (f = field; f->link != field; f = f->link)
+ {
+ }
+ f->link = field->link;
+ }
+ _nc_Free_Type(field);
+#if USE_WIDEC_SUPPORT
+ if (field->expanded != 0)
+ {
+ int n;
+
+ for (n = 0; n <= field->nbuf; ++n)
+ {
+ FreeIfNeeded(field->expanded[n]);
+ }
+ free(field->expanded);
+ (void)delwin(field->working);
+ }
+#endif
+ free(field);
+ RETURN(E_OK);
+}
+
+/* fld_def.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_dup.c b/payloads/libpayload/curses/form/fld_dup.c
new file mode 100644
index 0000000000..b8e501b383
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_dup.c
@@ -0,0 +1,101 @@
+/****************************************************************************
+ * Copyright (c) 1998-2007,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_dup.c,v 1.13 2010/01/23 21:14:35 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : FIELD *dup_field(FIELD *field, int frow, int fcol)
+|
+| Description : Duplicates the field at the specified position. All
+| field attributes and the buffers are copied.
+| If an error occurs, errno is set to
+|
+| E_BAD_ARGUMENT - invalid argument
+| E_SYSTEM_ERROR - system error
+|
+| Return Values : Pointer to the new field or NULL if failure
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(FIELD *)
+dup_field(FIELD *field, int frow, int fcol)
+{
+ FIELD *New_Field = (FIELD *)0;
+ int err = E_BAD_ARGUMENT;
+
+ T((T_CALLED("dup_field(%p,%d,%d)"), (void *)field, frow, fcol));
+ if (field && (frow >= 0) && (fcol >= 0) &&
+ ((err = E_SYSTEM_ERROR) != 0) && /* trick : this resets the default error */
+ (New_Field = typeMalloc(FIELD, 1)))
+ {
+ T((T_CREATE("field %p"), (void *)New_Field));
+ *New_Field = *_nc_Default_Field;
+ New_Field->frow = frow;
+ New_Field->fcol = fcol;
+ New_Field->link = New_Field;
+ New_Field->rows = field->rows;
+ New_Field->cols = field->cols;
+ New_Field->nrow = field->nrow;
+ New_Field->drows = field->drows;
+ New_Field->dcols = field->dcols;
+ New_Field->maxgrow = field->maxgrow;
+ New_Field->nbuf = field->nbuf;
+ New_Field->just = field->just;
+ New_Field->fore = field->fore;
+ New_Field->back = field->back;
+ New_Field->pad = field->pad;
+ New_Field->opts = field->opts;
+ New_Field->usrptr = field->usrptr;
+
+ if (_nc_Copy_Type(New_Field, field))
+ {
+ size_t i, len;
+
+ len = Total_Buffer_Size(New_Field);
+ if ((New_Field->buf = (FIELD_CELL *)malloc(len)))
+ {
+ for (i = 0; i < len; ++i)
+ New_Field->buf[i] = field->buf[i];
+ returnField(New_Field);
+ }
+ }
+ }
+
+ if (New_Field)
+ free_field(New_Field);
+
+ SET_ERROR(err);
+ returnField((FIELD *)0);
+}
+
+/* fld_dup.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_ftchoice.c b/payloads/libpayload/curses/form/fld_ftchoice.c
new file mode 100644
index 0000000000..3aac5be2b1
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_ftchoice.c
@@ -0,0 +1,70 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_ftchoice.c,v 1.12 2010/01/23 21:14:35 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_fieldtype_choice(
+| FIELDTYPE *typ,
+| bool (* const next_choice)(FIELD *,const void *),
+| bool (* const prev_choice)(FIELD *,const void *))
+|
+| Description : Define implementation of enumeration requests.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid arguments
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_fieldtype_choice(FIELDTYPE *typ,
+ bool (*const next_choice) (FIELD *, const void *),
+ bool (*const prev_choice) (FIELD *, const void *))
+{
+ T((T_CALLED("set_fieldtype_choice(%p,%p,%p)"), (void *)typ, next_choice, prev_choice));
+
+ if (!typ || !next_choice || !prev_choice)
+ RETURN(E_BAD_ARGUMENT);
+
+ typ->status |= _HAS_CHOICE;
+#if NCURSES_INTEROP_FUNCS
+ typ->enum_next.onext = next_choice;
+ typ->enum_prev.oprev = prev_choice;
+#else
+ typ->next = next_choice;
+ typ->prev = prev_choice;
+#endif
+ RETURN(E_OK);
+}
+
+/* fld_ftchoice.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_ftlink.c b/payloads/libpayload/curses/form/fld_ftlink.c
new file mode 100644
index 0000000000..c2cd251f42
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_ftlink.c
@@ -0,0 +1,87 @@
+/****************************************************************************
+ * Copyright (c) 1998-2007,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_ftlink.c,v 1.14 2010/01/23 21:14:35 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : FIELDTYPE *link_fieldtype(
+| FIELDTYPE *type1,
+| FIELDTYPE *type2)
+|
+| Description : Create a new fieldtype built from the two given types.
+| They are connected by an logical 'OR'.
+| If an error occurs, errno is set to
+| E_BAD_ARGUMENT - invalid arguments
+| E_SYSTEM_ERROR - system error (no memory)
+|
+| Return Values : Fieldtype pointer or NULL if error occurred.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(FIELDTYPE *)
+link_fieldtype(FIELDTYPE *type1, FIELDTYPE *type2)
+{
+ FIELDTYPE *nftyp = (FIELDTYPE *)0;
+
+ T((T_CALLED("link_fieldtype(%p,%p)"), (void *)type1, (void *)type2));
+ if (type1 && type2)
+ {
+ nftyp = typeMalloc(FIELDTYPE, 1);
+
+ if (nftyp)
+ {
+ T((T_CREATE("fieldtype %p"), (void *)nftyp));
+ *nftyp = *_nc_Default_FieldType;
+ nftyp->status |= _LINKED_TYPE;
+ if ((type1->status & _HAS_ARGS) || (type2->status & _HAS_ARGS))
+ nftyp->status |= _HAS_ARGS;
+ if ((type1->status & _HAS_CHOICE) || (type2->status & _HAS_CHOICE))
+ nftyp->status |= _HAS_CHOICE;
+ nftyp->left = type1;
+ nftyp->right = type2;
+ type1->ref++;
+ type2->ref++;
+ }
+ else
+ {
+ SET_ERROR(E_SYSTEM_ERROR);
+ }
+ }
+ else
+ {
+ SET_ERROR(E_BAD_ARGUMENT);
+ }
+ returnFieldType(nftyp);
+}
+
+/* fld_ftlink.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_info.c b/payloads/libpayload/curses/form/fld_info.c
new file mode 100644
index 0000000000..13fe8e72a0
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_info.c
@@ -0,0 +1,113 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_info.c,v 1.11 2010/01/23 21:14:35 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int field_info(const FIELD *field,
+| int *rows, int *cols,
+| int *frow, int *fcol,
+| int *nrow, int *nbuf)
+|
+| Description : Retrieve infos about the fields creation parameters.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid field pointer
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+field_info(const FIELD *field,
+ int *rows, int *cols,
+ int *frow, int *fcol,
+ int *nrow, int *nbuf)
+{
+ T((T_CALLED("field_info(%p,%p,%p,%p,%p,%p,%p)"),
+ (const void *)field,
+ (void *)rows, (void *)cols,
+ (void *)frow, (void *)fcol,
+ (void *)nrow, (void *)nbuf));
+
+ if (!field)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (rows)
+ *rows = field->rows;
+ if (cols)
+ *cols = field->cols;
+ if (frow)
+ *frow = field->frow;
+ if (fcol)
+ *fcol = field->fcol;
+ if (nrow)
+ *nrow = field->nrow;
+ if (nbuf)
+ *nbuf = field->nbuf;
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int dynamic_field_info(const FIELD *field,
+| int *drows, int *dcols,
+| int *maxgrow)
+|
+| Description : Retrieve informations about a dynamic fields current
+| dynamic parameters.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid argument
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+dynamic_field_info(const FIELD *field, int *drows, int *dcols, int *maxgrow)
+{
+ T((T_CALLED("dynamic_field_info(%p,%p,%p,%p)"),
+ (const void *)field,
+ (void *)drows,
+ (void *)dcols,
+ (void *)maxgrow));
+
+ if (!field)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (drows)
+ *drows = field->drows;
+ if (dcols)
+ *dcols = field->dcols;
+ if (maxgrow)
+ *maxgrow = field->maxgrow;
+
+ RETURN(E_OK);
+}
+
+/* fld_info.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_just.c b/payloads/libpayload/curses/form/fld_just.c
new file mode 100644
index 0000000000..58a1750cc0
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_just.c
@@ -0,0 +1,86 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_just.c,v 1.12 2010/01/23 21:14:35 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_field_just(FIELD *field, int just)
+|
+| Description : Set the fields type of justification.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - one of the arguments was incorrect
+| E_SYSTEM_ERROR - system error
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_field_just(FIELD *field, int just)
+{
+ int res = E_BAD_ARGUMENT;
+
+ T((T_CALLED("set_field_just(%p,%d)"), (void *)field, just));
+
+ if ((just == NO_JUSTIFICATION) ||
+ (just == JUSTIFY_LEFT) ||
+ (just == JUSTIFY_CENTER) ||
+ (just == JUSTIFY_RIGHT))
+ {
+ Normalize_Field(field);
+ if (field->just != just)
+ {
+ field->just = just;
+ res = _nc_Synchronize_Attributes(field);
+ }
+ else
+ res = E_OK;
+ }
+ RETURN(res);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int field_just( const FIELD *field )
+|
+| Description : Retrieve the fields type of justification
+|
+| Return Values : The justification type.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+field_just(const FIELD *field)
+{
+ T((T_CALLED("field_just(%p)"), (const void *)field));
+ returnCode(Normalize_Field(field)->just);
+}
+
+/* fld_just.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_link.c b/payloads/libpayload/curses/form/fld_link.c
new file mode 100644
index 0000000000..18103bee19
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_link.c
@@ -0,0 +1,96 @@
+/****************************************************************************
+ * Copyright (c) 1998-2007,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_link.c,v 1.12 2010/01/23 21:14:35 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : FIELD *link_field(FIELD *field, int frow, int fcol)
+|
+| Description : Duplicates the field at the specified position. The
+| new field shares its buffers with the original one,
+| the attributes are independent.
+| If an error occurs, errno is set to
+|
+| E_BAD_ARGUMENT - invalid argument
+| E_SYSTEM_ERROR - system error
+|
+| Return Values : Pointer to the new field or NULL if failure
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(FIELD *)
+link_field(FIELD *field, int frow, int fcol)
+{
+ FIELD *New_Field = (FIELD *)0;
+ int err = E_BAD_ARGUMENT;
+
+ T((T_CALLED("link_field(%p,%d,%d)"), (void *)field, frow, fcol));
+ if (field && (frow >= 0) && (fcol >= 0) &&
+ ((err = E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */
+ (New_Field = typeMalloc(FIELD, 1)))
+ {
+ T((T_CREATE("field %p"), (void *)New_Field));
+ *New_Field = *_nc_Default_Field;
+ New_Field->frow = frow;
+ New_Field->fcol = fcol;
+
+ New_Field->link = field->link;
+ field->link = New_Field;
+
+ New_Field->buf = field->buf;
+ New_Field->rows = field->rows;
+ New_Field->cols = field->cols;
+ New_Field->nrow = field->nrow;
+ New_Field->nbuf = field->nbuf;
+ New_Field->drows = field->drows;
+ New_Field->dcols = field->dcols;
+ New_Field->maxgrow = field->maxgrow;
+ New_Field->just = field->just;
+ New_Field->fore = field->fore;
+ New_Field->back = field->back;
+ New_Field->pad = field->pad;
+ New_Field->opts = field->opts;
+ New_Field->usrptr = field->usrptr;
+
+ if (_nc_Copy_Type(New_Field, field))
+ returnField(New_Field);
+ }
+
+ if (New_Field)
+ free_field(New_Field);
+
+ SET_ERROR(err);
+ returnField((FIELD *)0);
+}
+
+/* fld_link.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_max.c b/payloads/libpayload/curses/form/fld_max.c
new file mode 100644
index 0000000000..5ce918e4e0
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_max.c
@@ -0,0 +1,77 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_max.c,v 1.10 2010/01/23 21:14:36 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_max_field(FIELD *field, int maxgrow)
+|
+| Description : Set the maximum growth for a dynamic field. If maxgrow=0
+| the field may grow to any possible size.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid argument
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_max_field(FIELD *field, int maxgrow)
+{
+ T((T_CALLED("set_max_field(%p,%d)"), (void *)field, maxgrow));
+
+ if (!field || (maxgrow < 0))
+ RETURN(E_BAD_ARGUMENT);
+ else
+ {
+ bool single_line_field = Single_Line_Field(field);
+
+ if (maxgrow > 0)
+ {
+ if ((single_line_field && (maxgrow < field->dcols)) ||
+ (!single_line_field && (maxgrow < field->drows)))
+ RETURN(E_BAD_ARGUMENT);
+ }
+ field->maxgrow = maxgrow;
+ field->status &= ~_MAY_GROW;
+ if (!(field->opts & O_STATIC))
+ {
+ if ((maxgrow == 0) ||
+ (single_line_field && (field->dcols < maxgrow)) ||
+ (!single_line_field && (field->drows < maxgrow)))
+ field->status |= _MAY_GROW;
+ }
+ }
+ RETURN(E_OK);
+}
+
+/* fld_max.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_move.c b/payloads/libpayload/curses/form/fld_move.c
new file mode 100644
index 0000000000..dfba22d72a
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_move.c
@@ -0,0 +1,64 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_move.c,v 1.10 2010/01/23 21:14:36 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int move_field(FIELD *field,int frow, int fcol)
+|
+| Description : Moves the disconnected field to the new location in
+| the forms subwindow.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid argument passed
+| E_CONNECTED - field is connected
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+move_field(FIELD *field, int frow, int fcol)
+{
+ T((T_CALLED("move_field(%p,%d,%d)"), (void *)field, frow, fcol));
+
+ if (!field || (frow < 0) || (fcol < 0))
+ RETURN(E_BAD_ARGUMENT);
+
+ if (field->form)
+ RETURN(E_CONNECTED);
+
+ field->frow = frow;
+ field->fcol = fcol;
+ RETURN(E_OK);
+}
+
+/* fld_move.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_newftyp.c b/payloads/libpayload/curses/form/fld_newftyp.c
new file mode 100644
index 0000000000..4351aed6b3
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_newftyp.c
@@ -0,0 +1,143 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_newftyp.c,v 1.19 2010/01/23 21:14:36 tom Exp $")
+
+static FIELDTYPE default_fieldtype =
+{
+ 0, /* status */
+ 0L, /* reference count */
+ (FIELDTYPE *)0, /* pointer to left operand */
+ (FIELDTYPE *)0, /* pointer to right operand */
+ NULL, /* makearg function */
+ NULL, /* copyarg function */
+ NULL, /* freearg function */
+ INIT_FT_FUNC(NULL), /* field validation function */
+ INIT_FT_FUNC(NULL), /* Character check function */
+ INIT_FT_FUNC(NULL), /* enumerate next function */
+ INIT_FT_FUNC(NULL), /* enumerate previous function */
+#if NCURSES_INTEROP_FUNCS
+ NULL /* generic callback alternative to makearg */
+#endif
+};
+
+NCURSES_EXPORT_VAR(FIELDTYPE *)
+_nc_Default_FieldType = &default_fieldtype;
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : FIELDTYPE *new_fieldtype(
+| bool (* const field_check)(FIELD *,const void *),
+| bool (* const char_check) (int, const void *) )
+|
+| Description : Create a new fieldtype. The application programmer must
+| write a field_check and a char_check function and give
+| them as input to this call.
+| If an error occurs, errno is set to
+| E_BAD_ARGUMENT - invalid arguments
+| E_SYSTEM_ERROR - system error (no memory)
+|
+| Return Values : Fieldtype pointer or NULL if error occurred
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(FIELDTYPE *)
+new_fieldtype(bool (*const field_check) (FIELD *, const void *),
+ bool (*const char_check) (int, const void *))
+{
+ FIELDTYPE *nftyp = (FIELDTYPE *)0;
+
+ T((T_CALLED("new_fieldtype(%p,%p)"), field_check, char_check));
+ if ((field_check) || (char_check))
+ {
+ nftyp = typeMalloc(FIELDTYPE, 1);
+
+ if (nftyp)
+ {
+ T((T_CREATE("fieldtype %p"), (void *)nftyp));
+ *nftyp = default_fieldtype;
+#if NCURSES_INTEROP_FUNCS
+ nftyp->fieldcheck.ofcheck = field_check;
+ nftyp->charcheck.occheck = char_check;
+#else
+ nftyp->fcheck = field_check;
+ nftyp->ccheck = char_check;
+#endif
+ }
+ else
+ {
+ SET_ERROR(E_SYSTEM_ERROR);
+ }
+ }
+ else
+ {
+ SET_ERROR(E_BAD_ARGUMENT);
+ }
+ returnFieldType(nftyp);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int free_fieldtype(FIELDTYPE *typ)
+|
+| Description : Release the memory associated with this fieldtype.
+|
+| Return Values : E_OK - success
+| E_CONNECTED - there are fields referencing the type
+| E_BAD_ARGUMENT - invalid fieldtype pointer
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+free_fieldtype(FIELDTYPE *typ)
+{
+ T((T_CALLED("free_fieldtype(%p)"), (void *)typ));
+
+ if (!typ)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (typ->ref != 0)
+ RETURN(E_CONNECTED);
+
+ if (typ->status & _RESIDENT)
+ RETURN(E_CONNECTED);
+
+ if (typ->status & _LINKED_TYPE)
+ {
+ if (typ->left)
+ typ->left->ref--;
+ if (typ->right)
+ typ->right->ref--;
+ }
+ free(typ);
+ RETURN(E_OK);
+}
+
+/* fld_newftyp.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_opts.c b/payloads/libpayload/curses/form/fld_opts.c
new file mode 100644
index 0000000000..a52f1e2ad8
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_opts.c
@@ -0,0 +1,138 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_opts.c,v 1.12 2010/01/23 21:14:36 tom Exp $")
+
+/*----------------------------------------------------------------------------
+ Field-Options manipulation routines
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_field_opts(FIELD *field, Field_Options opts)
+|
+| Description : Turns on the named options for this field and turns
+| off all the remaining options.
+|
+| Return Values : E_OK - success
+| E_CURRENT - the field is the current field
+| E_BAD_ARGUMENT - invalid options
+| E_SYSTEM_ERROR - system error
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_field_opts(FIELD *field, Field_Options opts)
+{
+ int res = E_BAD_ARGUMENT;
+
+ T((T_CALLED("set_field_opts(%p,%d)"), (void *)field, opts));
+
+ opts &= ALL_FIELD_OPTS;
+ if (!(opts & ~ALL_FIELD_OPTS))
+ res = _nc_Synchronize_Options(Normalize_Field(field), opts);
+ RETURN(res);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : Field_Options field_opts(const FIELD *field)
+|
+| Description : Retrieve the fields options.
+|
+| Return Values : The options.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(Field_Options)
+field_opts(const FIELD *field)
+{
+ T((T_CALLED("field_opts(%p)"), (const void *)field));
+
+ returnCode(ALL_FIELD_OPTS & Normalize_Field(field)->opts);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int field_opts_on(FIELD *field, Field_Options opts)
+|
+| Description : Turns on the named options for this field and all the
+| remaining options are unchanged.
+|
+| Return Values : E_OK - success
+| E_CURRENT - the field is the current field
+| E_BAD_ARGUMENT - invalid options
+| E_SYSTEM_ERROR - system error
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+field_opts_on(FIELD *field, Field_Options opts)
+{
+ int res = E_BAD_ARGUMENT;
+
+ T((T_CALLED("field_opts_on(%p,%d)"), (void *)field, opts));
+
+ opts &= ALL_FIELD_OPTS;
+ if (!(opts & ~ALL_FIELD_OPTS))
+ {
+ Normalize_Field(field);
+ res = _nc_Synchronize_Options(field, field->opts | opts);
+ }
+ RETURN(res);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int field_opts_off(FIELD *field, Field_Options opts)
+|
+| Description : Turns off the named options for this field and all the
+| remaining options are unchanged.
+|
+| Return Values : E_OK - success
+| E_CURRENT - the field is the current field
+| E_BAD_ARGUMENT - invalid options
+| E_SYSTEM_ERROR - system error
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+field_opts_off(FIELD *field, Field_Options opts)
+{
+ int res = E_BAD_ARGUMENT;
+
+ T((T_CALLED("field_opts_off(%p,%d)"), (void *)field, opts));
+
+ opts &= ALL_FIELD_OPTS;
+ if (!(opts & ~ALL_FIELD_OPTS))
+ {
+ Normalize_Field(field);
+ res = _nc_Synchronize_Options(field, field->opts & ~opts);
+ }
+ RETURN(res);
+}
+
+/* fld_opts.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_pad.c b/payloads/libpayload/curses/form/fld_pad.c
new file mode 100644
index 0000000000..4f8ff1f54f
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_pad.c
@@ -0,0 +1,85 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_pad.c,v 1.10 2010/01/23 21:14:36 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_field_pad(FIELD *field, int ch)
+|
+| Description : Set the pad character used to fill the field. This must
+| be a printable character.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid field pointer or pad character
+| E_SYSTEM_ERROR - system error
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_field_pad(FIELD *field, int ch)
+{
+ int res = E_BAD_ARGUMENT;
+
+ T((T_CALLED("set_field_pad(%p,%d)"), (void *)field, ch));
+
+ Normalize_Field(field);
+ if (isprint(UChar(ch)))
+ {
+ if (field->pad != ch)
+ {
+ field->pad = ch;
+ res = _nc_Synchronize_Attributes(field);
+ }
+ else
+ res = E_OK;
+ }
+ RETURN(res);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int field_pad(const FIELD *field)
+|
+| Description : Retrieve the fields pad character.
+|
+| Return Values : The pad character.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+field_pad(const FIELD *field)
+{
+ T((T_CALLED("field_pad(%p)"), (const void *)field));
+
+ returnCode(Normalize_Field(field)->pad);
+}
+
+/* fld_pad.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_page.c b/payloads/libpayload/curses/form/fld_page.c
new file mode 100644
index 0000000000..e4d18c556b
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_page.c
@@ -0,0 +1,82 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_page.c,v 1.10 2010/01/23 21:14:36 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_new_page(FIELD *field, bool new_page_flag)
+|
+| Description : Marks the field as the beginning of a new page of
+| the form.
+|
+| Return Values : E_OK - success
+| E_CONNECTED - field is connected
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_new_page(FIELD *field, bool new_page_flag)
+{
+ T((T_CALLED("set_new_page(%p,%d)"), (void *)field, new_page_flag));
+
+ Normalize_Field(field);
+ if (field->form)
+ RETURN(E_CONNECTED);
+
+ if (new_page_flag)
+ field->status |= _NEWPAGE;
+ else
+ field->status &= ~_NEWPAGE;
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : bool new_page(const FIELD *field)
+|
+| Description : Retrieve the info whether or not the field starts a
+| new page on the form.
+|
+| Return Values : TRUE - field starts a new page
+| FALSE - field doesn't start a new page
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(bool)
+new_page(const FIELD *field)
+{
+ T((T_CALLED("new_page(%p)"), (const void *)field));
+
+ returnBool((Normalize_Field(field)->status & _NEWPAGE) ? TRUE : FALSE);
+}
+
+/* fld_page.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_stat.c b/payloads/libpayload/curses/form/fld_stat.c
new file mode 100644
index 0000000000..46f89e6748
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_stat.c
@@ -0,0 +1,79 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_stat.c,v 1.12 2010/01/23 21:14:36 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_field_status(FIELD *field, bool status)
+|
+| Description : Set or clear the 'changed' indication flag for that
+| fields primary buffer.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_field_status(FIELD *field, bool status)
+{
+ T((T_CALLED("set_field_status(%p,%d)"), (void *)field, status));
+
+ Normalize_Field(field);
+
+ if (status)
+ field->status |= _CHANGED;
+ else
+ field->status &= ~_CHANGED;
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : bool field_status(const FIELD *field)
+|
+| Description : Retrieve the value of the 'changed' indication flag
+| for that fields primary buffer.
+|
+| Return Values : TRUE - buffer has been changed
+| FALSE - buffer has not been changed
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(bool)
+field_status(const FIELD *field)
+{
+ T((T_CALLED("field_status(%p)"), (const void *)field));
+
+ returnBool((Normalize_Field(field)->status & _CHANGED) ? TRUE : FALSE);
+}
+
+/* fld_stat.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_type.c b/payloads/libpayload/curses/form/fld_type.c
new file mode 100644
index 0000000000..0b35b7eb9e
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_type.c
@@ -0,0 +1,97 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_type.c,v 1.16 2010/01/23 21:14:36 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_field_type(FIELD *field, FIELDTYPE *type,...)
+|
+| Description : Associate the specified fieldtype with the field.
+| Certain field types take additional arguments. Look
+| at the spec of the field types !
+|
+| Return Values : E_OK - success
+| E_SYSTEM_ERROR - system error
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_field_type(FIELD *field, FIELDTYPE *type,...)
+{
+ va_list ap;
+ int res = E_SYSTEM_ERROR;
+ int err = 0;
+
+ T((T_CALLED("set_field_type(%p,%p)"), (void *)field, (void *)type));
+
+ va_start(ap, type);
+
+ Normalize_Field(field);
+ _nc_Free_Type(field);
+
+ field->type = type;
+ field->arg = (void *)_nc_Make_Argument(field->type, &ap, &err);
+
+ if (err)
+ {
+ _nc_Free_Argument(field->type, (TypeArgument *)(field->arg));
+ field->type = (FIELDTYPE *)0;
+ field->arg = (void *)0;
+ }
+ else
+ {
+ res = E_OK;
+ if (field->type)
+ field->type->ref++;
+ }
+
+ va_end(ap);
+ RETURN(res);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : FIELDTYPE *field_type(const FIELD *field)
+|
+| Description : Retrieve the associated fieldtype for this field.
+|
+| Return Values : Pointer to fieldtype of NULL if none is defined.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(FIELDTYPE *)
+field_type(const FIELD *field)
+{
+ T((T_CALLED("field_type(%p)"), (const void *)field));
+ returnFieldType(Normalize_Field(field)->type);
+}
+
+/* fld_type.c ends here */
diff --git a/payloads/libpayload/curses/form/fld_user.c b/payloads/libpayload/curses/form/fld_user.c
new file mode 100644
index 0000000000..30bcf7a415
--- /dev/null
+++ b/payloads/libpayload/curses/form/fld_user.c
@@ -0,0 +1,72 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fld_user.c,v 1.16 2010/01/23 21:14:36 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_field_userptr(FIELD *field, void *usrptr)
+|
+| Description : Set the pointer that is reserved in any field to store
+| application relevant informations
+|
+| Return Values : E_OK - on success
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_field_userptr(FIELD *field, void *usrptr)
+{
+ T((T_CALLED("set_field_userptr(%p,%p)"), (void *)field, (void *)usrptr));
+
+ Normalize_Field(field)->usrptr = usrptr;
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : void *field_userptr(const FIELD *field)
+|
+| Description : Return the pointer that is reserved in any field to
+| store application relevant informations.
+|
+| Return Values : Value of pointer. If no such pointer has been set,
+| NULL is returned
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(void *)
+field_userptr(const FIELD *field)
+{
+ T((T_CALLED("field_userptr(%p)"), (const void *)field));
+ returnVoidPtr(Normalize_Field(field)->usrptr);
+}
+
+/* fld_user.c ends here */
diff --git a/payloads/libpayload/curses/form/form.h b/payloads/libpayload/curses/form/form.h
new file mode 100644
index 0000000000..d7bb85adf4
--- /dev/null
+++ b/payloads/libpayload/curses/form/form.h
@@ -0,0 +1,423 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2009 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/* $Id: form.h,v 0.21 2009/11/07 19:31:11 tom Exp $ */
+
+#ifndef FORM_H
+#define FORM_H
+
+#include <curses.h>
+#include <eti.h>
+#include <ncurses_cfg.h>
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#ifndef FORM_PRIV_H
+typedef void *FIELD_CELL;
+#endif
+
+#ifndef NCURSES_FIELD_INTERNALS
+#define NCURSES_FIELD_INTERNALS /* nothing */
+#endif
+
+typedef int Form_Options;
+typedef int Field_Options;
+
+ /**********
+ * _PAGE *
+ **********/
+
+typedef struct {
+ short pmin; /* index of first field on page */
+ short pmax; /* index of last field on page */
+ short smin; /* index of top leftmost field on page */
+ short smax; /* index of bottom rightmost field on page */
+} _PAGE;
+
+ /**********
+ * FIELD *
+ **********/
+
+typedef struct fieldnode {
+ unsigned short status; /* flags */
+ short rows; /* size in rows */
+ short cols; /* size in cols */
+ short frow; /* first row */
+ short fcol; /* first col */
+ int drows; /* dynamic rows */
+ int dcols; /* dynamic cols */
+ int maxgrow; /* maximum field growth */
+ int nrow; /* off-screen rows */
+ short nbuf; /* additional buffers */
+ short just; /* justification */
+ short page; /* page on form */
+ short index; /* into form -> field */
+ int pad; /* pad character */
+ chtype fore; /* foreground attribute */
+ chtype back; /* background attribute */
+ Field_Options opts; /* options */
+ struct fieldnode * snext; /* sorted order pointer */
+ struct fieldnode * sprev; /* sorted order pointer */
+ struct fieldnode * link; /* linked field chain */
+ struct formnode * form; /* containing form */
+ struct typenode * type; /* field type */
+ void * arg; /* argument for type */
+ FIELD_CELL * buf; /* field buffers */
+ void * usrptr; /* user pointer */
+ /*
+ * The wide-character configuration requires extra information. Because
+ * there are existing applications that manipulate the members of FIELD
+ * directly, we cannot make the struct opaque. Offsets of members up to
+ * this point are the same in the narrow- and wide-character configuration.
+ * But note that the type of buf depends on the configuration, and is made
+ * opaque for that reason.
+ */
+ NCURSES_FIELD_INTERNALS
+} FIELD;
+
+
+ /*********
+ * FORM *
+ *********/
+
+typedef struct formnode {
+ unsigned short status; /* flags */
+ short rows; /* size in rows */
+ short cols; /* size in cols */
+ int currow; /* current row in field window */
+ int curcol; /* current col in field window */
+ int toprow; /* in scrollable field window */
+ int begincol; /* in horiz. scrollable field */
+ short maxfield; /* number of fields */
+ short maxpage; /* number of pages */
+ short curpage; /* index into page */
+ Form_Options opts; /* options */
+ WINDOW * win; /* window */
+ WINDOW * sub; /* subwindow */
+ WINDOW * w; /* window for current field */
+ FIELD ** field; /* field [maxfield] */
+ FIELD * current; /* current field */
+ _PAGE * page; /* page [maxpage] */
+ void * usrptr; /* user pointer */
+
+ void (*forminit)(struct formnode *);
+ void (*formterm)(struct formnode *);
+ void (*fieldinit)(struct formnode *);
+ void (*fieldterm)(struct formnode *);
+
+} FORM;
+
+
+ /**************
+ * FIELDTYPE *
+ **************/
+
+typedef struct typenode {
+ unsigned short status; /* flags */
+ long ref; /* reference count */
+ struct typenode * left; /* ptr to operand for | */
+ struct typenode * right; /* ptr to operand for | */
+
+ void* (*makearg)(va_list *); /* make fieldtype arg */
+ void* (*copyarg)(const void *); /* copy fieldtype arg */
+ void (*freearg)(void *); /* free fieldtype arg */
+
+#if NCURSES_INTEROP_FUNCS
+ union {
+ bool (*ofcheck)(FIELD *,const void *); /* field validation */
+ bool (*gfcheck)(FORM*,FIELD *,const void*); /* generic field validation */
+ } fieldcheck;
+ union {
+ bool (*occheck)(int,const void *); /* character validation */
+ bool (*gccheck)(int,FORM*,
+ FIELD*,const void*); /* generic char validation */
+ } charcheck;
+ union {
+ bool (*onext)(FIELD *,const void *); /* enumerate next value */
+ bool (*gnext)(FORM*,FIELD*,const void*); /* generic enumerate next */
+ } enum_next;
+ union {
+ bool (*oprev)(FIELD *,const void *); /* enumerate prev value */
+ bool (*gprev)(FORM*,FIELD*,const void*); /* generic enumerate prev */
+ } enum_prev;
+ void* (*genericarg)(void*); /* Alternate Arg method */
+#else
+ bool (*fcheck)(FIELD *,const void *); /* field validation */
+ bool (*ccheck)(int,const void *); /* character validation */
+
+ bool (*next)(FIELD *,const void *); /* enumerate next value */
+ bool (*prev)(FIELD *,const void *); /* enumerate prev value */
+#endif
+} FIELDTYPE;
+
+typedef void (*Form_Hook)(FORM *);
+
+ /***************************
+ * miscellaneous #defines *
+ ***************************/
+
+/* field justification */
+#define NO_JUSTIFICATION (0)
+#define JUSTIFY_LEFT (1)
+#define JUSTIFY_CENTER (2)
+#define JUSTIFY_RIGHT (3)
+
+/* field options */
+#define O_VISIBLE (0x0001U)
+#define O_ACTIVE (0x0002U)
+#define O_PUBLIC (0x0004U)
+#define O_EDIT (0x0008U)
+#define O_WRAP (0x0010U)
+#define O_BLANK (0x0020U)
+#define O_AUTOSKIP (0x0040U)
+#define O_NULLOK (0x0080U)
+#define O_PASSOK (0x0100U)
+#define O_STATIC (0x0200U)
+
+/* form options */
+#define O_NL_OVERLOAD (0x0001U)
+#define O_BS_OVERLOAD (0x0002U)
+
+/* form driver commands */
+#define REQ_NEXT_PAGE (KEY_MAX + 1) /* move to next page */
+#define REQ_PREV_PAGE (KEY_MAX + 2) /* move to previous page */
+#define REQ_FIRST_PAGE (KEY_MAX + 3) /* move to first page */
+#define REQ_LAST_PAGE (KEY_MAX + 4) /* move to last page */
+
+#define REQ_NEXT_FIELD (KEY_MAX + 5) /* move to next field */
+#define REQ_PREV_FIELD (KEY_MAX + 6) /* move to previous field */
+#define REQ_FIRST_FIELD (KEY_MAX + 7) /* move to first field */
+#define REQ_LAST_FIELD (KEY_MAX + 8) /* move to last field */
+#define REQ_SNEXT_FIELD (KEY_MAX + 9) /* move to sorted next field */
+#define REQ_SPREV_FIELD (KEY_MAX + 10) /* move to sorted prev field */
+#define REQ_SFIRST_FIELD (KEY_MAX + 11) /* move to sorted first field */
+#define REQ_SLAST_FIELD (KEY_MAX + 12) /* move to sorted last field */
+#define REQ_LEFT_FIELD (KEY_MAX + 13) /* move to left to field */
+#define REQ_RIGHT_FIELD (KEY_MAX + 14) /* move to right to field */
+#define REQ_UP_FIELD (KEY_MAX + 15) /* move to up to field */
+#define REQ_DOWN_FIELD (KEY_MAX + 16) /* move to down to field */
+
+#define REQ_NEXT_CHAR (KEY_MAX + 17) /* move to next char in field */
+#define REQ_PREV_CHAR (KEY_MAX + 18) /* move to prev char in field */
+#define REQ_NEXT_LINE (KEY_MAX + 19) /* move to next line in field */
+#define REQ_PREV_LINE (KEY_MAX + 20) /* move to prev line in field */
+#define REQ_NEXT_WORD (KEY_MAX + 21) /* move to next word in field */
+#define REQ_PREV_WORD (KEY_MAX + 22) /* move to prev word in field */
+#define REQ_BEG_FIELD (KEY_MAX + 23) /* move to first char in field */
+#define REQ_END_FIELD (KEY_MAX + 24) /* move after last char in fld */
+#define REQ_BEG_LINE (KEY_MAX + 25) /* move to beginning of line */
+#define REQ_END_LINE (KEY_MAX + 26) /* move after last char in line */
+#define REQ_LEFT_CHAR (KEY_MAX + 27) /* move left in field */
+#define REQ_RIGHT_CHAR (KEY_MAX + 28) /* move right in field */
+#define REQ_UP_CHAR (KEY_MAX + 29) /* move up in field */
+#define REQ_DOWN_CHAR (KEY_MAX + 30) /* move down in field */
+
+#define REQ_NEW_LINE (KEY_MAX + 31) /* insert/overlay new line */
+#define REQ_INS_CHAR (KEY_MAX + 32) /* insert blank char at cursor */
+#define REQ_INS_LINE (KEY_MAX + 33) /* insert blank line at cursor */
+#define REQ_DEL_CHAR (KEY_MAX + 34) /* delete char at cursor */
+#define REQ_DEL_PREV (KEY_MAX + 35) /* delete char before cursor */
+#define REQ_DEL_LINE (KEY_MAX + 36) /* delete line at cursor */
+#define REQ_DEL_WORD (KEY_MAX + 37) /* delete word at cursor */
+#define REQ_CLR_EOL (KEY_MAX + 38) /* clear to end of line */
+#define REQ_CLR_EOF (KEY_MAX + 39) /* clear to end of field */
+#define REQ_CLR_FIELD (KEY_MAX + 40) /* clear entire field */
+#define REQ_OVL_MODE (KEY_MAX + 41) /* begin overlay mode */
+#define REQ_INS_MODE (KEY_MAX + 42) /* begin insert mode */
+#define REQ_SCR_FLINE (KEY_MAX + 43) /* scroll field forward a line */
+#define REQ_SCR_BLINE (KEY_MAX + 44) /* scroll field backward a line */
+#define REQ_SCR_FPAGE (KEY_MAX + 45) /* scroll field forward a page */
+#define REQ_SCR_BPAGE (KEY_MAX + 46) /* scroll field backward a page */
+#define REQ_SCR_FHPAGE (KEY_MAX + 47) /* scroll field forward half page */
+#define REQ_SCR_BHPAGE (KEY_MAX + 48) /* scroll field backward half page */
+#define REQ_SCR_FCHAR (KEY_MAX + 49) /* horizontal scroll char */
+#define REQ_SCR_BCHAR (KEY_MAX + 50) /* horizontal scroll char */
+#define REQ_SCR_HFLINE (KEY_MAX + 51) /* horizontal scroll line */
+#define REQ_SCR_HBLINE (KEY_MAX + 52) /* horizontal scroll line */
+#define REQ_SCR_HFHALF (KEY_MAX + 53) /* horizontal scroll half line */
+#define REQ_SCR_HBHALF (KEY_MAX + 54) /* horizontal scroll half line */
+
+#define REQ_VALIDATION (KEY_MAX + 55) /* validate field */
+#define REQ_NEXT_CHOICE (KEY_MAX + 56) /* display next field choice */
+#define REQ_PREV_CHOICE (KEY_MAX + 57) /* display prev field choice */
+
+#define MIN_FORM_COMMAND (KEY_MAX + 1) /* used by form_driver */
+#define MAX_FORM_COMMAND (KEY_MAX + 57) /* used by form_driver */
+
+#if defined(MAX_COMMAND)
+# if (MAX_FORM_COMMAND > MAX_COMMAND)
+# error Something is wrong -- MAX_FORM_COMMAND is greater than MAX_COMMAND
+# elif (MAX_COMMAND != (KEY_MAX + 128))
+# error Something is wrong -- MAX_COMMAND is already inconsistently defined.
+# endif
+#else
+# define MAX_COMMAND (KEY_MAX + 128)
+#endif
+
+ /*************************
+ * standard field types *
+ *************************/
+extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ALPHA;
+extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ALNUM;
+extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ENUM;
+extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_INTEGER;
+extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_NUMERIC;
+extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_REGEXP;
+
+ /************************************
+ * built-in additional field types *
+ * They are not defined in SVr4 *
+ ************************************/
+extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_IPV4; /* Internet IP Version 4 address */
+
+ /***********************
+ * FIELDTYPE routines *
+ ***********************/
+extern NCURSES_EXPORT(FIELDTYPE *) new_fieldtype (
+ bool (* const field_check)(FIELD *,const void *),
+ bool (* const char_check)(int,const void *));
+extern NCURSES_EXPORT(FIELDTYPE *) link_fieldtype(
+ FIELDTYPE *, FIELDTYPE *);
+
+extern NCURSES_EXPORT(int) free_fieldtype (FIELDTYPE *);
+extern NCURSES_EXPORT(int) set_fieldtype_arg (FIELDTYPE *,
+ void * (* const make_arg)(va_list *),
+ void * (* const copy_arg)(const void *),
+ void (* const free_arg)(void *));
+extern NCURSES_EXPORT(int) set_fieldtype_choice (FIELDTYPE *,
+ bool (* const next_choice)(FIELD *,const void *),
+ bool (* const prev_choice)(FIELD *,const void *));
+
+ /*******************
+ * FIELD routines *
+ *******************/
+extern NCURSES_EXPORT(FIELD *) new_field (int,int,int,int,int,int);
+extern NCURSES_EXPORT(FIELD *) dup_field (FIELD *,int,int);
+extern NCURSES_EXPORT(FIELD *) link_field (FIELD *,int,int);
+
+extern NCURSES_EXPORT(int) free_field (FIELD *);
+extern NCURSES_EXPORT(int) field_info (const FIELD *,int *,int *,int *,int *,int *,int *);
+extern NCURSES_EXPORT(int) dynamic_field_info (const FIELD *,int *,int *,int *);
+extern NCURSES_EXPORT(int) set_max_field ( FIELD *,int);
+extern NCURSES_EXPORT(int) move_field (FIELD *,int,int);
+extern NCURSES_EXPORT(int) set_field_type (FIELD *,FIELDTYPE *,...);
+extern NCURSES_EXPORT(int) set_new_page (FIELD *,bool);
+extern NCURSES_EXPORT(int) set_field_just (FIELD *,int);
+extern NCURSES_EXPORT(int) field_just (const FIELD *);
+extern NCURSES_EXPORT(int) set_field_fore (FIELD *,chtype);
+extern NCURSES_EXPORT(int) set_field_back (FIELD *,chtype);
+extern NCURSES_EXPORT(int) set_field_pad (FIELD *,int);
+extern NCURSES_EXPORT(int) field_pad (const FIELD *);
+extern NCURSES_EXPORT(int) set_field_buffer (FIELD *,int,const char *);
+extern NCURSES_EXPORT(int) set_field_status (FIELD *,bool);
+extern NCURSES_EXPORT(int) set_field_userptr (FIELD *, void *);
+extern NCURSES_EXPORT(int) set_field_opts (FIELD *,Field_Options);
+extern NCURSES_EXPORT(int) field_opts_on (FIELD *,Field_Options);
+extern NCURSES_EXPORT(int) field_opts_off (FIELD *,Field_Options);
+
+extern NCURSES_EXPORT(chtype) field_fore (const FIELD *);
+extern NCURSES_EXPORT(chtype) field_back (const FIELD *);
+
+extern NCURSES_EXPORT(bool) new_page (const FIELD *);
+extern NCURSES_EXPORT(bool) field_status (const FIELD *);
+
+extern NCURSES_EXPORT(void *) field_arg (const FIELD *);
+
+extern NCURSES_EXPORT(void *) field_userptr (const FIELD *);
+
+extern NCURSES_EXPORT(FIELDTYPE *) field_type (const FIELD *);
+
+extern NCURSES_EXPORT(char *) field_buffer (const FIELD *,int);
+
+extern NCURSES_EXPORT(Field_Options) field_opts (const FIELD *);
+
+ /******************
+ * FORM routines *
+ ******************/
+
+extern NCURSES_EXPORT(FORM *) new_form (FIELD **);
+
+extern NCURSES_EXPORT(FIELD **) form_fields (const FORM *);
+extern NCURSES_EXPORT(FIELD *) current_field (const FORM *);
+
+extern NCURSES_EXPORT(WINDOW *) form_win (const FORM *);
+extern NCURSES_EXPORT(WINDOW *) form_sub (const FORM *);
+
+extern NCURSES_EXPORT(Form_Hook) form_init (const FORM *);
+extern NCURSES_EXPORT(Form_Hook) form_term (const FORM *);
+extern NCURSES_EXPORT(Form_Hook) field_init (const FORM *);
+extern NCURSES_EXPORT(Form_Hook) field_term (const FORM *);
+
+extern NCURSES_EXPORT(int) free_form (FORM *);
+extern NCURSES_EXPORT(int) set_form_fields (FORM *,FIELD **);
+extern NCURSES_EXPORT(int) field_count (const FORM *);
+extern NCURSES_EXPORT(int) set_form_win (FORM *,WINDOW *);
+extern NCURSES_EXPORT(int) set_form_sub (FORM *,WINDOW *);
+extern NCURSES_EXPORT(int) set_current_field (FORM *,FIELD *);
+extern NCURSES_EXPORT(int) field_index (const FIELD *);
+extern NCURSES_EXPORT(int) set_form_page (FORM *,int);
+extern NCURSES_EXPORT(int) form_page (const FORM *);
+extern NCURSES_EXPORT(int) scale_form (const FORM *,int *,int *);
+extern NCURSES_EXPORT(int) set_form_init (FORM *,Form_Hook);
+extern NCURSES_EXPORT(int) set_form_term (FORM *,Form_Hook);
+extern NCURSES_EXPORT(int) set_field_init (FORM *,Form_Hook);
+extern NCURSES_EXPORT(int) set_field_term (FORM *,Form_Hook);
+extern NCURSES_EXPORT(int) post_form (FORM *);
+extern NCURSES_EXPORT(int) unpost_form (FORM *);
+extern NCURSES_EXPORT(int) pos_form_cursor (FORM *);
+extern NCURSES_EXPORT(int) form_driver (FORM *,int);
+extern NCURSES_EXPORT(int) set_form_userptr (FORM *,void *);
+extern NCURSES_EXPORT(int) set_form_opts (FORM *,Form_Options);
+extern NCURSES_EXPORT(int) form_opts_on (FORM *,Form_Options);
+extern NCURSES_EXPORT(int) form_opts_off (FORM *,Form_Options);
+extern NCURSES_EXPORT(int) form_request_by_name (const char *);
+
+extern NCURSES_EXPORT(const char *) form_request_name (int);
+
+extern NCURSES_EXPORT(void *) form_userptr (const FORM *);
+
+extern NCURSES_EXPORT(Form_Options) form_opts (const FORM *);
+
+extern NCURSES_EXPORT(bool) data_ahead (const FORM *);
+extern NCURSES_EXPORT(bool) data_behind (const FORM *);
+
+#if NCURSES_SP_FUNCS
+extern NCURSES_EXPORT(FORM *) NCURSES_SP_NAME(new_form) (SCREEN*, FIELD **);
+#endif
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* FORM_H */
diff --git a/payloads/libpayload/curses/form/form.priv.h b/payloads/libpayload/curses/form/form.priv.h
new file mode 100644
index 0000000000..91dc7a8285
--- /dev/null
+++ b/payloads/libpayload/curses/form/form.priv.h
@@ -0,0 +1,299 @@
+/****************************************************************************
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/* $Id: form.priv.h,v 0.32 2009/11/07 21:26:43 tom Exp $ */
+
+#ifndef FORM_PRIV_H
+#define FORM_PRIV_H 1
+
+#include "curspriv.h"
+#include "mf_common.h"
+
+#define UChar(c) ((unsigned char)(c))
+
+#if USE_WIDEC_SUPPORT
+#if HAVE_WCTYPE_H
+#include <wctype.h>
+#endif
+
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */
+#endif
+
+#define FIELD_CELL NCURSES_CH_T
+
+#define NCURSES_FIELD_INTERNALS char** expanded; WINDOW *working;
+#define NCURSES_FIELD_EXTENSION , (char **)0, (WINDOW *)0
+
+#else
+
+#define FIELD_CELL char
+
+#define NCURSES_FIELD_EXTENSION /* nothing */
+
+#endif
+
+#include "form.h"
+
+ /***********************
+ * Default objects *
+ ***********************/
+extern NCURSES_EXPORT_VAR(FORM *) _nc_Default_Form;
+extern NCURSES_EXPORT_VAR(FIELD *) _nc_Default_Field;
+extern NCURSES_EXPORT_VAR(FIELDTYPE *) _nc_Default_FieldType;
+
+/* form status values */
+#define _OVLMODE (0x04U) /* Form is in overlay mode */
+#define _WINDOW_MODIFIED (0x10U) /* Current field window has been modified */
+#define _FCHECK_REQUIRED (0x20U) /* Current field needs validation */
+
+/* field status values */
+#define _CHANGED (0x01U) /* Field has been changed */
+#define _NEWTOP (0x02U) /* Vertical scrolling occurred */
+#define _NEWPAGE (0x04U) /* field begins new page of form */
+#define _MAY_GROW (0x08U) /* dynamic field may still grow */
+
+/* fieldtype status values */
+#define _LINKED_TYPE (0x01U) /* Type is a linked type */
+#define _HAS_ARGS (0x02U) /* Type has arguments */
+#define _HAS_CHOICE (0x04U) /* Type has choice methods */
+#define _RESIDENT (0x08U) /* Type is built-in */
+#define _GENERIC (0x10U) /* A generic field type */
+
+/* This are the field options required to be a selectable field in field
+ navigation requests */
+#define O_SELECTABLE (O_ACTIVE | O_VISIBLE)
+
+/* If form is NULL replace form argument by default-form */
+#define Normalize_Form(form) \
+ ((form) = (form != 0) ? (form) : _nc_Default_Form)
+
+/* If field is NULL replace field argument by default-field */
+#define Normalize_Field(field) \
+ ((field) = (field != 0) ? (field) : _nc_Default_Field)
+
+#if NCURSES_SP_FUNCS
+#define Get_Form_Screen(form) \
+ ((form)->win ? _nc_screen_of((form->win)):CURRENT_SCREEN)
+#else
+#define Get_Form_Screen(form) CURRENT_SCREEN
+#endif
+
+/* Retrieve forms window */
+#define Get_Form_Window(form) \
+ ((form)->sub != NULL \
+ ? (form)->sub \
+ : ((form)->win != NULL \
+ ? (form)->win \
+ : StdScreen(Get_Form_Screen(form))))
+
+/* Calculate the size for a single buffer for this field */
+#define Buffer_Length(field) ((field)->drows * (field)->dcols)
+
+/* Calculate the total size of all buffers for this field */
+#define Total_Buffer_Size(field) \
+ ( (Buffer_Length(field) + 1) * (1+(field)->nbuf) * sizeof(FIELD_CELL) )
+
+/* Logic to determine whether or not a field is single lined */
+#define Single_Line_Field(field) \
+ (((field)->rows + (field)->nrow) == 1)
+
+/* Logic to determine whether or not a field is selectable */
+#define Field_Is_Selectable(f) (((unsigned)((f)->opts) & O_SELECTABLE)==O_SELECTABLE)
+#define Field_Is_Not_Selectable(f) (((unsigned)((f)->opts) & O_SELECTABLE)!=O_SELECTABLE)
+
+typedef struct typearg
+ {
+ struct typearg *left;
+ struct typearg *right;
+ }
+TypeArgument;
+
+/* This is a dummy request code (normally invalid) to be used internally
+ with the form_driver() routine to position to the first active field
+ on the form
+*/
+#define FIRST_ACTIVE_MAGIC (-291056)
+
+#define ALL_FORM_OPTS ( \
+ O_NL_OVERLOAD |\
+ O_BS_OVERLOAD )
+
+#define ALL_FIELD_OPTS (Field_Options)( \
+ O_VISIBLE |\
+ O_ACTIVE |\
+ O_PUBLIC |\
+ O_EDIT |\
+ O_WRAP |\
+ O_BLANK |\
+ O_AUTOSKIP|\
+ O_NULLOK |\
+ O_PASSOK |\
+ O_STATIC )
+
+#define C_BLANK ' '
+#define is_blank(c) ((c)==C_BLANK)
+
+#define C_ZEROS '\0'
+
+extern NCURSES_EXPORT(TypeArgument *) _nc_Make_Argument (const FIELDTYPE*, va_list*, int*);
+extern NCURSES_EXPORT(TypeArgument *) _nc_Copy_Argument (const FIELDTYPE*, const TypeArgument*, int*);
+extern NCURSES_EXPORT(void) _nc_Free_Argument (const FIELDTYPE*, TypeArgument*);
+extern NCURSES_EXPORT(bool) _nc_Copy_Type (FIELD*, FIELD const *);
+extern NCURSES_EXPORT(void) _nc_Free_Type (FIELD *);
+
+extern NCURSES_EXPORT(int) _nc_Synchronize_Attributes (FIELD*);
+extern NCURSES_EXPORT(int) _nc_Synchronize_Options (FIELD*, Field_Options);
+extern NCURSES_EXPORT(int) _nc_Set_Form_Page (FORM*, int, FIELD*);
+extern NCURSES_EXPORT(int) _nc_Refresh_Current_Field (FORM*);
+extern NCURSES_EXPORT(FIELD *) _nc_First_Active_Field (FORM*);
+extern NCURSES_EXPORT(bool) _nc_Internal_Validation (FORM*);
+extern NCURSES_EXPORT(int) _nc_Set_Current_Field (FORM*, FIELD*);
+extern NCURSES_EXPORT(int) _nc_Position_Form_Cursor (FORM*);
+
+#if NCURSES_INTEROP_FUNCS
+extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_INTEGER(void);
+extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_ALNUM(void);
+extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_ALPHA(void);
+extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_ENUM(void);
+extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_NUMERIC(void);
+extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_REGEXP(void);
+extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_IPV4(void);
+
+extern NCURSES_EXPORT(FIELDTYPE *)
+_nc_generic_fieldtype(bool (*const field_check) (FORM*,
+ FIELD *,
+ const void *),
+ bool (*const char_check) (int,
+ FORM*,
+ FIELD*,
+ const void *),
+ bool (*const next)(FORM*,FIELD*,const void*),
+ bool (*const prev)(FORM*,FIELD*,const void*),
+ void (*freecallback)(void*));
+extern NCURSES_EXPORT(int) _nc_set_generic_fieldtype(FIELD*, FIELDTYPE*, int (*)(void**));
+extern NCURSES_EXPORT(WINDOW*) _nc_form_cursor(const FORM* , int* , int* );
+
+#define INIT_FT_FUNC(func) {func}
+#else
+#define INIT_FT_FUNC(func) func
+#endif
+
+extern NCURSES_EXPORT(void) _nc_get_fieldbuffer(FORM*, FIELD*, FIELD_CELL*);
+
+#if USE_WIDEC_SUPPORT
+extern NCURSES_EXPORT(wchar_t *) _nc_Widen_String(char *, int *);
+#endif
+
+#ifdef TRACE
+
+#define returnField(code) TRACE_RETURN(code,field)
+#define returnFieldPtr(code) TRACE_RETURN(code,field_ptr)
+#define returnForm(code) TRACE_RETURN(code,form)
+#define returnFieldType(code) TRACE_RETURN(code,field_type)
+#define returnFormHook(code) TRACE_RETURN(code,form_hook)
+
+extern NCURSES_EXPORT(FIELD **) _nc_retrace_field_ptr (FIELD **);
+extern NCURSES_EXPORT(FIELD *) _nc_retrace_field (FIELD *);
+extern NCURSES_EXPORT(FIELDTYPE *) _nc_retrace_field_type (FIELDTYPE *);
+extern NCURSES_EXPORT(FORM *) _nc_retrace_form (FORM *);
+extern NCURSES_EXPORT(Form_Hook) _nc_retrace_form_hook (Form_Hook);
+
+#else /* !TRACE */
+
+#define returnFieldPtr(code) return code
+#define returnFieldType(code) return code
+#define returnField(code) return code
+#define returnForm(code) return code
+#define returnFormHook(code) return code
+
+#endif /* TRACE/!TRACE */
+
+/*
+ * Use Check_CTYPE_Field() to simplify FIELDTYPE's that use only the ccheck()
+ * function.
+ */
+#if USE_WIDEC_SUPPORT
+#define Check_CTYPE_Field(result, buffer, width, ccheck) \
+ while (*buffer && *buffer == ' ') \
+ buffer++; \
+ if (*buffer) \
+ { \
+ bool blank = FALSE; \
+ int len; \
+ int n; \
+ wchar_t *list = _nc_Widen_String((char *)buffer, &len); \
+ if (list != 0) \
+ { \
+ result = TRUE; \
+ for (n = 0; n < len; ++n) \
+ { \
+ if (blank) \
+ { \
+ if (list[n] != ' ') \
+ { \
+ result = FALSE; \
+ break; \
+ } \
+ } \
+ else if (list[n] == ' ') \
+ { \
+ blank = TRUE; \
+ result = (n + 1 >= width); \
+ } \
+ else if (!ccheck(list[n], NULL)) \
+ { \
+ result = FALSE; \
+ break; \
+ } \
+ } \
+ free(list); \
+ } \
+ }
+#else
+#define Check_CTYPE_Field(result, buffer, width, ccheck) \
+ while (*buffer && *buffer == ' ') \
+ buffer++; \
+ if (*buffer) \
+ { \
+ unsigned char *s = buffer; \
+ int l = -1; \
+ while (*buffer && ccheck(*buffer, NULL)) \
+ buffer++; \
+ l = (int)(buffer - s); \
+ while (*buffer && *buffer == ' ') \
+ buffer++; \
+ result = ((*buffer || (l < width)) ? FALSE : TRUE); \
+ }
+#endif
+
+#endif /* FORM_PRIV_H */
diff --git a/payloads/libpayload/curses/form/frm_cursor.c b/payloads/libpayload/curses/form/frm_cursor.c
new file mode 100644
index 0000000000..7a4cd16116
--- /dev/null
+++ b/payloads/libpayload/curses/form/frm_cursor.c
@@ -0,0 +1,70 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: frm_cursor.c,v 1.10 2010/01/23 21:14:36 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int pos_form_cursor(FORM * form)
+|
+| Description : Moves the form window cursor to the location required
+| by the form driver to resume form processing. This may
+| be needed after the application calls a curses library
+| I/O routine that modifies the cursor position.
+|
+| Return Values : E_OK - Success
+| E_SYSTEM_ERROR - System error.
+| E_BAD_ARGUMENT - Invalid form pointer
+| E_NOT_POSTED - Form is not posted
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+pos_form_cursor(FORM *form)
+{
+ int res;
+
+ T((T_CALLED("pos_form_cursor(%p)"), (void *)form));
+
+ if (!form)
+ res = E_BAD_ARGUMENT;
+ else
+ {
+ if (!(form->status & _POSTED))
+ res = E_NOT_POSTED;
+ else
+ res = _nc_Position_Form_Cursor(form);
+ }
+ RETURN(res);
+}
+
+/* frm_cursor.c ends here */
diff --git a/payloads/libpayload/curses/form/frm_data.c b/payloads/libpayload/curses/form/frm_data.c
new file mode 100644
index 0000000000..93917d5bbe
--- /dev/null
+++ b/payloads/libpayload/curses/form/frm_data.c
@@ -0,0 +1,193 @@
+/****************************************************************************
+ * Copyright (c) 1998-2005,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: frm_data.c,v 1.15 2010/01/23 21:14:36 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : bool data_behind(const FORM *form)
+|
+| Description : Check for off-screen data behind. This is nearly trivial
+| because the beginning of a field is fixed.
+|
+| Return Values : TRUE - there are off-screen data behind
+| FALSE - there are no off-screen data behind
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(bool)
+data_behind(const FORM *form)
+{
+ bool result = FALSE;
+
+ T((T_CALLED("data_behind(%p)"), (const void *)form));
+
+ if (form && (form->status & _POSTED) && form->current)
+ {
+ FIELD *field;
+
+ field = form->current;
+ if (!Single_Line_Field(field))
+ {
+ result = (form->toprow == 0) ? FALSE : TRUE;
+ }
+ else
+ {
+ result = (form->begincol == 0) ? FALSE : TRUE;
+ }
+ }
+ returnBool(result);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static char * Only_Padding(
+| WINDOW *w,
+| int len,
+| int pad)
+|
+| Description : Test if 'length' cells starting at the current position
+| contain a padding character.
+|
+| Return Values : true if only padding cells are found
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static bool
+Only_Padding(WINDOW *w, int len, int pad)
+{
+ bool result = TRUE;
+ int y, x, j;
+ FIELD_CELL cell;
+
+ getyx(w, y, x);
+ for (j = 0; j < len; ++j)
+ {
+ if (wmove(w, y, x + j) != ERR)
+ {
+#if USE_WIDEC_SUPPORT
+ if (win_wch(w, &cell) != ERR)
+ {
+ if ((chtype)CharOf(cell) != ChCharOf(pad)
+ || cell.chars[1] != 0)
+ {
+ result = FALSE;
+ break;
+ }
+ }
+#else
+ cell = winch(w);
+ if (ChCharOf(cell) != ChCharOf(pad))
+ {
+ result = FALSE;
+ break;
+ }
+#endif
+ }
+ else
+ {
+ /* if an error, return true: no non-padding text found */
+ break;
+ }
+ }
+ /* no need to reset the cursor position; caller does this */
+ return result;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : bool data_ahead(const FORM *form)
+|
+| Description : Check for off-screen data ahead. This is more difficult
+| because a dynamic field has a variable end.
+|
+| Return Values : TRUE - there are off-screen data ahead
+| FALSE - there are no off-screen data ahead
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(bool)
+data_ahead(const FORM *form)
+{
+ bool result = FALSE;
+
+ T((T_CALLED("data_ahead(%p)"), (const void *)form));
+
+ if (form && (form->status & _POSTED) && form->current)
+ {
+ FIELD *field;
+ bool cursor_moved = FALSE;
+ int pos;
+
+ field = form->current;
+ assert(form->w);
+
+ if (Single_Line_Field(field))
+ {
+ int check_len;
+
+ pos = form->begincol + field->cols;
+ while (pos < field->dcols)
+ {
+ check_len = field->dcols - pos;
+ if (check_len >= field->cols)
+ check_len = field->cols;
+ cursor_moved = TRUE;
+ wmove(form->w, 0, pos);
+ if (Only_Padding(form->w, check_len, field->pad))
+ pos += field->cols;
+ else
+ {
+ result = TRUE;
+ break;
+ }
+ }
+ }
+ else
+ {
+ pos = form->toprow + field->rows;
+ while (pos < field->drows)
+ {
+ cursor_moved = TRUE;
+ wmove(form->w, pos, 0);
+ pos++;
+ if (!Only_Padding(form->w, field->cols, field->pad))
+ {
+ result = TRUE;
+ break;
+ }
+ }
+ }
+
+ if (cursor_moved)
+ wmove(form->w, form->currow, form->curcol);
+ }
+ returnBool(result);
+}
+
+/* frm_data.c ends here */
diff --git a/payloads/libpayload/curses/form/frm_def.c b/payloads/libpayload/curses/form/frm_def.c
new file mode 100644
index 0000000000..86500f2398
--- /dev/null
+++ b/payloads/libpayload/curses/form/frm_def.c
@@ -0,0 +1,448 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: frm_def.c,v 1.25 2010/01/23 21:14:36 tom Exp $")
+
+/* this can't be readonly */
+static FORM default_form =
+{
+ 0, /* status */
+ 0, /* rows */
+ 0, /* cols */
+ 0, /* currow */
+ 0, /* curcol */
+ 0, /* toprow */
+ 0, /* begincol */
+ -1, /* maxfield */
+ -1, /* maxpage */
+ -1, /* curpage */
+ ALL_FORM_OPTS, /* opts */
+ (WINDOW *)0, /* win */
+ (WINDOW *)0, /* sub */
+ (WINDOW *)0, /* w */
+ (FIELD **)0, /* field */
+ (FIELD *)0, /* current */
+ (_PAGE *) 0, /* page */
+ (char *)0, /* usrptr */
+ NULL, /* forminit */
+ NULL, /* formterm */
+ NULL, /* fieldinit */
+ NULL /* fieldterm */
+};
+
+NCURSES_EXPORT_VAR(FORM *) _nc_Default_Form = &default_form;
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static FIELD *Insert_Field_By_Position(
+| FIELD *new_field,
+| FIELD *head )
+|
+| Description : Insert new_field into sorted fieldlist with head "head"
+| and return new head of sorted fieldlist. Sorting
+| criteria is (row,column). This is a circular list.
+|
+| Return Values : New head of sorted fieldlist
++--------------------------------------------------------------------------*/
+static FIELD *
+Insert_Field_By_Position(FIELD *newfield, FIELD *head)
+{
+ FIELD *current, *newhead;
+
+ assert(newfield);
+
+ if (!head)
+ { /* empty list is trivial */
+ newhead = newfield->snext = newfield->sprev = newfield;
+ }
+ else
+ {
+ newhead = current = head;
+ while ((current->frow < newfield->frow) ||
+ ((current->frow == newfield->frow) &&
+ (current->fcol < newfield->fcol)))
+ {
+ current = current->snext;
+ if (current == head)
+ { /* We cycled through. Reset head to indicate that */
+ head = (FIELD *)0;
+ break;
+ }
+ }
+ /* we leave the loop with current pointing to the field after newfield */
+ newfield->snext = current;
+ newfield->sprev = current->sprev;
+ newfield->snext->sprev = newfield;
+ newfield->sprev->snext = newfield;
+ if (current == head)
+ newhead = newfield;
+ }
+ return (newhead);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void Disconnect_Fields(FORM *form)
+|
+| Description : Break association between form and array of fields.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+static void
+Disconnect_Fields(FORM *form)
+{
+ if (form->field)
+ {
+ FIELD **fields;
+
+ for (fields = form->field; *fields; fields++)
+ {
+ if (form == (*fields)->form)
+ (*fields)->form = (FORM *)0;
+ }
+
+ form->rows = form->cols = 0;
+ form->maxfield = form->maxpage = -1;
+ form->field = (FIELD **)0;
+ if (form->page)
+ free(form->page);
+ form->page = (_PAGE *) 0;
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int Connect_Fields(FORM *form, FIELD **fields)
+|
+| Description : Set association between form and array of fields.
+|
+| Return Values : E_OK - no error
+| E_CONNECTED - a field is already connected
+| E_BAD_ARGUMENT - Invalid form pointer or field array
+| E_SYSTEM_ERROR - not enough memory
++--------------------------------------------------------------------------*/
+static int
+Connect_Fields(FORM *form, FIELD **fields)
+{
+ int field_cnt, j;
+ int page_nr;
+ int maximum_row_in_field, maximum_col_in_field;
+ _PAGE *pg;
+
+ T((T_CALLED("Connect_Fields(%p,%p)"), (void *)form, (void *)fields));
+
+ assert(form);
+
+ form->field = fields;
+ form->maxfield = 0;
+ form->maxpage = 0;
+
+ if (!fields)
+ RETURN(E_OK);
+
+ page_nr = 0;
+ /* store formpointer in fields and count pages */
+ for (field_cnt = 0; fields[field_cnt]; field_cnt++)
+ {
+ if (fields[field_cnt]->form)
+ RETURN(E_CONNECTED);
+ if (field_cnt == 0 ||
+ (fields[field_cnt]->status & _NEWPAGE))
+ page_nr++;
+ fields[field_cnt]->form = form;
+ }
+ if (field_cnt == 0 || (short)field_cnt < 0)
+ RETURN(E_BAD_ARGUMENT);
+
+ /* allocate page structures */
+ if ((pg = typeMalloc(_PAGE, page_nr)) != (_PAGE *) 0)
+ {
+ T((T_CREATE("_PAGE %p"), (void *)pg));
+ form->page = pg;
+ }
+ else
+ RETURN(E_SYSTEM_ERROR);
+
+ /* Cycle through fields and calculate page boundaries as well as
+ size of the form */
+ for (j = 0; j < field_cnt; j++)
+ {
+ if (j == 0)
+ pg->pmin = j;
+ else
+ {
+ if (fields[j]->status & _NEWPAGE)
+ {
+ pg->pmax = j - 1;
+ pg++;
+ pg->pmin = j;
+ }
+ }
+
+ maximum_row_in_field = fields[j]->frow + fields[j]->rows;
+ maximum_col_in_field = fields[j]->fcol + fields[j]->cols;
+
+ if (form->rows < maximum_row_in_field)
+ form->rows = maximum_row_in_field;
+ if (form->cols < maximum_col_in_field)
+ form->cols = maximum_col_in_field;
+ }
+
+ pg->pmax = field_cnt - 1;
+ form->maxfield = field_cnt;
+ form->maxpage = page_nr;
+
+ /* Sort fields on form pages */
+ for (page_nr = 0; page_nr < form->maxpage; page_nr++)
+ {
+ FIELD *fld = (FIELD *)0;
+
+ for (j = form->page[page_nr].pmin; j <= form->page[page_nr].pmax; j++)
+ {
+ fields[j]->index = j;
+ fields[j]->page = page_nr;
+ fld = Insert_Field_By_Position(fields[j], fld);
+ }
+ if (fld)
+ {
+ form->page[page_nr].smin = fld->index;
+ form->page[page_nr].smax = fld->sprev->index;
+ }
+ else
+ {
+ form->page[page_nr].smin = 0;
+ form->page[page_nr].smax = 0;
+ }
+ }
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int Associate_Fields(FORM *form, FIELD **fields)
+|
+| Description : Set association between form and array of fields.
+| If there are fields, position to first active field.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - Invalid form pointer or field array
+| E_CONNECTED - a field is already connected
+| E_SYSTEM_ERROR - not enough memory
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static int
+Associate_Fields(FORM *form, FIELD **fields)
+{
+ int res = Connect_Fields(form, fields);
+
+ if (res == E_OK)
+ {
+ if (form->maxpage > 0)
+ {
+ form->curpage = 0;
+ form_driver(form, FIRST_ACTIVE_MAGIC);
+ }
+ else
+ {
+ form->curpage = -1;
+ form->current = (FIELD *)0;
+ }
+ }
+ return (res);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : FORM *new_form_sp(SCREEN* sp, FIELD** fields )
+|
+| Description : Create new form with given array of fields.
+|
+| Return Values : Pointer to form. NULL if error occurred.
+! Set errno:
+| E_OK - success
+| E_BAD_ARGUMENT - Invalid form pointer or field array
+| E_CONNECTED - a field is already connected
+| E_SYSTEM_ERROR - not enough memory
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(FORM *)
+NCURSES_SP_NAME(new_form) (NCURSES_SP_DCLx FIELD **fields)
+{
+ int err = E_SYSTEM_ERROR;
+ FORM *form = (FORM *)0;
+
+ T((T_CALLED("new_form(%p,%p)"), (void *)SP_PARM, (void *)fields));
+
+ if (IsValidScreen(SP_PARM))
+ {
+ form = typeMalloc(FORM, 1);
+
+ if (form)
+ {
+ T((T_CREATE("form %p"), (void *)form));
+ *form = *_nc_Default_Form;
+ /* This ensures win and sub are always non-null,
+ so we can derive always the SCREEN that this form is
+ running on. */
+ form->win = StdScreen(SP_PARM);
+ form->sub = StdScreen(SP_PARM);
+ if ((err = Associate_Fields(form, fields)) != E_OK)
+ {
+ free_form(form);
+ form = (FORM *)0;
+ }
+ }
+ }
+
+ if (!form)
+ SET_ERROR(err);
+
+ returnForm(form);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : FORM* new_form(FIELD** fields )
+|
+| Description : Create new form with given array of fields.
+|
+| Return Values : Pointer to form. NULL if error occurred.
+! Set errno:
+| E_OK - success
+| E_BAD_ARGUMENT - Invalid form pointer or field array
+| E_CONNECTED - a field is already connected
+| E_SYSTEM_ERROR - not enough memory
++--------------------------------------------------------------------------*/
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(FORM *)
+new_form(FIELD **fields)
+{
+ return NCURSES_SP_NAME(new_form) (CURRENT_SCREEN, fields);
+}
+#endif
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int free_form( FORM *form )
+|
+| Description : Release internal memory associated with form.
+|
+| Return Values : E_OK - no error
+| E_BAD_ARGUMENT - invalid form pointer
+| E_POSTED - form is posted
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+free_form(FORM *form)
+{
+ T((T_CALLED("free_form(%p)"), (void *)form));
+
+ if (!form)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (form->status & _POSTED)
+ RETURN(E_POSTED);
+
+ Disconnect_Fields(form);
+ if (form->page)
+ free(form->page);
+ free(form);
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_form_fields( FORM *form, FIELD **fields )
+|
+| Description : Set a new association of an array of fields to a form
+|
+| Return Values : E_OK - no error
+| E_BAD_ARGUMENT - Invalid form pointer or field array
+| E_CONNECTED - a field is already connected
+| E_POSTED - form is posted
+| E_SYSTEM_ERROR - not enough memory
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_form_fields(FORM *form, FIELD **fields)
+{
+ FIELD **old;
+ int res;
+
+ T((T_CALLED("set_form_fields(%p,%p)"), (void *)form, (void *)fields));
+
+ if (!form)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (form->status & _POSTED)
+ RETURN(E_POSTED);
+
+ old = form->field;
+ Disconnect_Fields(form);
+
+ if ((res = Associate_Fields(form, fields)) != E_OK)
+ Connect_Fields(form, old);
+
+ RETURN(res);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : FIELD **form_fields( const FORM *form )
+|
+| Description : Retrieve array of fields
+|
+| Return Values : Pointer to field array
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(FIELD **)
+form_fields(const FORM *form)
+{
+ T((T_CALLED("form_field(%p)"), (const void *)form));
+ returnFieldPtr(Normalize_Form(form)->field);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int field_count( const FORM *form )
+|
+| Description : Retrieve number of fields
+|
+| Return Values : Number of fields, -1 if none are defined
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+field_count(const FORM *form)
+{
+ T((T_CALLED("field_count(%p)"), (const void *)form));
+
+ returnCode(Normalize_Form(form)->maxfield);
+}
+
+/* frm_def.c ends here */
diff --git a/payloads/libpayload/curses/form/frm_driver.c b/payloads/libpayload/curses/form/frm_driver.c
new file mode 100644
index 0000000000..e0892bf8d4
--- /dev/null
+++ b/payloads/libpayload/curses/form/frm_driver.c
@@ -0,0 +1,4646 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: frm_driver.c,v 1.98 2010/05/01 21:11:43 tom Exp $")
+
+/*----------------------------------------------------------------------------
+ This is the core module of the form library. It contains the majority
+ of the driver routines as well as the form_driver function.
+
+ Essentially this module is nearly the whole library. This is because
+ all the functions in this module depends on some others in the module,
+ so it makes no sense to split them into separate files because they
+ will always be linked together. The only acceptable concern is turnaround
+ time for this module, but now we have all Pentiums or RISCs, so what!
+
+ The driver routines are grouped into nine generic categories:
+
+ a) Page Navigation ( all functions prefixed by PN_ )
+ The current page of the form is left and some new page is
+ entered.
+ b) Inter-Field Navigation ( all functions prefixed by FN_ )
+ The current field of the form is left and some new field is
+ entered.
+ c) Intra-Field Navigation ( all functions prefixed by IFN_ )
+ The current position in the current field is changed.
+ d) Vertical Scrolling ( all functions prefixed by VSC_ )
+ Essentially this is a specialization of Intra-Field navigation.
+ It has to check for a multi-line field.
+ e) Horizontal Scrolling ( all functions prefixed by HSC_ )
+ Essentially this is a specialization of Intra-Field navigation.
+ It has to check for a single-line field.
+ f) Field Editing ( all functions prefixed by FE_ )
+ The content of the current field is changed
+ g) Edit Mode requests ( all functions prefixed by EM_ )
+ Switching between insert and overlay mode
+ h) Field-Validation requests ( all functions prefixed by FV_ )
+ Perform verifications of the field.
+ i) Choice requests ( all functions prefixed by CR_ )
+ Requests to enumerate possible field values
+ --------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+ Some remarks on the placements of assert() macros :
+ I use them only on "strategic" places, i.e. top level entries where
+ I want to make sure that things are set correctly. Throughout subordinate
+ routines I omit them mostly.
+ --------------------------------------------------------------------------*/
+
+/*
+Some options that may effect compatibility in behavior to SVr4 forms,
+but they are here to allow a more intuitive and user friendly behavior of
+our form implementation. This doesn't affect the API, so we feel it is
+uncritical.
+
+The initial implementation tries to stay very close with the behavior
+of the original SVr4 implementation, although in some areas it is quite
+clear that this isn't the most appropriate way. As far as possible this
+sources will allow you to build a forms lib that behaves quite similar
+to SVr4, but now and in the future we will give you better options.
+Perhaps at some time we will make this configurable at runtime.
+*/
+
+/* Implement a more user-friendly previous/next word behavior */
+#define FRIENDLY_PREV_NEXT_WORD (1)
+/* Fix the wrong behavior for forms with all fields inactive */
+#define FIX_FORM_INACTIVE_BUG (1)
+/* Allow dynamic field growth also when navigating past the end */
+#define GROW_IF_NAVIGATE (1)
+
+#if USE_WIDEC_SUPPORT
+#define myADDNSTR(w, s, n) wadd_wchnstr(w, s, n)
+#define myINSNSTR(w, s, n) wins_wchnstr(w, s, n)
+#define myINNSTR(w, s, n) fix_wchnstr(w, s, n)
+#define myWCWIDTH(w, y, x) cell_width(w, y, x)
+#else
+#define myADDNSTR(w, s, n) waddnstr(w, s, n)
+#define myINSNSTR(w, s, n) winsnstr(w, s, n)
+#define myINNSTR(w, s, n) winnstr(w, s, n)
+#define myWCWIDTH(w, y, x) 1
+#endif
+
+/*----------------------------------------------------------------------------
+ Forward references to some internally used static functions
+ --------------------------------------------------------------------------*/
+static int Inter_Field_Navigation(int (*const fct) (FORM *), FORM *form);
+static int FN_Next_Field(FORM *form);
+static int FN_Previous_Field(FORM *form);
+static int FE_New_Line(FORM *);
+static int FE_Delete_Previous(FORM *);
+
+/*----------------------------------------------------------------------------
+ Macro Definitions.
+
+ Some Remarks on that: I use the convention to use UPPERCASE for constants
+ defined by Macros. If I provide a macro as a kind of inline routine to
+ provide some logic, I use my Upper_Lower case style.
+ --------------------------------------------------------------------------*/
+
+/* Calculate the position of a single row in a field buffer */
+#define Position_Of_Row_In_Buffer(field,row) ((row)*(field)->dcols)
+
+/* Calculate start address for the fields buffer# N */
+#define Address_Of_Nth_Buffer(field,N) \
+ ((field)->buf + (N)*(1+Buffer_Length(field)))
+
+/* Calculate the start address of the row in the fields specified buffer# N */
+#define Address_Of_Row_In_Nth_Buffer(field,N,row) \
+ (Address_Of_Nth_Buffer(field,N) + Position_Of_Row_In_Buffer(field,row))
+
+/* Calculate the start address of the row in the fields primary buffer */
+#define Address_Of_Row_In_Buffer(field,row) \
+ Address_Of_Row_In_Nth_Buffer(field,0,row)
+
+/* Calculate the start address of the row in the forms current field
+ buffer# N */
+#define Address_Of_Current_Row_In_Nth_Buffer(form,N) \
+ Address_Of_Row_In_Nth_Buffer((form)->current,N,(form)->currow)
+
+/* Calculate the start address of the row in the forms current field
+ primary buffer */
+#define Address_Of_Current_Row_In_Buffer(form) \
+ Address_Of_Current_Row_In_Nth_Buffer(form,0)
+
+/* Calculate the address of the cursor in the forms current field
+ primary buffer */
+#define Address_Of_Current_Position_In_Nth_Buffer(form,N) \
+ (Address_Of_Current_Row_In_Nth_Buffer(form,N) + (form)->curcol)
+
+/* Calculate the address of the cursor in the forms current field
+ buffer# N */
+#define Address_Of_Current_Position_In_Buffer(form) \
+ Address_Of_Current_Position_In_Nth_Buffer(form,0)
+
+/* Logic to decide whether or not a field is actually a field with
+ vertical or horizontal scrolling */
+#define Is_Scroll_Field(field) \
+ (((field)->drows > (field)->rows) || \
+ ((field)->dcols > (field)->cols))
+
+/* Logic to decide whether or not a field needs to have an individual window
+ instead of a derived window because it contains invisible parts.
+ This is true for non-public fields and for scrollable fields. */
+#define Has_Invisible_Parts(field) \
+ (!((field)->opts & O_PUBLIC) || \
+ Is_Scroll_Field(field))
+
+/* Logic to decide whether or not a field needs justification */
+#define Justification_Allowed(field) \
+ (((field)->just != NO_JUSTIFICATION) && \
+ (Single_Line_Field(field)) && \
+ (((field)->dcols == (field)->cols) && \
+ ((field)->opts & O_STATIC)) )
+
+/* Logic to determine whether or not a dynamic field may still grow */
+#define Growable(field) ((field)->status & _MAY_GROW)
+
+/* Macro to set the attributes for a fields window */
+#define Set_Field_Window_Attributes(field,win) \
+( wbkgdset((win),(chtype)((field)->pad | (field)->back)), \
+ (void) wattrset((win),(field)->fore) )
+
+/* Logic to decide whether or not a field really appears on the form */
+#define Field_Really_Appears(field) \
+ ((field->form) &&\
+ (field->form->status & _POSTED) &&\
+ (field->opts & O_VISIBLE) &&\
+ (field->page == field->form->curpage))
+
+/* Logic to determine whether or not we are on the first position in the
+ current field */
+#define First_Position_In_Current_Field(form) \
+ (((form)->currow==0) && ((form)->curcol==0))
+
+#define Minimum(a,b) (((a)<=(b)) ? (a) : (b))
+#define Maximum(a,b) (((a)>=(b)) ? (a) : (b))
+
+/*----------------------------------------------------------------------------
+ Useful constants
+ --------------------------------------------------------------------------*/
+static FIELD_CELL myBLANK = BLANK;
+static FIELD_CELL myZEROS;
+
+#ifdef TRACE
+static void
+check_pos(FORM *form, int lineno)
+{
+ int y, x;
+
+ if (form && form->w)
+ {
+ getyx(form->w, y, x);
+ if (y != form->currow || x != form->curcol)
+ {
+ T(("CHECKPOS %s@%d have position %d,%d vs want %d,%d",
+ __FILE__, lineno,
+ y, x,
+ form->currow, form->curcol));
+ }
+ }
+}
+#define CHECKPOS(form) check_pos(form, __LINE__)
+#else
+#define CHECKPOS(form) /* nothing */
+#endif
+
+/*----------------------------------------------------------------------------
+ Wide-character special functions
+ --------------------------------------------------------------------------*/
+#if USE_WIDEC_SUPPORT
+/* like winsnstr */
+static int
+wins_wchnstr(WINDOW *w, cchar_t *s, int n)
+{
+ int code = ERR;
+ int y, x;
+
+ while (n-- > 0)
+ {
+ getyx(w, y, x);
+ if ((code = wins_wch(w, s++)) != OK)
+ break;
+ if ((code = wmove(w, y, x + 1)) != OK)
+ break;
+ }
+ return code;
+}
+
+/* win_wchnstr is inconsistent with winnstr, since it returns OK rather than
+ * the number of items transferred.
+ */
+static int
+fix_wchnstr(WINDOW *w, cchar_t *s, int n)
+{
+ int x;
+
+ win_wchnstr(w, s, n);
+ /*
+ * This function is used to extract the text only from the window.
+ * Strip attributes and color from the string so they will not be added
+ * back when copying the string to the window.
+ */
+ for (x = 0; x < n; ++x)
+ {
+ RemAttr(s[x], A_ATTRIBUTES);
+ SetPair(s[x], 0);
+ }
+ return n;
+}
+
+/*
+ * Returns the column of the base of the given cell.
+ */
+static int
+cell_base(WINDOW *win, int y, int x)
+{
+ int result = x;
+
+ while (LEGALYX(win, y, x))
+ {
+ cchar_t *data = &(win->_line[y].text[x]);
+
+ if (isWidecBase(CHDEREF(data)) || !isWidecExt(CHDEREF(data)))
+ {
+ result = x;
+ break;
+ }
+ --x;
+ }
+ return result;
+}
+
+/*
+ * Returns the number of columns needed for the given cell in a window.
+ */
+static int
+cell_width(WINDOW *win, int y, int x)
+{
+ int result = 1;
+
+ if (LEGALYX(win, y, x))
+ {
+ cchar_t *data = &(win->_line[y].text[x]);
+
+ if (isWidecExt(CHDEREF(data)))
+ {
+ /* recur, providing the number of columns to the next character */
+ result = cell_width(win, y, x - 1);
+ }
+ else
+ {
+ result = wcwidth(CharOf(CHDEREF(data)));
+ }
+ }
+ return result;
+}
+
+/*
+ * There is no wide-character function such as wdel_wch(), so we must find
+ * all of the cells that comprise a multi-column character and delete them
+ * one-by-one.
+ */
+static void
+delete_char(FORM *form)
+{
+ int cells = cell_width(form->w, form->currow, form->curcol);
+
+ form->curcol = cell_base(form->w, form->currow, form->curcol);
+ wmove(form->w, form->currow, form->curcol);
+ while (cells-- > 0)
+ {
+ wdelch(form->w);
+ }
+}
+#define DeleteChar(form) delete_char(form)
+#else
+#define DeleteChar(form) \
+ wmove((form)->w, (form)->currow, (form)->curcol), \
+ wdelch((form)->w)
+#endif
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static char *Get_Start_Of_Data(char * buf, int blen)
+|
+| Description : Return pointer to first non-blank position in buffer.
+| If buffer is empty return pointer to buffer itself.
+|
+| Return Values : Pointer to first non-blank position in buffer
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static FIELD_CELL *
+Get_Start_Of_Data(FIELD_CELL *buf, int blen)
+{
+ FIELD_CELL *p = buf;
+ FIELD_CELL *end = &buf[blen];
+
+ assert(buf && blen >= 0);
+ while ((p < end) && ISBLANK(*p))
+ p++;
+ return ((p == end) ? buf : p);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static char *After_End_Of_Data(char * buf, int blen)
+|
+| Description : Return pointer after last non-blank position in buffer.
+| If buffer is empty, return pointer to buffer itself.
+|
+| Return Values : Pointer to position after last non-blank position in
+| buffer.
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static FIELD_CELL *
+After_End_Of_Data(FIELD_CELL *buf, int blen)
+{
+ FIELD_CELL *p = &buf[blen];
+
+ assert(buf && blen >= 0);
+ while ((p > buf) && ISBLANK(p[-1]))
+ p--;
+ return (p);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static char *Get_First_Whitespace_Character(
+| char * buf, int blen)
+|
+| Description : Position to the first whitespace character.
+|
+| Return Values : Pointer to first whitespace character in buffer.
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static FIELD_CELL *
+Get_First_Whitespace_Character(FIELD_CELL *buf, int blen)
+{
+ FIELD_CELL *p = buf;
+ FIELD_CELL *end = &p[blen];
+
+ assert(buf && blen >= 0);
+ while ((p < end) && !ISBLANK(*p))
+ p++;
+ return ((p == end) ? buf : p);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static char *After_Last_Whitespace_Character(
+| char * buf, int blen)
+|
+| Description : Get the position after the last whitespace character.
+|
+| Return Values : Pointer to position after last whitespace character in
+| buffer.
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static FIELD_CELL *
+After_Last_Whitespace_Character(FIELD_CELL *buf, int blen)
+{
+ FIELD_CELL *p = &buf[blen];
+
+ assert(buf && blen >= 0);
+ while ((p > buf) && !ISBLANK(p[-1]))
+ p--;
+ return (p);
+}
+
+/* Set this to 1 to use the div_t version. This is a good idea if your
+ compiler has an intrinsic div() support. Unfortunately GNU-C has it
+ not yet.
+ N.B.: This only works if form->curcol follows immediately form->currow
+ and both are of type int.
+*/
+#define USE_DIV_T (0)
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void Adjust_Cursor_Position(
+| FORM * form, const char * pos)
+|
+| Description : Set current row and column of the form to values
+| corresponding to the buffer position.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static void
+Adjust_Cursor_Position(FORM *form, const FIELD_CELL *pos)
+{
+ FIELD *field;
+ int idx;
+
+ field = form->current;
+ assert(pos >= field->buf && field->dcols > 0);
+ idx = (int)(pos - field->buf);
+#if USE_DIV_T
+ *((div_t *) & (form->currow)) = div(idx, field->dcols);
+#else
+ form->currow = idx / field->dcols;
+ form->curcol = idx - field->cols * form->currow;
+#endif
+ if (field->drows < form->currow)
+ form->currow = 0;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void Buffer_To_Window(
+| const FIELD * field,
+| WINDOW * win)
+|
+| Description : Copy the buffer to the window. If it is a multi-line
+| field, the buffer is split to the lines of the
+| window without any editing.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+static void
+Buffer_To_Window(const FIELD *field, WINDOW *win)
+{
+ int width, height;
+ int y, x;
+ int len;
+ int row;
+ FIELD_CELL *pBuffer;
+
+ assert(win && field);
+
+ getyx(win, y, x);
+ width = getmaxx(win);
+ height = getmaxy(win);
+
+ for (row = 0, pBuffer = field->buf;
+ row < height;
+ row++, pBuffer += width)
+ {
+ if ((len = (int)(After_End_Of_Data(pBuffer, width) - pBuffer)) > 0)
+ {
+ wmove(win, row, 0);
+ myADDNSTR(win, pBuffer, len);
+ }
+ }
+ wmove(win, y, x);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : void _nc_get_fieldbuffer(
+| WINDOW * win,
+| FIELD * field,
+| FIELD_CELL * buf)
+|
+| Description : Copy the content of the window into the buffer.
+| The multiple lines of a window are simply
+| concatenated into the buffer. Pad characters in
+| the window will be replaced by blanks in the buffer.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(void)
+_nc_get_fieldbuffer(FORM *form, FIELD *field, FIELD_CELL *buf)
+{
+ int pad;
+ int len = 0;
+ FIELD_CELL *p;
+ int row, height;
+ WINDOW *win;
+
+ assert(form && field && buf);
+
+ win = form->w;
+ assert(win);
+
+ pad = field->pad;
+ p = buf;
+ height = getmaxy(win);
+
+ for (row = 0; (row < height) && (row < field->drows); row++)
+ {
+ wmove(win, row, 0);
+ len += myINNSTR(win, p + len, field->dcols);
+ }
+ p[len] = myZEROS;
+
+ /* replace visual padding character by blanks in buffer */
+ if (pad != C_BLANK)
+ {
+ int i;
+
+ for (i = 0; i < len; i++, p++)
+ {
+ if ((unsigned long)CharOf(*p) == ChCharOf(pad)
+#if USE_WIDEC_SUPPORT
+ && p->chars[1] == 0
+#endif
+ )
+ *p = myBLANK;
+ }
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void Window_To_Buffer(
+| FORM * form,
+| FIELD * field)
+|
+| Description : Copy the content of the window into the buffer.
+| The multiple lines of a window are simply
+| concatenated into the buffer. Pad characters in
+| the window will be replaced by blanks in the buffer.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+static void
+Window_To_Buffer(FORM *form, FIELD *field)
+{
+ _nc_get_fieldbuffer(form, field, field->buf);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void Synchronize_Buffer(FORM * form)
+|
+| Description : If there was a change, copy the content of the
+| window into the buffer, so the buffer is synchronized
+| with the windows content. We have to indicate that the
+| buffer needs validation due to the change.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static void
+Synchronize_Buffer(FORM *form)
+{
+ if (form->status & _WINDOW_MODIFIED)
+ {
+ form->status &= ~_WINDOW_MODIFIED;
+ form->status |= _FCHECK_REQUIRED;
+ Window_To_Buffer(form, form->current);
+ wmove(form->w, form->currow, form->curcol);
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Field_Grown( FIELD *field, int amount)
+|
+| Description : This function is called for growable dynamic fields
+| only. It has to increase the buffers and to allocate
+| a new window for this field.
+| This function has the side effect to set a new
+| field-buffer pointer, the dcols and drows values
+| as well as a new current Window for the field.
+|
+| Return Values : TRUE - field successfully increased
+| FALSE - there was some error
++--------------------------------------------------------------------------*/
+static bool
+Field_Grown(FIELD *field, int amount)
+{
+ bool result = FALSE;
+
+ if (field && Growable(field))
+ {
+ bool single_line_field = Single_Line_Field(field);
+ int old_buflen = Buffer_Length(field);
+ int new_buflen;
+ int old_dcols = field->dcols;
+ int old_drows = field->drows;
+ FIELD_CELL *oldbuf = field->buf;
+ FIELD_CELL *newbuf;
+
+ int growth;
+ FORM *form = field->form;
+ bool need_visual_update = ((form != (FORM *)0) &&
+ (form->status & _POSTED) &&
+ (form->current == field));
+
+ if (need_visual_update)
+ Synchronize_Buffer(form);
+
+ if (single_line_field)
+ {
+ growth = field->cols * amount;
+ if (field->maxgrow)
+ growth = Minimum(field->maxgrow - field->dcols, growth);
+ field->dcols += growth;
+ if (field->dcols == field->maxgrow)
+ field->status &= ~_MAY_GROW;
+ }
+ else
+ {
+ growth = (field->rows + field->nrow) * amount;
+ if (field->maxgrow)
+ growth = Minimum(field->maxgrow - field->drows, growth);
+ field->drows += growth;
+ if (field->drows == field->maxgrow)
+ field->status &= ~_MAY_GROW;
+ }
+ /* drows, dcols changed, so we get really the new buffer length */
+ new_buflen = Buffer_Length(field);
+ newbuf = (FIELD_CELL *)malloc(Total_Buffer_Size(field));
+ if (!newbuf)
+ {
+ /* restore to previous state */
+ field->dcols = old_dcols;
+ field->drows = old_drows;
+ if ((single_line_field && (field->dcols != field->maxgrow)) ||
+ (!single_line_field && (field->drows != field->maxgrow)))
+ field->status |= _MAY_GROW;
+ }
+ else
+ {
+ /* Copy all the buffers. This is the reason why we can't just use
+ * realloc().
+ */
+ int i, j;
+ FIELD_CELL *old_bp;
+ FIELD_CELL *new_bp;
+
+ result = TRUE; /* allow sharing of recovery on failure */
+
+ T((T_CREATE("fieldcell %p"), (void *)newbuf));
+ field->buf = newbuf;
+ for (i = 0; i <= field->nbuf; i++)
+ {
+ new_bp = Address_Of_Nth_Buffer(field, i);
+ old_bp = oldbuf + i * (1 + old_buflen);
+ for (j = 0; j < old_buflen; ++j)
+ new_bp[j] = old_bp[j];
+ while (j < new_buflen)
+ new_bp[j++] = myBLANK;
+ new_bp[new_buflen] = myZEROS;
+ }
+
+#if USE_WIDEC_SUPPORT && NCURSES_EXT_FUNCS
+ if (wresize(field->working, 1, Buffer_Length(field) + 1) == ERR)
+ result = FALSE;
+#endif
+
+ if (need_visual_update && result)
+ {
+ WINDOW *new_window = newpad(field->drows, field->dcols);
+
+ if (new_window != 0)
+ {
+ assert(form != (FORM *)0);
+ if (form->w)
+ delwin(form->w);
+ form->w = new_window;
+ Set_Field_Window_Attributes(field, form->w);
+ werase(form->w);
+ Buffer_To_Window(field, form->w);
+ untouchwin(form->w);
+ wmove(form->w, form->currow, form->curcol);
+ }
+ else
+ result = FALSE;
+ }
+
+ if (result)
+ {
+ free(oldbuf);
+ /* reflect changes in linked fields */
+ if (field != field->link)
+ {
+ FIELD *linked_field;
+
+ for (linked_field = field->link;
+ linked_field != field;
+ linked_field = linked_field->link)
+ {
+ linked_field->buf = field->buf;
+ linked_field->drows = field->drows;
+ linked_field->dcols = field->dcols;
+ }
+ }
+ }
+ else
+ {
+ /* restore old state */
+ field->dcols = old_dcols;
+ field->drows = old_drows;
+ field->buf = oldbuf;
+ if ((single_line_field &&
+ (field->dcols != field->maxgrow)) ||
+ (!single_line_field &&
+ (field->drows != field->maxgrow)))
+ field->status |= _MAY_GROW;
+ free(newbuf);
+ }
+ }
+ }
+ return (result);
+}
+
+#ifdef NCURSES_MOUSE_VERSION
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int Field_encloses(FIELD *field, int ry, int rx)
+|
+| Description : Check if the given coordinates lie within the given field.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid form pointer
+| E_SYSTEM_ERROR - form has no current field or
+| field-window
++--------------------------------------------------------------------------*/
+static int
+Field_encloses(FIELD *field, int ry, int rx)
+{
+ T((T_CALLED("Field_encloses(%p)"), (void *)field));
+ if (field != 0
+ && field->frow <= ry
+ && (field->frow + field->rows) > ry
+ && field->fcol <= rx
+ && (field->fcol + field->cols) > rx)
+ {
+ RETURN(E_OK);
+ }
+ RETURN(E_INVALID_FIELD);
+}
+#endif
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int _nc_Position_Form_Cursor(FORM * form)
+|
+| Description : Position the cursor in the window for the current
+| field to be in sync. with the currow and curcol
+| values.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid form pointer
+| E_SYSTEM_ERROR - form has no current field or
+| field-window
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+_nc_Position_Form_Cursor(FORM *form)
+{
+ FIELD *field;
+ WINDOW *formwin;
+
+ if (!form)
+ return (E_BAD_ARGUMENT);
+
+ if (!form->w || !form->current)
+ return (E_SYSTEM_ERROR);
+
+ field = form->current;
+ formwin = Get_Form_Window(form);
+
+ wmove(form->w, form->currow, form->curcol);
+ if (Has_Invisible_Parts(field))
+ {
+ /* in this case fieldwin isn't derived from formwin, so we have
+ to move the cursor in formwin by hand... */
+ wmove(formwin,
+ field->frow + form->currow - form->toprow,
+ field->fcol + form->curcol - form->begincol);
+ wcursyncup(formwin);
+ }
+ else
+ wcursyncup(form->w);
+ return (E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int _nc_Refresh_Current_Field(FORM * form)
+|
+| Description : Propagate the changes in the fields window to the
+| window of the form.
+|
+| Return Values : E_OK - on success
+| E_BAD_ARGUMENT - invalid form pointer
+| E_SYSTEM_ERROR - general error
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+_nc_Refresh_Current_Field(FORM *form)
+{
+ WINDOW *formwin;
+ FIELD *field;
+
+ T((T_CALLED("_nc_Refresh_Current_Field(%p)"), (void *)form));
+
+ if (!form)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (!form->w || !form->current)
+ RETURN(E_SYSTEM_ERROR);
+
+ field = form->current;
+ formwin = Get_Form_Window(form);
+
+ if (field->opts & O_PUBLIC)
+ {
+ if (Is_Scroll_Field(field))
+ {
+ /* Again, in this case the fieldwin isn't derived from formwin,
+ so we have to perform a copy operation. */
+ if (Single_Line_Field(field))
+ {
+ /* horizontal scrolling */
+ if (form->curcol < form->begincol)
+ form->begincol = form->curcol;
+ else
+ {
+ if (form->curcol >= (form->begincol + field->cols))
+ form->begincol = form->curcol - field->cols + 1;
+ }
+ copywin(form->w,
+ formwin,
+ 0,
+ form->begincol,
+ field->frow,
+ field->fcol,
+ field->frow,
+ field->cols + field->fcol - 1,
+ 0);
+ }
+ else
+ {
+ /* A multi-line, i.e. vertical scrolling field */
+ int row_after_bottom, first_modified_row, first_unmodified_row;
+
+ if (field->drows > field->rows)
+ {
+ row_after_bottom = form->toprow + field->rows;
+ if (form->currow < form->toprow)
+ {
+ form->toprow = form->currow;
+ field->status |= _NEWTOP;
+ }
+ if (form->currow >= row_after_bottom)
+ {
+ form->toprow = form->currow - field->rows + 1;
+ field->status |= _NEWTOP;
+ }
+ if (field->status & _NEWTOP)
+ {
+ /* means we have to copy whole range */
+ first_modified_row = form->toprow;
+ first_unmodified_row = first_modified_row + field->rows;
+ field->status &= ~_NEWTOP;
+ }
+ else
+ {
+ /* we try to optimize : finding the range of touched
+ lines */
+ first_modified_row = form->toprow;
+ while (first_modified_row < row_after_bottom)
+ {
+ if (is_linetouched(form->w, first_modified_row))
+ break;
+ first_modified_row++;
+ }
+ first_unmodified_row = first_modified_row;
+ while (first_unmodified_row < row_after_bottom)
+ {
+ if (!is_linetouched(form->w, first_unmodified_row))
+ break;
+ first_unmodified_row++;
+ }
+ }
+ }
+ else
+ {
+ first_modified_row = form->toprow;
+ first_unmodified_row = first_modified_row + field->rows;
+ }
+ if (first_unmodified_row != first_modified_row)
+ copywin(form->w,
+ formwin,
+ first_modified_row,
+ 0,
+ field->frow + first_modified_row - form->toprow,
+ field->fcol,
+ field->frow + first_unmodified_row - form->toprow - 1,
+ field->cols + field->fcol - 1,
+ 0);
+ }
+ wsyncup(formwin);
+ }
+ else
+ {
+ /* if the field-window is simply a derived window, i.e. contains no
+ * invisible parts, the whole thing is trivial
+ */
+ wsyncup(form->w);
+ }
+ }
+ untouchwin(form->w);
+ returnCode(_nc_Position_Form_Cursor(form));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void Perform_Justification(
+| FIELD * field,
+| WINDOW * win)
+|
+| Description : Output field with requested justification
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+static void
+Perform_Justification(FIELD *field, WINDOW *win)
+{
+ FIELD_CELL *bp;
+ int len;
+ int col = 0;
+
+ bp = Get_Start_Of_Data(field->buf, Buffer_Length(field));
+ len = (int)(After_End_Of_Data(field->buf, Buffer_Length(field)) - bp);
+
+ if (len > 0)
+ {
+ assert(win && (field->drows == 1) && (field->dcols == field->cols));
+
+ switch (field->just)
+ {
+ case JUSTIFY_LEFT:
+ break;
+ case JUSTIFY_CENTER:
+ col = (field->cols - len) / 2;
+ break;
+ case JUSTIFY_RIGHT:
+ col = field->cols - len;
+ break;
+ default:
+ break;
+ }
+
+ wmove(win, 0, col);
+ myADDNSTR(win, bp, len);
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void Undo_Justification(
+| FIELD * field,
+| WINDOW * win)
+|
+| Description : Display field without any justification, i.e.
+| left justified
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+static void
+Undo_Justification(FIELD *field, WINDOW *win)
+{
+ FIELD_CELL *bp;
+ int len;
+
+ bp = Get_Start_Of_Data(field->buf, Buffer_Length(field));
+ len = (int)(After_End_Of_Data(field->buf, Buffer_Length(field)) - bp);
+
+ if (len > 0)
+ {
+ assert(win);
+ wmove(win, 0, 0);
+ myADDNSTR(win, bp, len);
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Check_Char(FORM *form,
+| FIELD *field,
+| FIELDTYPE * typ,
+| int ch,
+| TypeArgument *argp)
+|
+| Description : Perform a single character check for character ch
+| according to the fieldtype instance.
+|
+| Return Values : TRUE - Character is valid
+| FALSE - Character is invalid
++--------------------------------------------------------------------------*/
+static bool
+Check_Char(FORM *form,
+ FIELD *field,
+ FIELDTYPE *typ,
+ int ch,
+ TypeArgument *argp)
+{
+ if (typ)
+ {
+ if (typ->status & _LINKED_TYPE)
+ {
+ assert(argp);
+ return (
+ Check_Char(form, field, typ->left, ch, argp->left) ||
+ Check_Char(form, field, typ->right, ch, argp->right));
+ }
+ else
+ {
+#if NCURSES_INTEROP_FUNCS
+ if (typ->charcheck.occheck)
+ {
+ if (typ->status & _GENERIC)
+ return typ->charcheck.gccheck(ch, form, field, (void *)argp);
+ else
+ return typ->charcheck.occheck(ch, (void *)argp);
+ }
+#else
+ if (typ->ccheck)
+ return typ->ccheck(ch, (void *)argp);
+#endif
+ }
+ }
+ return (!iscntrl(UChar(ch)) ? TRUE : FALSE);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int Display_Or_Erase_Field(
+| FIELD * field,
+| bool bEraseFlag)
+|
+| Description : Create a subwindow for the field and display the
+| buffer contents (apply justification if required)
+| or simply erase the field.
+|
+| Return Values : E_OK - on success
+| E_SYSTEM_ERROR - some error (typical no memory)
++--------------------------------------------------------------------------*/
+static int
+Display_Or_Erase_Field(FIELD *field, bool bEraseFlag)
+{
+ WINDOW *win;
+ WINDOW *fwin;
+
+ if (!field)
+ return E_SYSTEM_ERROR;
+
+ fwin = Get_Form_Window(field->form);
+ win = derwin(fwin,
+ field->rows, field->cols, field->frow, field->fcol);
+
+ if (!win)
+ return E_SYSTEM_ERROR;
+ else
+ {
+ if (field->opts & O_VISIBLE)
+ {
+ Set_Field_Window_Attributes(field, win);
+ }
+ else
+ {
+ (void)wattrset(win, WINDOW_ATTRS(fwin));
+ }
+ werase(win);
+ }
+
+ if (!bEraseFlag)
+ {
+ if (field->opts & O_PUBLIC)
+ {
+ if (Justification_Allowed(field))
+ Perform_Justification(field, win);
+ else
+ Buffer_To_Window(field, win);
+ }
+ field->status &= ~_NEWTOP;
+ }
+ wsyncup(win);
+ delwin(win);
+ return E_OK;
+}
+
+/* Macros to preset the bEraseFlag */
+#define Display_Field(field) Display_Or_Erase_Field(field,FALSE)
+#define Erase_Field(field) Display_Or_Erase_Field(field,TRUE)
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int Synchronize_Field(FIELD * field)
+|
+| Description : Synchronize the windows content with the value in
+| the buffer.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid field pointer
+| E_SYSTEM_ERROR - some severe basic error
++--------------------------------------------------------------------------*/
+static int
+Synchronize_Field(FIELD *field)
+{
+ FORM *form;
+ int res = E_OK;
+
+ if (!field)
+ return (E_BAD_ARGUMENT);
+
+ if (((form = field->form) != (FORM *)0)
+ && Field_Really_Appears(field))
+ {
+ if (field == form->current)
+ {
+ form->currow = form->curcol = form->toprow = form->begincol = 0;
+ werase(form->w);
+
+ if ((field->opts & O_PUBLIC) && Justification_Allowed(field))
+ Undo_Justification(field, form->w);
+ else
+ Buffer_To_Window(field, form->w);
+
+ field->status |= _NEWTOP;
+ res = _nc_Refresh_Current_Field(form);
+ }
+ else
+ res = Display_Field(field);
+ }
+ field->status |= _CHANGED;
+ return (res);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int Synchronize_Linked_Fields(FIELD * field)
+|
+| Description : Propagate the Synchronize_Field function to all linked
+| fields. The first error that occurs in the sequence
+| of updates is the return value.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid field pointer
+| E_SYSTEM_ERROR - some severe basic error
++--------------------------------------------------------------------------*/
+static int
+Synchronize_Linked_Fields(FIELD *field)
+{
+ FIELD *linked_field;
+ int res = E_OK;
+ int syncres;
+
+ if (!field)
+ return (E_BAD_ARGUMENT);
+
+ if (!field->link)
+ return (E_SYSTEM_ERROR);
+
+ for (linked_field = field->link;
+ linked_field != field;
+ linked_field = linked_field->link)
+ {
+ if (((syncres = Synchronize_Field(linked_field)) != E_OK) &&
+ (res == E_OK))
+ res = syncres;
+ }
+ return (res);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int _nc_Synchronize_Attributes(FIELD * field)
+|
+| Description : If a fields visual attributes have changed, this
+| routine is called to propagate those changes to the
+| screen.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid field pointer
+| E_SYSTEM_ERROR - some severe basic error
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+_nc_Synchronize_Attributes(FIELD *field)
+{
+ FORM *form;
+ int res = E_OK;
+ WINDOW *formwin;
+
+ T((T_CALLED("_nc_Synchronize_Attributes(%p)"), (void *)field));
+
+ if (!field)
+ returnCode(E_BAD_ARGUMENT);
+
+ CHECKPOS(field->form);
+ if (((form = field->form) != (FORM *)0)
+ && Field_Really_Appears(field))
+ {
+ if (form->current == field)
+ {
+ Synchronize_Buffer(form);
+ Set_Field_Window_Attributes(field, form->w);
+ werase(form->w);
+ wmove(form->w, form->currow, form->curcol);
+
+ if (field->opts & O_PUBLIC)
+ {
+ if (Justification_Allowed(field))
+ Undo_Justification(field, form->w);
+ else
+ Buffer_To_Window(field, form->w);
+ }
+ else
+ {
+ formwin = Get_Form_Window(form);
+ copywin(form->w, formwin,
+ 0, 0,
+ field->frow, field->fcol,
+ field->rows - 1, field->cols - 1, 0);
+ wsyncup(formwin);
+ Buffer_To_Window(field, form->w);
+ field->status |= _NEWTOP; /* fake refresh to paint all */
+ _nc_Refresh_Current_Field(form);
+ }
+ }
+ else
+ {
+ res = Display_Field(field);
+ }
+ }
+ CHECKPOS(form);
+ returnCode(res);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int _nc_Synchronize_Options(FIELD * field,
+| Field_Options newopts)
+|
+| Description : If a fields options have changed, this routine is
+| called to propagate these changes to the screen and
+| to really change the behavior of the field.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid field pointer
+| E_CURRENT - field is the current one
+| E_SYSTEM_ERROR - some severe basic error
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+_nc_Synchronize_Options(FIELD *field, Field_Options newopts)
+{
+ Field_Options oldopts;
+ Field_Options changed_opts;
+ FORM *form;
+ int res = E_OK;
+
+ T((T_CALLED("_nc_Synchronize_Options(%p,%#x)"), (void *)field, newopts));
+
+ if (!field)
+ returnCode(E_BAD_ARGUMENT);
+
+ oldopts = field->opts;
+ changed_opts = oldopts ^ newopts;
+ field->opts = newopts;
+ form = field->form;
+
+ if (form)
+ {
+ if (form->status & _POSTED)
+ {
+ if (form->current == field)
+ {
+ field->opts = oldopts;
+ returnCode(E_CURRENT);
+ }
+ if ((form->curpage == field->page))
+ {
+ if (changed_opts & O_VISIBLE)
+ {
+ if (newopts & O_VISIBLE)
+ res = Display_Field(field);
+ else
+ res = Erase_Field(field);
+ }
+ else
+ {
+ if ((changed_opts & O_PUBLIC) &&
+ (newopts & O_VISIBLE))
+ res = Display_Field(field);
+ }
+ }
+ }
+ }
+
+ if (changed_opts & O_STATIC)
+ {
+ bool single_line_field = Single_Line_Field(field);
+ int res2 = E_OK;
+
+ if (newopts & O_STATIC)
+ {
+ /* the field becomes now static */
+ field->status &= ~_MAY_GROW;
+ /* if actually we have no hidden columns, justification may
+ occur again */
+ if (single_line_field &&
+ (field->cols == field->dcols) &&
+ (field->just != NO_JUSTIFICATION) &&
+ Field_Really_Appears(field))
+ {
+ res2 = Display_Field(field);
+ }
+ }
+ else
+ {
+ /* field is no longer static */
+ if ((field->maxgrow == 0) ||
+ (single_line_field && (field->dcols < field->maxgrow)) ||
+ (!single_line_field && (field->drows < field->maxgrow)))
+ {
+ field->status |= _MAY_GROW;
+ /* a field with justification now changes its behavior,
+ so we must redisplay it */
+ if (single_line_field &&
+ (field->just != NO_JUSTIFICATION) &&
+ Field_Really_Appears(field))
+ {
+ res2 = Display_Field(field);
+ }
+ }
+ }
+ if (res2 != E_OK)
+ res = res2;
+ }
+
+ returnCode(res);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int _nc_Set_Current_Field(FORM * form,
+| FIELD * newfield)
+|
+| Description : Make the newfield the new current field.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid form or field pointer
+| E_SYSTEM_ERROR - some severe basic error
+| E_NOT_CONNECTED - no fields are connected to the form
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+_nc_Set_Current_Field(FORM *form, FIELD *newfield)
+{
+ FIELD *field;
+ WINDOW *new_window;
+
+ T((T_CALLED("_nc_Set_Current_Field(%p,%p)"), (void *)form, (void *)newfield));
+
+ if (!form || !newfield || !form->current || (newfield->form != form))
+ returnCode(E_BAD_ARGUMENT);
+
+ if ((form->status & _IN_DRIVER))
+ returnCode(E_BAD_STATE);
+
+ if (!(form->field))
+ returnCode(E_NOT_CONNECTED);
+
+ field = form->current;
+
+ if ((field != newfield) ||
+ !(form->status & _POSTED))
+ {
+ if ((form->w) &&
+ (field->opts & O_VISIBLE) &&
+ (field->form->curpage == field->page))
+ {
+ _nc_Refresh_Current_Field(form);
+ if (field->opts & O_PUBLIC)
+ {
+ if (field->drows > field->rows)
+ {
+ if (form->toprow == 0)
+ field->status &= ~_NEWTOP;
+ else
+ field->status |= _NEWTOP;
+ }
+ else
+ {
+ if (Justification_Allowed(field))
+ {
+ Window_To_Buffer(form, field);
+ werase(form->w);
+ Perform_Justification(field, form->w);
+ wsyncup(form->w);
+ }
+ }
+ }
+ delwin(form->w);
+ form->w = (WINDOW *)0;
+ }
+
+ field = newfield;
+
+ if (Has_Invisible_Parts(field))
+ new_window = newpad(field->drows, field->dcols);
+ else
+ new_window = derwin(Get_Form_Window(form),
+ field->rows, field->cols, field->frow, field->fcol);
+
+ if (!new_window)
+ returnCode(E_SYSTEM_ERROR);
+
+ form->current = field;
+
+ if (form->w)
+ delwin(form->w);
+ form->w = new_window;
+
+ form->status &= ~_WINDOW_MODIFIED;
+ Set_Field_Window_Attributes(field, form->w);
+
+ if (Has_Invisible_Parts(field))
+ {
+ werase(form->w);
+ Buffer_To_Window(field, form->w);
+ }
+ else
+ {
+ if (Justification_Allowed(field))
+ {
+ werase(form->w);
+ Undo_Justification(field, form->w);
+ wsyncup(form->w);
+ }
+ }
+
+ untouchwin(form->w);
+ }
+
+ form->currow = form->curcol = form->toprow = form->begincol = 0;
+ returnCode(E_OK);
+}
+
+/*----------------------------------------------------------------------------
+ Intra-Field Navigation routines
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int IFN_Next_Character(FORM * form)
+|
+| Description : Move to the next character in the field. In a multi-line
+| field this wraps at the end of the line.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - at the rightmost position
++--------------------------------------------------------------------------*/
+static int
+IFN_Next_Character(FORM *form)
+{
+ FIELD *field = form->current;
+ int step = myWCWIDTH(form->w, form->currow, form->curcol);
+
+ T((T_CALLED("IFN_Next_Character(%p)"), (void *)form));
+ if ((form->curcol += step) == field->dcols)
+ {
+ if ((++(form->currow)) == field->drows)
+ {
+#if GROW_IF_NAVIGATE
+ if (!Single_Line_Field(field) && Field_Grown(field, 1))
+ {
+ form->curcol = 0;
+ returnCode(E_OK);
+ }
+#endif
+ form->currow--;
+#if GROW_IF_NAVIGATE
+ if (Single_Line_Field(field) && Field_Grown(field, 1))
+ returnCode(E_OK);
+#endif
+ form->curcol -= step;
+ returnCode(E_REQUEST_DENIED);
+ }
+ form->curcol = 0;
+ }
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int IFN_Previous_Character(FORM * form)
+|
+| Description : Move to the previous character in the field. In a
+| multi-line field this wraps and the beginning of the
+| line.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - at the leftmost position
++--------------------------------------------------------------------------*/
+static int
+IFN_Previous_Character(FORM *form)
+{
+ int amount = myWCWIDTH(form->w, form->currow, form->curcol - 1);
+ int oldcol = form->curcol;
+
+ T((T_CALLED("IFN_Previous_Character(%p)"), (void *)form));
+ if ((form->curcol -= amount) < 0)
+ {
+ if ((--(form->currow)) < 0)
+ {
+ form->currow++;
+ form->curcol = oldcol;
+ returnCode(E_REQUEST_DENIED);
+ }
+ form->curcol = form->current->dcols - 1;
+ }
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int IFN_Next_Line(FORM * form)
+|
+| Description : Move to the beginning of the next line in the field
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - at the last line
++--------------------------------------------------------------------------*/
+static int
+IFN_Next_Line(FORM *form)
+{
+ FIELD *field = form->current;
+
+ T((T_CALLED("IFN_Next_Line(%p)"), (void *)form));
+ if ((++(form->currow)) == field->drows)
+ {
+#if GROW_IF_NAVIGATE
+ if (!Single_Line_Field(field) && Field_Grown(field, 1))
+ returnCode(E_OK);
+#endif
+ form->currow--;
+ returnCode(E_REQUEST_DENIED);
+ }
+ form->curcol = 0;
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int IFN_Previous_Line(FORM * form)
+|
+| Description : Move to the beginning of the previous line in the field
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - at the first line
++--------------------------------------------------------------------------*/
+static int
+IFN_Previous_Line(FORM *form)
+{
+ T((T_CALLED("IFN_Previous_Line(%p)"), (void *)form));
+ if ((--(form->currow)) < 0)
+ {
+ form->currow++;
+ returnCode(E_REQUEST_DENIED);
+ }
+ form->curcol = 0;
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int IFN_Next_Word(FORM * form)
+|
+| Description : Move to the beginning of the next word in the field.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - there is no next word
++--------------------------------------------------------------------------*/
+static int
+IFN_Next_Word(FORM *form)
+{
+ FIELD *field = form->current;
+ FIELD_CELL *bp = Address_Of_Current_Position_In_Buffer(form);
+ FIELD_CELL *s;
+ FIELD_CELL *t;
+
+ T((T_CALLED("IFN_Next_Word(%p)"), (void *)form));
+
+ /* We really need access to the data, so we have to synchronize */
+ Synchronize_Buffer(form);
+
+ /* Go to the first whitespace after the current position (including
+ current position). This is then the starting point to look for the
+ next non-blank data */
+ s = Get_First_Whitespace_Character(bp, Buffer_Length(field) -
+ (int)(bp - field->buf));
+
+ /* Find the start of the next word */
+ t = Get_Start_Of_Data(s, Buffer_Length(field) -
+ (int)(s - field->buf));
+#if !FRIENDLY_PREV_NEXT_WORD
+ if (s == t)
+ returnCode(E_REQUEST_DENIED);
+ else
+#endif
+ {
+ Adjust_Cursor_Position(form, t);
+ returnCode(E_OK);
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int IFN_Previous_Word(FORM * form)
+|
+| Description : Move to the beginning of the previous word in the field.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - there is no previous word
++--------------------------------------------------------------------------*/
+static int
+IFN_Previous_Word(FORM *form)
+{
+ FIELD *field = form->current;
+ FIELD_CELL *bp = Address_Of_Current_Position_In_Buffer(form);
+ FIELD_CELL *s;
+ FIELD_CELL *t;
+ bool again = FALSE;
+
+ T((T_CALLED("IFN_Previous_Word(%p)"), (void *)form));
+
+ /* We really need access to the data, so we have to synchronize */
+ Synchronize_Buffer(form);
+
+ s = After_End_Of_Data(field->buf, (int)(bp - field->buf));
+ /* s points now right after the last non-blank in the buffer before bp.
+ If bp was in a word, s equals bp. In this case we must find the last
+ whitespace in the buffer before bp and repeat the game to really find
+ the previous word! */
+ if (s == bp)
+ again = TRUE;
+
+ /* And next call now goes backward to look for the last whitespace
+ before that, pointing right after this, so it points to the begin
+ of the previous word.
+ */
+ t = After_Last_Whitespace_Character(field->buf, (int)(s - field->buf));
+#if !FRIENDLY_PREV_NEXT_WORD
+ if (s == t)
+ returnCode(E_REQUEST_DENIED);
+#endif
+ if (again)
+ {
+ /* and do it again, replacing bp by t */
+ s = After_End_Of_Data(field->buf, (int)(t - field->buf));
+ t = After_Last_Whitespace_Character(field->buf, (int)(s - field->buf));
+#if !FRIENDLY_PREV_NEXT_WORD
+ if (s == t)
+ returnCode(E_REQUEST_DENIED);
+#endif
+ }
+ Adjust_Cursor_Position(form, t);
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int IFN_Beginning_Of_Field(FORM * form)
+|
+| Description : Place the cursor at the first non-pad character in
+| the field.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+static int
+IFN_Beginning_Of_Field(FORM *form)
+{
+ FIELD *field = form->current;
+
+ T((T_CALLED("IFN_Beginning_Of_Field(%p)"), (void *)form));
+ Synchronize_Buffer(form);
+ Adjust_Cursor_Position(form,
+ Get_Start_Of_Data(field->buf, Buffer_Length(field)));
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int IFN_End_Of_Field(FORM * form)
+|
+| Description : Place the cursor after the last non-pad character in
+| the field. If the field occupies the last position in
+| the buffer, the cursor is positioned on the last
+| character.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+static int
+IFN_End_Of_Field(FORM *form)
+{
+ FIELD *field = form->current;
+ FIELD_CELL *pos;
+
+ T((T_CALLED("IFN_End_Of_Field(%p)"), (void *)form));
+ Synchronize_Buffer(form);
+ pos = After_End_Of_Data(field->buf, Buffer_Length(field));
+ if (pos == (field->buf + Buffer_Length(field)))
+ pos--;
+ Adjust_Cursor_Position(form, pos);
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int IFN_Beginning_Of_Line(FORM * form)
+|
+| Description : Place the cursor on the first non-pad character in
+| the current line of the field.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+static int
+IFN_Beginning_Of_Line(FORM *form)
+{
+ FIELD *field = form->current;
+
+ T((T_CALLED("IFN_Beginning_Of_Line(%p)"), (void *)form));
+ Synchronize_Buffer(form);
+ Adjust_Cursor_Position(form,
+ Get_Start_Of_Data(Address_Of_Current_Row_In_Buffer(form),
+ field->dcols));
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int IFN_End_Of_Line(FORM * form)
+|
+| Description : Place the cursor after the last non-pad character in the
+| current line of the field. If the field occupies the
+| last column in the line, the cursor is positioned on the
+| last character of the line.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+static int
+IFN_End_Of_Line(FORM *form)
+{
+ FIELD *field = form->current;
+ FIELD_CELL *pos;
+ FIELD_CELL *bp;
+
+ T((T_CALLED("IFN_End_Of_Line(%p)"), (void *)form));
+ Synchronize_Buffer(form);
+ bp = Address_Of_Current_Row_In_Buffer(form);
+ pos = After_End_Of_Data(bp, field->dcols);
+ if (pos == (bp + field->dcols))
+ pos--;
+ Adjust_Cursor_Position(form, pos);
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int IFN_Left_Character(FORM * form)
+|
+| Description : Move one character to the left in the current line.
+| This doesn't cycle.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - already in first column
++--------------------------------------------------------------------------*/
+static int
+IFN_Left_Character(FORM *form)
+{
+ int amount = myWCWIDTH(form->w, form->currow, form->curcol - 1);
+ int oldcol = form->curcol;
+
+ T((T_CALLED("IFN_Left_Character(%p)"), (void *)form));
+ if ((form->curcol -= amount) < 0)
+ {
+ form->curcol = oldcol;
+ returnCode(E_REQUEST_DENIED);
+ }
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int IFN_Right_Character(FORM * form)
+|
+| Description : Move one character to the right in the current line.
+| This doesn't cycle.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - already in last column
++--------------------------------------------------------------------------*/
+static int
+IFN_Right_Character(FORM *form)
+{
+ int amount = myWCWIDTH(form->w, form->currow, form->curcol);
+ int oldcol = form->curcol;
+
+ T((T_CALLED("IFN_Right_Character(%p)"), (void *)form));
+ if ((form->curcol += amount) >= form->current->dcols)
+ {
+#if GROW_IF_NAVIGATE
+ FIELD *field = form->current;
+
+ if (Single_Line_Field(field) && Field_Grown(field, 1))
+ returnCode(E_OK);
+#endif
+ form->curcol = oldcol;
+ returnCode(E_REQUEST_DENIED);
+ }
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int IFN_Up_Character(FORM * form)
+|
+| Description : Move one line up. This doesn't cycle through the lines
+| of the field.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - already in last column
++--------------------------------------------------------------------------*/
+static int
+IFN_Up_Character(FORM *form)
+{
+ T((T_CALLED("IFN_Up_Character(%p)"), (void *)form));
+ if ((--(form->currow)) < 0)
+ {
+ form->currow++;
+ returnCode(E_REQUEST_DENIED);
+ }
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int IFN_Down_Character(FORM * form)
+|
+| Description : Move one line down. This doesn't cycle through the
+| lines of the field.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - already in last column
++--------------------------------------------------------------------------*/
+static int
+IFN_Down_Character(FORM *form)
+{
+ FIELD *field = form->current;
+
+ T((T_CALLED("IFN_Down_Character(%p)"), (void *)form));
+ if ((++(form->currow)) == field->drows)
+ {
+#if GROW_IF_NAVIGATE
+ if (!Single_Line_Field(field) && Field_Grown(field, 1))
+ returnCode(E_OK);
+#endif
+ --(form->currow);
+ returnCode(E_REQUEST_DENIED);
+ }
+ returnCode(E_OK);
+}
+/*----------------------------------------------------------------------------
+ END of Intra-Field Navigation routines
+ --------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+ Vertical scrolling helper routines
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int VSC_Generic(FORM *form, int nlines)
+|
+| Description : Scroll multi-line field forward (nlines>0) or
+| backward (nlines<0) this many lines.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - can't scroll
++--------------------------------------------------------------------------*/
+static int
+VSC_Generic(FORM *form, int nlines)
+{
+ FIELD *field = form->current;
+ int res = E_REQUEST_DENIED;
+ int rows_to_go = (nlines > 0 ? nlines : -nlines);
+
+ if (nlines > 0)
+ {
+ if ((rows_to_go + form->toprow) > (field->drows - field->rows))
+ rows_to_go = (field->drows - field->rows - form->toprow);
+
+ if (rows_to_go > 0)
+ {
+ form->currow += rows_to_go;
+ form->toprow += rows_to_go;
+ res = E_OK;
+ }
+ }
+ else
+ {
+ if (rows_to_go > form->toprow)
+ rows_to_go = form->toprow;
+
+ if (rows_to_go > 0)
+ {
+ form->currow -= rows_to_go;
+ form->toprow -= rows_to_go;
+ res = E_OK;
+ }
+ }
+ return (res);
+}
+/*----------------------------------------------------------------------------
+ End of Vertical scrolling helper routines
+ --------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+ Vertical scrolling routines
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int Vertical_Scrolling(
+| int (* const fct) (FORM *),
+| FORM * form)
+|
+| Description : Performs the generic vertical scrolling routines.
+| This has to check for a multi-line field and to set
+| the _NEWTOP flag if scrolling really occurred.
+|
+| Return Values : Propagated error code from low-level driver calls
++--------------------------------------------------------------------------*/
+static int
+Vertical_Scrolling(int (*const fct) (FORM *), FORM *form)
+{
+ int res = E_REQUEST_DENIED;
+
+ if (!Single_Line_Field(form->current))
+ {
+ res = fct(form);
+ if (res == E_OK)
+ form->current->status |= _NEWTOP;
+ }
+ return (res);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int VSC_Scroll_Line_Forward(FORM * form)
+|
+| Description : Scroll multi-line field forward a line
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - no data ahead
++--------------------------------------------------------------------------*/
+static int
+VSC_Scroll_Line_Forward(FORM *form)
+{
+ T((T_CALLED("VSC_Scroll_Line_Forward(%p)"), (void *)form));
+ returnCode(VSC_Generic(form, 1));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int VSC_Scroll_Line_Backward(FORM * form)
+|
+| Description : Scroll multi-line field backward a line
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - no data behind
++--------------------------------------------------------------------------*/
+static int
+VSC_Scroll_Line_Backward(FORM *form)
+{
+ T((T_CALLED("VSC_Scroll_Line_Backward(%p)"), (void *)form));
+ returnCode(VSC_Generic(form, -1));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int VSC_Scroll_Page_Forward(FORM * form)
+|
+| Description : Scroll a multi-line field forward a page
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - no data ahead
++--------------------------------------------------------------------------*/
+static int
+VSC_Scroll_Page_Forward(FORM *form)
+{
+ T((T_CALLED("VSC_Scroll_Page_Forward(%p)"), (void *)form));
+ returnCode(VSC_Generic(form, form->current->rows));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int VSC_Scroll_Half_Page_Forward(FORM * form)
+|
+| Description : Scroll a multi-line field forward half a page
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - no data ahead
++--------------------------------------------------------------------------*/
+static int
+VSC_Scroll_Half_Page_Forward(FORM *form)
+{
+ T((T_CALLED("VSC_Scroll_Half_Page_Forward(%p)"), (void *)form));
+ returnCode(VSC_Generic(form, (form->current->rows + 1) / 2));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int VSC_Scroll_Page_Backward(FORM * form)
+|
+| Description : Scroll a multi-line field backward a page
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - no data behind
++--------------------------------------------------------------------------*/
+static int
+VSC_Scroll_Page_Backward(FORM *form)
+{
+ T((T_CALLED("VSC_Scroll_Page_Backward(%p)"), (void *)form));
+ returnCode(VSC_Generic(form, -(form->current->rows)));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int VSC_Scroll_Half_Page_Backward(FORM * form)
+|
+| Description : Scroll a multi-line field backward half a page
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - no data behind
++--------------------------------------------------------------------------*/
+static int
+VSC_Scroll_Half_Page_Backward(FORM *form)
+{
+ T((T_CALLED("VSC_Scroll_Half_Page_Backward(%p)"), (void *)form));
+ returnCode(VSC_Generic(form, -((form->current->rows + 1) / 2)));
+}
+/*----------------------------------------------------------------------------
+ End of Vertical scrolling routines
+ --------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+ Horizontal scrolling helper routines
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int HSC_Generic(FORM *form, int ncolumns)
+|
+| Description : Scroll single-line field forward (ncolumns>0) or
+| backward (ncolumns<0) this many columns.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - can't scroll
++--------------------------------------------------------------------------*/
+static int
+HSC_Generic(FORM *form, int ncolumns)
+{
+ FIELD *field = form->current;
+ int res = E_REQUEST_DENIED;
+ int cols_to_go = (ncolumns > 0 ? ncolumns : -ncolumns);
+
+ if (ncolumns > 0)
+ {
+ if ((cols_to_go + form->begincol) > (field->dcols - field->cols))
+ cols_to_go = field->dcols - field->cols - form->begincol;
+
+ if (cols_to_go > 0)
+ {
+ form->curcol += cols_to_go;
+ form->begincol += cols_to_go;
+ res = E_OK;
+ }
+ }
+ else
+ {
+ if (cols_to_go > form->begincol)
+ cols_to_go = form->begincol;
+
+ if (cols_to_go > 0)
+ {
+ form->curcol -= cols_to_go;
+ form->begincol -= cols_to_go;
+ res = E_OK;
+ }
+ }
+ return (res);
+}
+/*----------------------------------------------------------------------------
+ End of Horizontal scrolling helper routines
+ --------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+ Horizontal scrolling routines
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int Horizontal_Scrolling(
+| int (* const fct) (FORM *),
+| FORM * form)
+|
+| Description : Performs the generic horizontal scrolling routines.
+| This has to check for a single-line field.
+|
+| Return Values : Propagated error code from low-level driver calls
++--------------------------------------------------------------------------*/
+static int
+Horizontal_Scrolling(int (*const fct) (FORM *), FORM *form)
+{
+ if (Single_Line_Field(form->current))
+ return fct(form);
+ else
+ return (E_REQUEST_DENIED);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int HSC_Scroll_Char_Forward(FORM * form)
+|
+| Description : Scroll single-line field forward a character
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - no data ahead
++--------------------------------------------------------------------------*/
+static int
+HSC_Scroll_Char_Forward(FORM *form)
+{
+ T((T_CALLED("HSC_Scroll_Char_Forward(%p)"), (void *)form));
+ returnCode(HSC_Generic(form, 1));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int HSC_Scroll_Char_Backward(FORM * form)
+|
+| Description : Scroll single-line field backward a character
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - no data behind
++--------------------------------------------------------------------------*/
+static int
+HSC_Scroll_Char_Backward(FORM *form)
+{
+ T((T_CALLED("HSC_Scroll_Char_Backward(%p)"), (void *)form));
+ returnCode(HSC_Generic(form, -1));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int HSC_Horizontal_Line_Forward(FORM* form)
+|
+| Description : Scroll single-line field forward a line
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - no data ahead
++--------------------------------------------------------------------------*/
+static int
+HSC_Horizontal_Line_Forward(FORM *form)
+{
+ T((T_CALLED("HSC_Horizontal_Line_Forward(%p)"), (void *)form));
+ returnCode(HSC_Generic(form, form->current->cols));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int HSC_Horizontal_Half_Line_Forward(FORM* form)
+|
+| Description : Scroll single-line field forward half a line
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - no data ahead
++--------------------------------------------------------------------------*/
+static int
+HSC_Horizontal_Half_Line_Forward(FORM *form)
+{
+ T((T_CALLED("HSC_Horizontal_Half_Line_Forward(%p)"), (void *)form));
+ returnCode(HSC_Generic(form, (form->current->cols + 1) / 2));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int HSC_Horizontal_Line_Backward(FORM* form)
+|
+| Description : Scroll single-line field backward a line
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - no data behind
++--------------------------------------------------------------------------*/
+static int
+HSC_Horizontal_Line_Backward(FORM *form)
+{
+ T((T_CALLED("HSC_Horizontal_Line_Backward(%p)"), (void *)form));
+ returnCode(HSC_Generic(form, -(form->current->cols)));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int HSC_Horizontal_Half_Line_Backward(FORM* form)
+|
+| Description : Scroll single-line field backward half a line
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - no data behind
++--------------------------------------------------------------------------*/
+static int
+HSC_Horizontal_Half_Line_Backward(FORM *form)
+{
+ T((T_CALLED("HSC_Horizontal_Half_Line_Backward(%p)"), (void *)form));
+ returnCode(HSC_Generic(form, -((form->current->cols + 1) / 2)));
+}
+
+/*----------------------------------------------------------------------------
+ End of Horizontal scrolling routines
+ --------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+ Helper routines for Field Editing
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Is_There_Room_For_A_Line(FORM * form)
+|
+| Description : Check whether or not there is enough room in the
+| buffer to enter a whole line.
+|
+| Return Values : TRUE - there is enough space
+| FALSE - there is not enough space
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static bool
+Is_There_Room_For_A_Line(FORM *form)
+{
+ FIELD *field = form->current;
+ FIELD_CELL *begin_of_last_line, *s;
+
+ Synchronize_Buffer(form);
+ begin_of_last_line = Address_Of_Row_In_Buffer(field, (field->drows - 1));
+ s = After_End_Of_Data(begin_of_last_line, field->dcols);
+ return ((s == begin_of_last_line) ? TRUE : FALSE);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Is_There_Room_For_A_Char_In_Line(FORM * form)
+|
+| Description : Checks whether or not there is room for a new character
+| in the current line.
+|
+| Return Values : TRUE - there is room
+| FALSE - there is not enough room (line full)
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static bool
+Is_There_Room_For_A_Char_In_Line(FORM *form)
+{
+ int last_char_in_line;
+
+ wmove(form->w, form->currow, form->current->dcols - 1);
+ last_char_in_line = (int)(winch(form->w) & A_CHARTEXT);
+ wmove(form->w, form->currow, form->curcol);
+ return (((last_char_in_line == form->current->pad) ||
+ is_blank(last_char_in_line)) ? TRUE : FALSE);
+}
+
+#define There_Is_No_Room_For_A_Char_In_Line(f) \
+ !Is_There_Room_For_A_Char_In_Line(f)
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int Insert_String(
+| FORM * form,
+| int row,
+| char *txt,
+| int len )
+|
+| Description : Insert the 'len' characters beginning at pointer 'txt'
+| into the 'row' of the 'form'. The insertion occurs
+| on the beginning of the row, all other characters are
+| moved to the right. After the text a pad character will
+| be inserted to separate the text from the rest. If
+| necessary the insertion moves characters on the next
+| line to make place for the requested insertion string.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED -
+| E_SYSTEM_ERROR - system error
++--------------------------------------------------------------------------*/
+static int
+Insert_String(FORM *form, int row, FIELD_CELL *txt, int len)
+{
+ FIELD *field = form->current;
+ FIELD_CELL *bp = Address_Of_Row_In_Buffer(field, row);
+ int datalen = (int)(After_End_Of_Data(bp, field->dcols) - bp);
+ int freelen = field->dcols - datalen;
+ int requiredlen = len + 1;
+ FIELD_CELL *split;
+ int result = E_REQUEST_DENIED;
+
+ if (freelen >= requiredlen)
+ {
+ wmove(form->w, row, 0);
+ myINSNSTR(form->w, txt, len);
+ wmove(form->w, row, len);
+ myINSNSTR(form->w, &myBLANK, 1);
+ return E_OK;
+ }
+ else
+ {
+ /* we have to move characters on the next line. If we are on the
+ last line this may work, if the field is growable */
+ if ((row == (field->drows - 1)) && Growable(field))
+ {
+ if (!Field_Grown(field, 1))
+ return (E_SYSTEM_ERROR);
+ /* !!!Side-Effect : might be changed due to growth!!! */
+ bp = Address_Of_Row_In_Buffer(field, row);
+ }
+
+ if (row < (field->drows - 1))
+ {
+ split =
+ After_Last_Whitespace_Character(bp,
+ (int)(Get_Start_Of_Data(bp
+ + field->dcols
+ - requiredlen,
+ requiredlen)
+ - bp));
+ /* split points now to the first character of the portion of the
+ line that must be moved to the next line */
+ datalen = (int)(split - bp); /* + freelen has to stay on this line */
+ freelen = field->dcols - (datalen + freelen); /* for the next line */
+
+ if ((result = Insert_String(form, row + 1, split, freelen)) == E_OK)
+ {
+ wmove(form->w, row, datalen);
+ wclrtoeol(form->w);
+ wmove(form->w, row, 0);
+ myINSNSTR(form->w, txt, len);
+ wmove(form->w, row, len);
+ myINSNSTR(form->w, &myBLANK, 1);
+ return E_OK;
+ }
+ }
+ return (result);
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int Wrapping_Not_Necessary_Or_Wrapping_Ok(
+| FORM * form)
+|
+| Description : If a character has been entered into a field, it may
+| be that wrapping has to occur. This routine checks
+| whether or not wrapping is required and if so, performs
+| the wrapping.
+|
+| Return Values : E_OK - no wrapping required or wrapping
+| was successful
+| E_REQUEST_DENIED -
+| E_SYSTEM_ERROR - some system error
++--------------------------------------------------------------------------*/
+static int
+Wrapping_Not_Necessary_Or_Wrapping_Ok(FORM *form)
+{
+ FIELD *field = form->current;
+ int result = E_REQUEST_DENIED;
+ bool Last_Row = ((field->drows - 1) == form->currow);
+
+ if ((field->opts & O_WRAP) && /* wrapping wanted */
+ (!Single_Line_Field(field)) && /* must be multi-line */
+ (There_Is_No_Room_For_A_Char_In_Line(form)) && /* line is full */
+ (!Last_Row || Growable(field))) /* there are more lines */
+ {
+ FIELD_CELL *bp;
+ FIELD_CELL *split;
+ int chars_to_be_wrapped;
+ int chars_to_remain_on_line;
+
+ if (Last_Row)
+ {
+ /* the above logic already ensures, that in this case the field
+ is growable */
+ if (!Field_Grown(field, 1))
+ return E_SYSTEM_ERROR;
+ }
+ bp = Address_Of_Current_Row_In_Buffer(form);
+ Window_To_Buffer(form, field);
+ split = After_Last_Whitespace_Character(bp, field->dcols);
+ /* split points to the first character of the sequence to be brought
+ on the next line */
+ chars_to_remain_on_line = (int)(split - bp);
+ chars_to_be_wrapped = field->dcols - chars_to_remain_on_line;
+ if (chars_to_remain_on_line > 0)
+ {
+ if ((result = Insert_String(form, form->currow + 1, split,
+ chars_to_be_wrapped)) == E_OK)
+ {
+ wmove(form->w, form->currow, chars_to_remain_on_line);
+ wclrtoeol(form->w);
+ if (form->curcol >= chars_to_remain_on_line)
+ {
+ form->currow++;
+ form->curcol -= chars_to_remain_on_line;
+ }
+ return E_OK;
+ }
+ }
+ else
+ return E_OK;
+ if (result != E_OK)
+ {
+ DeleteChar(form);
+ Window_To_Buffer(form, field);
+ result = E_REQUEST_DENIED;
+ }
+ }
+ else
+ result = E_OK; /* wrapping was not necessary */
+ return (result);
+}
+
+/*----------------------------------------------------------------------------
+ Field Editing routines
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int Field_Editing(
+| int (* const fct) (FORM *),
+| FORM * form)
+|
+| Description : Generic routine for field editing requests. The driver
+| routines are only called for editable fields, the
+| _WINDOW_MODIFIED flag is set if editing occurred.
+| This is somewhat special due to the overload semantics
+| of the NEW_LINE and DEL_PREV requests.
+|
+| Return Values : Error code from low level drivers.
++--------------------------------------------------------------------------*/
+static int
+Field_Editing(int (*const fct) (FORM *), FORM *form)
+{
+ int res = E_REQUEST_DENIED;
+
+ /* We have to deal here with the specific case of the overloaded
+ behavior of New_Line and Delete_Previous requests.
+ They may end up in navigational requests if we are on the first
+ character in a field. But navigation is also allowed on non-
+ editable fields.
+ */
+ if ((fct == FE_Delete_Previous) &&
+ (form->opts & O_BS_OVERLOAD) &&
+ First_Position_In_Current_Field(form))
+ {
+ res = Inter_Field_Navigation(FN_Previous_Field, form);
+ }
+ else
+ {
+ if (fct == FE_New_Line)
+ {
+ if ((form->opts & O_NL_OVERLOAD) &&
+ First_Position_In_Current_Field(form))
+ {
+ res = Inter_Field_Navigation(FN_Next_Field, form);
+ }
+ else
+ /* FE_New_Line deals itself with the _WINDOW_MODIFIED flag */
+ res = fct(form);
+ }
+ else
+ {
+ /* From now on, everything must be editable */
+ if (form->current->opts & O_EDIT)
+ {
+ res = fct(form);
+ if (res == E_OK)
+ form->status |= _WINDOW_MODIFIED;
+ }
+ }
+ }
+ return res;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FE_New_Line(FORM * form)
+|
+| Description : Perform a new line request. This is rather complex
+| compared to other routines in this code due to the
+| rather difficult to understand description in the
+| manuals.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - new line not allowed
+| E_SYSTEM_ERROR - system error
++--------------------------------------------------------------------------*/
+static int
+FE_New_Line(FORM *form)
+{
+ FIELD *field = form->current;
+ FIELD_CELL *bp, *t;
+ bool Last_Row = ((field->drows - 1) == form->currow);
+
+ T((T_CALLED("FE_New_Line(%p)"), (void *)form));
+ if (form->status & _OVLMODE)
+ {
+ if (Last_Row &&
+ (!(Growable(field) && !Single_Line_Field(field))))
+ {
+ if (!(form->opts & O_NL_OVERLOAD))
+ returnCode(E_REQUEST_DENIED);
+ wmove(form->w, form->currow, form->curcol);
+ wclrtoeol(form->w);
+ /* we have to set this here, although it is also
+ handled in the generic routine. The reason is,
+ that FN_Next_Field may fail, but the form is
+ definitively changed */
+ form->status |= _WINDOW_MODIFIED;
+ returnCode(Inter_Field_Navigation(FN_Next_Field, form));
+ }
+ else
+ {
+ if (Last_Row && !Field_Grown(field, 1))
+ {
+ /* N.B.: due to the logic in the 'if', LastRow==TRUE
+ means here that the field is growable and not
+ a single-line field */
+ returnCode(E_SYSTEM_ERROR);
+ }
+ wmove(form->w, form->currow, form->curcol);
+ wclrtoeol(form->w);
+ form->currow++;
+ form->curcol = 0;
+ form->status |= _WINDOW_MODIFIED;
+ returnCode(E_OK);
+ }
+ }
+ else
+ {
+ /* Insert Mode */
+ if (Last_Row &&
+ !(Growable(field) && !Single_Line_Field(field)))
+ {
+ if (!(form->opts & O_NL_OVERLOAD))
+ returnCode(E_REQUEST_DENIED);
+ returnCode(Inter_Field_Navigation(FN_Next_Field, form));
+ }
+ else
+ {
+ bool May_Do_It = !Last_Row && Is_There_Room_For_A_Line(form);
+
+ if (!(May_Do_It || Growable(field)))
+ returnCode(E_REQUEST_DENIED);
+ if (!May_Do_It && !Field_Grown(field, 1))
+ returnCode(E_SYSTEM_ERROR);
+
+ bp = Address_Of_Current_Position_In_Buffer(form);
+ t = After_End_Of_Data(bp, field->dcols - form->curcol);
+ wmove(form->w, form->currow, form->curcol);
+ wclrtoeol(form->w);
+ form->currow++;
+ form->curcol = 0;
+ wmove(form->w, form->currow, form->curcol);
+ winsertln(form->w);
+ myADDNSTR(form->w, bp, (int)(t - bp));
+ form->status |= _WINDOW_MODIFIED;
+ returnCode(E_OK);
+ }
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FE_Insert_Character(FORM * form)
+|
+| Description : Insert blank character at the cursor position
+|
+| Return Values : E_OK
+| E_REQUEST_DENIED
++--------------------------------------------------------------------------*/
+static int
+FE_Insert_Character(FORM *form)
+{
+ FIELD *field = form->current;
+ int result = E_REQUEST_DENIED;
+
+ T((T_CALLED("FE_Insert_Character(%p)"), (void *)form));
+ if (Check_Char(form, field, field->type, (int)C_BLANK,
+ (TypeArgument *)(field->arg)))
+ {
+ bool There_Is_Room = Is_There_Room_For_A_Char_In_Line(form);
+
+ if (There_Is_Room ||
+ ((Single_Line_Field(field) && Growable(field))))
+ {
+ if (!There_Is_Room && !Field_Grown(field, 1))
+ result = E_SYSTEM_ERROR;
+ else
+ {
+ winsch(form->w, (chtype)C_BLANK);
+ result = Wrapping_Not_Necessary_Or_Wrapping_Ok(form);
+ }
+ }
+ }
+ returnCode(result);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FE_Insert_Line(FORM * form)
+|
+| Description : Insert a blank line at the cursor position
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - line can not be inserted
++--------------------------------------------------------------------------*/
+static int
+FE_Insert_Line(FORM *form)
+{
+ FIELD *field = form->current;
+ int result = E_REQUEST_DENIED;
+
+ T((T_CALLED("FE_Insert_Line(%p)"), (void *)form));
+ if (Check_Char(form, field,
+ field->type, (int)C_BLANK, (TypeArgument *)(field->arg)))
+ {
+ bool Maybe_Done = (form->currow != (field->drows - 1)) &&
+ Is_There_Room_For_A_Line(form);
+
+ if (!Single_Line_Field(field) &&
+ (Maybe_Done || Growable(field)))
+ {
+ if (!Maybe_Done && !Field_Grown(field, 1))
+ result = E_SYSTEM_ERROR;
+ else
+ {
+ form->curcol = 0;
+ winsertln(form->w);
+ result = E_OK;
+ }
+ }
+ }
+ returnCode(result);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FE_Delete_Character(FORM * form)
+|
+| Description : Delete character at the cursor position
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+static int
+FE_Delete_Character(FORM *form)
+{
+ T((T_CALLED("FE_Delete_Character(%p)"), (void *)form));
+ DeleteChar(form);
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FE_Delete_Previous(FORM * form)
+|
+| Description : Delete character before cursor. Again this is a rather
+| difficult piece compared to others due to the overloading
+| semantics of backspace.
+| N.B.: The case of overloaded BS on first field position
+| is already handled in the generic routine.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - Character can't be deleted
++--------------------------------------------------------------------------*/
+static int
+FE_Delete_Previous(FORM *form)
+{
+ FIELD *field = form->current;
+
+ T((T_CALLED("FE_Delete_Previous(%p)"), (void *)form));
+ if (First_Position_In_Current_Field(form))
+ returnCode(E_REQUEST_DENIED);
+
+ if ((--(form->curcol)) < 0)
+ {
+ FIELD_CELL *this_line, *prev_line, *prev_end, *this_end;
+ int this_row = form->currow;
+
+ form->curcol++;
+ if (form->status & _OVLMODE)
+ returnCode(E_REQUEST_DENIED);
+
+ prev_line = Address_Of_Row_In_Buffer(field, (form->currow - 1));
+ this_line = Address_Of_Row_In_Buffer(field, (form->currow));
+ Synchronize_Buffer(form);
+ prev_end = After_End_Of_Data(prev_line, field->dcols);
+ this_end = After_End_Of_Data(this_line, field->dcols);
+ if ((int)(this_end - this_line) >
+ (field->cols - (int)(prev_end - prev_line)))
+ returnCode(E_REQUEST_DENIED);
+ wmove(form->w, form->currow, form->curcol);
+ wdeleteln(form->w);
+ Adjust_Cursor_Position(form, prev_end);
+ /*
+ * If we did not really move to the previous line, help the user a
+ * little. It is however a little inconsistent. Normally, when
+ * backspacing around the point where text wraps to a new line in a
+ * multi-line form, we absorb one keystroke for the wrapping point. That
+ * is consistent with SVr4 forms. However, SVr4 does not allow typing
+ * into the last column of the field, and requires the user to enter a
+ * newline to move to the next line. Therefore it can consistently eat
+ * that keystroke. Since ncurses allows the last column, it wraps
+ * automatically (given the proper options). But we cannot eat the
+ * keystroke to back over the wrapping point, since that would put the
+ * cursor past the end of the form field. In this case, just delete the
+ * character at the end of the field.
+ */
+ if (form->currow == this_row && this_row > 0)
+ {
+ form->currow -= 1;
+ form->curcol = field->dcols - 1;
+ DeleteChar(form);
+ }
+ else
+ {
+ wmove(form->w, form->currow, form->curcol);
+ myADDNSTR(form->w, this_line, (int)(this_end - this_line));
+ }
+ }
+ else
+ {
+ DeleteChar(form);
+ }
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FE_Delete_Line(FORM * form)
+|
+| Description : Delete line at cursor position.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+static int
+FE_Delete_Line(FORM *form)
+{
+ T((T_CALLED("FE_Delete_Line(%p)"), (void *)form));
+ form->curcol = 0;
+ wdeleteln(form->w);
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FE_Delete_Word(FORM * form)
+|
+| Description : Delete word at cursor position
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - failure
++--------------------------------------------------------------------------*/
+static int
+FE_Delete_Word(FORM *form)
+{
+ FIELD *field = form->current;
+ FIELD_CELL *bp = Address_Of_Current_Row_In_Buffer(form);
+ FIELD_CELL *ep = bp + field->dcols;
+ FIELD_CELL *cp = bp + form->curcol;
+ FIELD_CELL *s;
+
+ T((T_CALLED("FE_Delete_Word(%p)"), (void *)form));
+ Synchronize_Buffer(form);
+ if (ISBLANK(*cp))
+ returnCode(E_REQUEST_DENIED); /* not in word */
+
+ /* move cursor to begin of word and erase to end of screen-line */
+ Adjust_Cursor_Position(form,
+ After_Last_Whitespace_Character(bp, form->curcol));
+ wmove(form->w, form->currow, form->curcol);
+ wclrtoeol(form->w);
+
+ /* skip over word in buffer */
+ s = Get_First_Whitespace_Character(cp, (int)(ep - cp));
+ /* to begin of next word */
+ s = Get_Start_Of_Data(s, (int)(ep - s));
+ if ((s != cp) && !ISBLANK(*s))
+ {
+ /* copy remaining line to window */
+ myADDNSTR(form->w, s, (int)(s - After_End_Of_Data(s, (int)(ep - s))));
+ }
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FE_Clear_To_End_Of_Line(FORM * form)
+|
+| Description : Clear to end of current line.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+static int
+FE_Clear_To_End_Of_Line(FORM *form)
+{
+ T((T_CALLED("FE_Clear_To_End_Of_Line(%p)"), (void *)form));
+ wmove(form->w, form->currow, form->curcol);
+ wclrtoeol(form->w);
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FE_Clear_To_End_Of_Field(FORM * form)
+|
+| Description : Clear to end of field.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+static int
+FE_Clear_To_End_Of_Field(FORM *form)
+{
+ T((T_CALLED("FE_Clear_To_End_Of_Field(%p)"), (void *)form));
+ wmove(form->w, form->currow, form->curcol);
+ wclrtobot(form->w);
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FE_Clear_Field(FORM * form)
+|
+| Description : Clear entire field.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+static int
+FE_Clear_Field(FORM *form)
+{
+ T((T_CALLED("FE_Clear_Field(%p)"), (void *)form));
+ form->currow = form->curcol = 0;
+ werase(form->w);
+ returnCode(E_OK);
+}
+/*----------------------------------------------------------------------------
+ END of Field Editing routines
+ --------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+ Edit Mode routines
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int EM_Overlay_Mode(FORM * form)
+|
+| Description : Switch to overlay mode.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+static int
+EM_Overlay_Mode(FORM *form)
+{
+ T((T_CALLED("EM_Overlay_Mode(%p)"), (void *)form));
+ form->status |= _OVLMODE;
+ returnCode(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int EM_Insert_Mode(FORM * form)
+|
+| Description : Switch to insert mode
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+static int
+EM_Insert_Mode(FORM *form)
+{
+ T((T_CALLED("EM_Insert_Mode(%p)"), (void *)form));
+ form->status &= ~_OVLMODE;
+ returnCode(E_OK);
+}
+
+/*----------------------------------------------------------------------------
+ END of Edit Mode routines
+ --------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+ Helper routines for Choice Requests
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Next_Choice(FORM * form,
+| FIELDTYPE * typ,
+| FIELD * field,
+| TypeArgument *argp)
+|
+| Description : Get the next field choice. For linked types this is
+| done recursively.
+|
+| Return Values : TRUE - next choice successfully retrieved
+| FALSE - couldn't retrieve next choice
++--------------------------------------------------------------------------*/
+static bool
+Next_Choice(FORM *form, FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
+{
+ if (!typ || !(typ->status & _HAS_CHOICE))
+ return FALSE;
+
+ if (typ->status & _LINKED_TYPE)
+ {
+ assert(argp);
+ return (
+ Next_Choice(form, typ->left, field, argp->left) ||
+ Next_Choice(form, typ->right, field, argp->right));
+ }
+ else
+ {
+#if NCURSES_INTEROP_FUNCS
+ assert(typ->enum_next.onext);
+ if (typ->status & _GENERIC)
+ return typ->enum_next.gnext(form, field, (void *)argp);
+ else
+ return typ->enum_next.onext(field, (void *)argp);
+#else
+ assert(typ->next);
+ return typ->next(field, (void *)argp);
+#endif
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Previous_Choice(FORM * form,
+| FIELDTYPE * typ,
+| FIELD * field,
+| TypeArgument *argp)
+|
+| Description : Get the previous field choice. For linked types this
+| is done recursively.
+|
+| Return Values : TRUE - previous choice successfully retrieved
+| FALSE - couldn't retrieve previous choice
++--------------------------------------------------------------------------*/
+static bool
+Previous_Choice(FORM *form, FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
+{
+ if (!typ || !(typ->status & _HAS_CHOICE))
+ return FALSE;
+
+ if (typ->status & _LINKED_TYPE)
+ {
+ assert(argp);
+ return (
+ Previous_Choice(form, typ->left, field, argp->left) ||
+ Previous_Choice(form, typ->right, field, argp->right));
+ }
+ else
+ {
+#if NCURSES_INTEROP_FUNCS
+ assert(typ->enum_prev.oprev);
+ if (typ->status & _GENERIC)
+ return typ->enum_prev.gprev(form, field, (void *)argp);
+ else
+ return typ->enum_prev.oprev(field, (void *)argp);
+#else
+ assert(typ->prev);
+ return typ->prev(field, (void *)argp);
+#endif
+ }
+}
+/*----------------------------------------------------------------------------
+ End of Helper routines for Choice Requests
+ --------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+ Routines for Choice Requests
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int CR_Next_Choice(FORM * form)
+|
+| Description : Get the next field choice.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - next choice couldn't be retrieved
++--------------------------------------------------------------------------*/
+static int
+CR_Next_Choice(FORM *form)
+{
+ FIELD *field = form->current;
+
+ T((T_CALLED("CR_Next_Choice(%p)"), (void *)form));
+ Synchronize_Buffer(form);
+ returnCode((Next_Choice(form, field->type, field, (TypeArgument *)(field->arg)))
+ ? E_OK
+ : E_REQUEST_DENIED);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int CR_Previous_Choice(FORM * form)
+|
+| Description : Get the previous field choice.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - prev. choice couldn't be retrieved
++--------------------------------------------------------------------------*/
+static int
+CR_Previous_Choice(FORM *form)
+{
+ FIELD *field = form->current;
+
+ T((T_CALLED("CR_Previous_Choice(%p)"), (void *)form));
+ Synchronize_Buffer(form);
+ returnCode((Previous_Choice(form, field->type, field, (TypeArgument *)(field->arg)))
+ ? E_OK
+ : E_REQUEST_DENIED);
+}
+/*----------------------------------------------------------------------------
+ End of Routines for Choice Requests
+ --------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+ Helper routines for Field Validations.
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Check_Field(FORM* form,
+| FIELDTYPE * typ,
+| FIELD * field,
+| TypeArgument * argp)
+|
+| Description : Check the field according to its fieldtype and its
+| actual arguments. For linked fieldtypes this is done
+| recursively.
+|
+| Return Values : TRUE - field is valid
+| FALSE - field is invalid.
++--------------------------------------------------------------------------*/
+static bool
+Check_Field(FORM *form, FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
+{
+ if (typ)
+ {
+ if (field->opts & O_NULLOK)
+ {
+ FIELD_CELL *bp = field->buf;
+
+ assert(bp);
+ while (ISBLANK(*bp))
+ {
+ bp++;
+ }
+ if (CharOf(*bp) == 0)
+ return TRUE;
+ }
+
+ if (typ->status & _LINKED_TYPE)
+ {
+ assert(argp);
+ return (
+ Check_Field(form, typ->left, field, argp->left) ||
+ Check_Field(form, typ->right, field, argp->right));
+ }
+ else
+ {
+#if NCURSES_INTEROP_FUNCS
+ if (typ->fieldcheck.ofcheck)
+ {
+ if (typ->status & _GENERIC)
+ return typ->fieldcheck.gfcheck(form, field, (void *)argp);
+ else
+ return typ->fieldcheck.ofcheck(field, (void *)argp);
+ }
+#else
+ if (typ->fcheck)
+ return typ->fcheck(field, (void *)argp);
+#endif
+ }
+ }
+ return TRUE;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : bool _nc_Internal_Validation(FORM * form )
+|
+| Description : Validate the current field of the form.
+|
+| Return Values : TRUE - field is valid
+| FALSE - field is invalid
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(bool)
+_nc_Internal_Validation(FORM *form)
+{
+ FIELD *field;
+
+ field = form->current;
+
+ Synchronize_Buffer(form);
+ if ((form->status & _FCHECK_REQUIRED) ||
+ (!(field->opts & O_PASSOK)))
+ {
+ if (!Check_Field(form, field->type, field, (TypeArgument *)(field->arg)))
+ return FALSE;
+ form->status &= ~_FCHECK_REQUIRED;
+ field->status |= _CHANGED;
+ Synchronize_Linked_Fields(field);
+ }
+ return TRUE;
+}
+/*----------------------------------------------------------------------------
+ End of Helper routines for Field Validations.
+ --------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+ Routines for Field Validation.
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FV_Validation(FORM * form)
+|
+| Description : Validate the current field of the form.
+|
+| Return Values : E_OK - field valid
+| E_INVALID_FIELD - field not valid
++--------------------------------------------------------------------------*/
+static int
+FV_Validation(FORM *form)
+{
+ T((T_CALLED("FV_Validation(%p)"), (void *)form));
+ if (_nc_Internal_Validation(form))
+ returnCode(E_OK);
+ else
+ returnCode(E_INVALID_FIELD);
+}
+/*----------------------------------------------------------------------------
+ End of routines for Field Validation.
+ --------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+ Helper routines for Inter-Field Navigation
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static FIELD *Next_Field_On_Page(FIELD * field)
+|
+| Description : Get the next field after the given field on the current
+| page. The order of fields is the one defined by the
+| fields array. Only visible and active fields are
+| counted.
+|
+| Return Values : Pointer to the next field.
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static FIELD *
+Next_Field_On_Page(FIELD *field)
+{
+ FORM *form = field->form;
+ FIELD **field_on_page = &form->field[field->index];
+ FIELD **first_on_page = &form->field[form->page[form->curpage].pmin];
+ FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
+
+ do
+ {
+ field_on_page =
+ (field_on_page == last_on_page) ? first_on_page : field_on_page + 1;
+ if (Field_Is_Selectable(*field_on_page))
+ break;
+ }
+ while (field != (*field_on_page));
+ return (*field_on_page);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : FIELD* _nc_First_Active_Field(FORM * form)
+|
+| Description : Get the first active field on the current page,
+| if there are such. If there are none, get the first
+| visible field on the page. If there are also none,
+| we return the first field on page and hope the best.
+|
+| Return Values : Pointer to calculated field.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(FIELD *)
+_nc_First_Active_Field(FORM *form)
+{
+ FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
+ FIELD *proposed = Next_Field_On_Page(*last_on_page);
+
+ if (proposed == *last_on_page)
+ {
+ /* there might be the special situation, where there is no
+ active and visible field on the current page. We then select
+ the first visible field on this readonly page
+ */
+ if (Field_Is_Not_Selectable(proposed))
+ {
+ FIELD **field = &form->field[proposed->index];
+ FIELD **first = &form->field[form->page[form->curpage].pmin];
+
+ do
+ {
+ field = (field == last_on_page) ? first : field + 1;
+ if (((*field)->opts & O_VISIBLE))
+ break;
+ }
+ while (proposed != (*field));
+
+ proposed = *field;
+
+ if ((proposed == *last_on_page) && !(proposed->opts & O_VISIBLE))
+ {
+ /* This means, there is also no visible field on the page.
+ So we propose the first one and hope the very best...
+ Some very clever user has designed a readonly and invisible
+ page on this form.
+ */
+ proposed = *first;
+ }
+ }
+ }
+ return (proposed);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static FIELD *Previous_Field_On_Page(FIELD * field)
+|
+| Description : Get the previous field before the given field on the
+| current page. The order of fields is the one defined by
+| the fields array. Only visible and active fields are
+| counted.
+|
+| Return Values : Pointer to the previous field.
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static FIELD *
+Previous_Field_On_Page(FIELD *field)
+{
+ FORM *form = field->form;
+ FIELD **field_on_page = &form->field[field->index];
+ FIELD **first_on_page = &form->field[form->page[form->curpage].pmin];
+ FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
+
+ do
+ {
+ field_on_page =
+ (field_on_page == first_on_page) ? last_on_page : field_on_page - 1;
+ if (Field_Is_Selectable(*field_on_page))
+ break;
+ }
+ while (field != (*field_on_page));
+
+ return (*field_on_page);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static FIELD *Sorted_Next_Field(FIELD * field)
+|
+| Description : Get the next field after the given field on the current
+| page. The order of fields is the one defined by the
+| (row,column) geometry, rows are major.
+|
+| Return Values : Pointer to the next field.
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static FIELD *
+Sorted_Next_Field(FIELD *field)
+{
+ FIELD *field_on_page = field;
+
+ do
+ {
+ field_on_page = field_on_page->snext;
+ if (Field_Is_Selectable(field_on_page))
+ break;
+ }
+ while (field_on_page != field);
+
+ return (field_on_page);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static FIELD *Sorted_Previous_Field(FIELD * field)
+|
+| Description : Get the previous field before the given field on the
+| current page. The order of fields is the one defined
+| by the (row,column) geometry, rows are major.
+|
+| Return Values : Pointer to the previous field.
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static FIELD *
+Sorted_Previous_Field(FIELD *field)
+{
+ FIELD *field_on_page = field;
+
+ do
+ {
+ field_on_page = field_on_page->sprev;
+ if (Field_Is_Selectable(field_on_page))
+ break;
+ }
+ while (field_on_page != field);
+
+ return (field_on_page);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static FIELD *Left_Neighbor_Field(FIELD * field)
+|
+| Description : Get the left neighbor of the field on the same line
+| and the same page. Cycles through the line.
+|
+| Return Values : Pointer to left neighbor field.
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static FIELD *
+Left_Neighbor_Field(FIELD *field)
+{
+ FIELD *field_on_page = field;
+
+ /* For a field that has really a left neighbor, the while clause
+ immediately fails and the loop is left, positioned at the right
+ neighbor. Otherwise we cycle backwards through the sorted field list
+ until we enter the same line (from the right end).
+ */
+ do
+ {
+ field_on_page = Sorted_Previous_Field(field_on_page);
+ }
+ while (field_on_page->frow != field->frow);
+
+ return (field_on_page);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static FIELD *Right_Neighbor_Field(FIELD * field)
+|
+| Description : Get the right neighbor of the field on the same line
+| and the same page.
+|
+| Return Values : Pointer to right neighbor field.
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static FIELD *
+Right_Neighbor_Field(FIELD *field)
+{
+ FIELD *field_on_page = field;
+
+ /* See the comments on Left_Neighbor_Field to understand how it works */
+ do
+ {
+ field_on_page = Sorted_Next_Field(field_on_page);
+ }
+ while (field_on_page->frow != field->frow);
+
+ return (field_on_page);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static FIELD *Upper_Neighbor_Field(FIELD * field)
+|
+| Description : Because of the row-major nature of sorting the fields,
+| it is more difficult to define whats the upper neighbor
+| field really means. We define that it must be on a
+| 'previous' line (cyclic order!) and is the rightmost
+| field laying on the left side of the given field. If
+| this set is empty, we take the first field on the line.
+|
+| Return Values : Pointer to the upper neighbor field.
++--------------------------------------------------------------------------*/
+static FIELD *
+Upper_Neighbor_Field(FIELD *field)
+{
+ FIELD *field_on_page = field;
+ int frow = field->frow;
+ int fcol = field->fcol;
+
+ /* Walk back to the 'previous' line. The second term in the while clause
+ just guarantees that we stop if we cycled through the line because
+ there might be no 'previous' line if the page has just one line.
+ */
+ do
+ {
+ field_on_page = Sorted_Previous_Field(field_on_page);
+ }
+ while (field_on_page->frow == frow && field_on_page->fcol != fcol);
+
+ if (field_on_page->frow != frow)
+ {
+ /* We really found a 'previous' line. We are positioned at the
+ rightmost field on this line */
+ frow = field_on_page->frow;
+
+ /* We walk to the left as long as we are really right of the
+ field. */
+ while (field_on_page->frow == frow && field_on_page->fcol > fcol)
+ field_on_page = Sorted_Previous_Field(field_on_page);
+
+ /* If we wrapped, just go to the right which is the first field on
+ the row */
+ if (field_on_page->frow != frow)
+ field_on_page = Sorted_Next_Field(field_on_page);
+ }
+
+ return (field_on_page);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static FIELD *Down_Neighbor_Field(FIELD * field)
+|
+| Description : Because of the row-major nature of sorting the fields,
+| its more difficult to define whats the down neighbor
+| field really means. We define that it must be on a
+| 'next' line (cyclic order!) and is the leftmost
+| field laying on the right side of the given field. If
+| this set is empty, we take the last field on the line.
+|
+| Return Values : Pointer to the upper neighbor field.
++--------------------------------------------------------------------------*/
+static FIELD *
+Down_Neighbor_Field(FIELD *field)
+{
+ FIELD *field_on_page = field;
+ int frow = field->frow;
+ int fcol = field->fcol;
+
+ /* Walk forward to the 'next' line. The second term in the while clause
+ just guarantees that we stop if we cycled through the line because
+ there might be no 'next' line if the page has just one line.
+ */
+ do
+ {
+ field_on_page = Sorted_Next_Field(field_on_page);
+ }
+ while (field_on_page->frow == frow && field_on_page->fcol != fcol);
+
+ if (field_on_page->frow != frow)
+ {
+ /* We really found a 'next' line. We are positioned at the rightmost
+ field on this line */
+ frow = field_on_page->frow;
+
+ /* We walk to the right as long as we are really left of the
+ field. */
+ while (field_on_page->frow == frow && field_on_page->fcol < fcol)
+ field_on_page = Sorted_Next_Field(field_on_page);
+
+ /* If we wrapped, just go to the left which is the last field on
+ the row */
+ if (field_on_page->frow != frow)
+ field_on_page = Sorted_Previous_Field(field_on_page);
+ }
+
+ return (field_on_page);
+}
+
+/*----------------------------------------------------------------------------
+ Inter-Field Navigation routines
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int Inter_Field_Navigation(
+| int (* const fct) (FORM *),
+| FORM * form)
+|
+| Description : Generic behavior for changing the current field, the
+| field is left and a new field is entered. So the field
+| must be validated and the field init/term hooks must
+| be called.
+|
+| Return Values : E_OK - success
+| E_INVALID_FIELD - field is invalid
+| some other - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+Inter_Field_Navigation(int (*const fct) (FORM *), FORM *form)
+{
+ int res;
+
+ if (!_nc_Internal_Validation(form))
+ res = E_INVALID_FIELD;
+ else
+ {
+ Call_Hook(form, fieldterm);
+ res = fct(form);
+ Call_Hook(form, fieldinit);
+ }
+ return res;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FN_Next_Field(FORM * form)
+|
+| Description : Move to the next field on the current page of the form
+|
+| Return Values : E_OK - success
+| != E_OK - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+FN_Next_Field(FORM *form)
+{
+ T((T_CALLED("FN_Next_Field(%p)"), (void *)form));
+ returnCode(_nc_Set_Current_Field(form,
+ Next_Field_On_Page(form->current)));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FN_Previous_Field(FORM * form)
+|
+| Description : Move to the previous field on the current page of the
+| form
+|
+| Return Values : E_OK - success
+| != E_OK - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+FN_Previous_Field(FORM *form)
+{
+ T((T_CALLED("FN_Previous_Field(%p)"), (void *)form));
+ returnCode(_nc_Set_Current_Field(form,
+ Previous_Field_On_Page(form->current)));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FN_First_Field(FORM * form)
+|
+| Description : Move to the first field on the current page of the form
+|
+| Return Values : E_OK - success
+| != E_OK - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+FN_First_Field(FORM *form)
+{
+ T((T_CALLED("FN_First_Field(%p)"), (void *)form));
+ returnCode(_nc_Set_Current_Field(form,
+ Next_Field_On_Page(form->field[form->page[form->curpage].pmax])));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FN_Last_Field(FORM * form)
+|
+| Description : Move to the last field on the current page of the form
+|
+| Return Values : E_OK - success
+| != E_OK - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+FN_Last_Field(FORM *form)
+{
+ T((T_CALLED("FN_Last_Field(%p)"), (void *)form));
+ returnCode(
+ _nc_Set_Current_Field(form,
+ Previous_Field_On_Page(form->field[form->page[form->curpage].pmin])));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FN_Sorted_Next_Field(FORM * form)
+|
+| Description : Move to the sorted next field on the current page
+| of the form.
+|
+| Return Values : E_OK - success
+| != E_OK - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+FN_Sorted_Next_Field(FORM *form)
+{
+ T((T_CALLED("FN_Sorted_Next_Field(%p)"), (void *)form));
+ returnCode(_nc_Set_Current_Field(form,
+ Sorted_Next_Field(form->current)));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FN_Sorted_Previous_Field(FORM * form)
+|
+| Description : Move to the sorted previous field on the current page
+| of the form.
+|
+| Return Values : E_OK - success
+| != E_OK - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+FN_Sorted_Previous_Field(FORM *form)
+{
+ T((T_CALLED("FN_Sorted_Previous_Field(%p)"), (void *)form));
+ returnCode(_nc_Set_Current_Field(form,
+ Sorted_Previous_Field(form->current)));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FN_Sorted_First_Field(FORM * form)
+|
+| Description : Move to the sorted first field on the current page
+| of the form.
+|
+| Return Values : E_OK - success
+| != E_OK - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+FN_Sorted_First_Field(FORM *form)
+{
+ T((T_CALLED("FN_Sorted_First_Field(%p)"), (void *)form));
+ returnCode(_nc_Set_Current_Field(form,
+ Sorted_Next_Field(form->field[form->page[form->curpage].smax])));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FN_Sorted_Last_Field(FORM * form)
+|
+| Description : Move to the sorted last field on the current page
+| of the form.
+|
+| Return Values : E_OK - success
+| != E_OK - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+FN_Sorted_Last_Field(FORM *form)
+{
+ T((T_CALLED("FN_Sorted_Last_Field(%p)"), (void *)form));
+ returnCode(_nc_Set_Current_Field(form,
+ Sorted_Previous_Field(form->field[form->page[form->curpage].smin])));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FN_Left_Field(FORM * form)
+|
+| Description : Get the field on the left of the current field on the
+| same line and the same page. Cycles through the line.
+|
+| Return Values : E_OK - success
+| != E_OK - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+FN_Left_Field(FORM *form)
+{
+ T((T_CALLED("FN_Left_Field(%p)"), (void *)form));
+ returnCode(_nc_Set_Current_Field(form,
+ Left_Neighbor_Field(form->current)));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FN_Right_Field(FORM * form)
+|
+| Description : Get the field on the right of the current field on the
+| same line and the same page. Cycles through the line.
+|
+| Return Values : E_OK - success
+| != E_OK - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+FN_Right_Field(FORM *form)
+{
+ T((T_CALLED("FN_Right_Field(%p)"), (void *)form));
+ returnCode(_nc_Set_Current_Field(form,
+ Right_Neighbor_Field(form->current)));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FN_Up_Field(FORM * form)
+|
+| Description : Get the upper neighbor of the current field. This
+| cycles through the page. See the comments of the
+| Upper_Neighbor_Field function to understand how
+| 'upper' is defined.
+|
+| Return Values : E_OK - success
+| != E_OK - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+FN_Up_Field(FORM *form)
+{
+ T((T_CALLED("FN_Up_Field(%p)"), (void *)form));
+ returnCode(_nc_Set_Current_Field(form,
+ Upper_Neighbor_Field(form->current)));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int FN_Down_Field(FORM * form)
+|
+| Description : Get the down neighbor of the current field. This
+| cycles through the page. See the comments of the
+| Down_Neighbor_Field function to understand how
+| 'down' is defined.
+|
+| Return Values : E_OK - success
+| != E_OK - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+FN_Down_Field(FORM *form)
+{
+ T((T_CALLED("FN_Down_Field(%p)"), (void *)form));
+ returnCode(_nc_Set_Current_Field(form,
+ Down_Neighbor_Field(form->current)));
+}
+/*----------------------------------------------------------------------------
+ END of Field Navigation routines
+ --------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+ Helper routines for Page Navigation
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int _nc_Set_Form_Page(FORM * form,
+| int page,
+| FIELD * field)
+|
+| Description : Make the given page number the current page and make
+| the given field the current field on the page. If
+| for the field NULL is given, make the first field on
+| the page the current field. The routine acts only
+| if the requested page is not the current page.
+|
+| Return Values : E_OK - success
+| != E_OK - error from subordinate call
+| E_BAD_ARGUMENT - invalid field pointer
+| E_SYSTEM_ERROR - some severe basic error
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+_nc_Set_Form_Page(FORM *form, int page, FIELD *field)
+{
+ int res = E_OK;
+
+ if ((form->curpage != page))
+ {
+ FIELD *last_field, *field_on_page;
+
+ werase(Get_Form_Window(form));
+ form->curpage = page;
+ last_field = field_on_page = form->field[form->page[page].smin];
+ do
+ {
+ if (field_on_page->opts & O_VISIBLE)
+ if ((res = Display_Field(field_on_page)) != E_OK)
+ return (res);
+ field_on_page = field_on_page->snext;
+ }
+ while (field_on_page != last_field);
+
+ if (field)
+ res = _nc_Set_Current_Field(form, field);
+ else
+ /* N.B.: we don't encapsulate this by Inter_Field_Navigation(),
+ because this is already executed in a page navigation
+ context that contains field navigation
+ */
+ res = FN_First_Field(form);
+ }
+ return (res);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int Next_Page_Number(const FORM * form)
+|
+| Description : Calculate the page number following the current page
+| number. This cycles if the highest page number is
+| reached.
+|
+| Return Values : The next page number
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static int
+Next_Page_Number(const FORM *form)
+{
+ return (form->curpage + 1) % form->maxpage;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int Previous_Page_Number(const FORM * form)
+|
+| Description : Calculate the page number before the current page
+| number. This cycles if the first page number is
+| reached.
+|
+| Return Values : The previous page number
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static int
+Previous_Page_Number(const FORM *form)
+{
+ return (form->curpage != 0 ? form->curpage - 1 : form->maxpage - 1);
+}
+
+/*----------------------------------------------------------------------------
+ Page Navigation routines
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int Page_Navigation(
+| int (* const fct) (FORM *),
+| FORM * form)
+|
+| Description : Generic behavior for changing a page. This means
+| that the field is left and a new field is entered.
+| So the field must be validated and the field init/term
+| hooks must be called. Because also the page is changed,
+| the forms init/term hooks must be called also.
+|
+| Return Values : E_OK - success
+| E_INVALID_FIELD - field is invalid
+| some other - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+Page_Navigation(int (*const fct) (FORM *), FORM *form)
+{
+ int res;
+
+ if (!_nc_Internal_Validation(form))
+ res = E_INVALID_FIELD;
+ else
+ {
+ Call_Hook(form, fieldterm);
+ Call_Hook(form, formterm);
+ res = fct(form);
+ Call_Hook(form, forminit);
+ Call_Hook(form, fieldinit);
+ }
+ return res;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int PN_Next_Page(FORM * form)
+|
+| Description : Move to the next page of the form
+|
+| Return Values : E_OK - success
+| != E_OK - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+PN_Next_Page(FORM *form)
+{
+ T((T_CALLED("PN_Next_Page(%p)"), (void *)form));
+ returnCode(_nc_Set_Form_Page(form, Next_Page_Number(form), (FIELD *)0));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int PN_Previous_Page(FORM * form)
+|
+| Description : Move to the previous page of the form
+|
+| Return Values : E_OK - success
+| != E_OK - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+PN_Previous_Page(FORM *form)
+{
+ T((T_CALLED("PN_Previous_Page(%p)"), (void *)form));
+ returnCode(_nc_Set_Form_Page(form, Previous_Page_Number(form), (FIELD *)0));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int PN_First_Page(FORM * form)
+|
+| Description : Move to the first page of the form
+|
+| Return Values : E_OK - success
+| != E_OK - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+PN_First_Page(FORM *form)
+{
+ T((T_CALLED("PN_First_Page(%p)"), (void *)form));
+ returnCode(_nc_Set_Form_Page(form, 0, (FIELD *)0));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int PN_Last_Page(FORM * form)
+|
+| Description : Move to the last page of the form
+|
+| Return Values : E_OK - success
+| != E_OK - error from subordinate call
++--------------------------------------------------------------------------*/
+static int
+PN_Last_Page(FORM *form)
+{
+ T((T_CALLED("PN_Last_Page(%p)"), (void *)form));
+ returnCode(_nc_Set_Form_Page(form, form->maxpage - 1, (FIELD *)0));
+}
+
+/*----------------------------------------------------------------------------
+ END of Field Navigation routines
+ --------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+ Helper routines for the core form driver.
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int Data_Entry(FORM * form,int c)
+|
+| Description : Enter character c into at the current position of the
+| current field of the form.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - driver could not process the request
+| E_SYSTEM_ERROR -
++--------------------------------------------------------------------------*/
+static int
+Data_Entry(FORM *form, int c)
+{
+ FIELD *field = form->current;
+ int result = E_REQUEST_DENIED;
+
+ T((T_CALLED("Data_Entry(%p,%s)"), (void *)form, _tracechtype((chtype)c)));
+ if ((field->opts & O_EDIT)
+#if FIX_FORM_INACTIVE_BUG
+ && (field->opts & O_ACTIVE)
+#endif
+ )
+ {
+ if ((field->opts & O_BLANK) &&
+ First_Position_In_Current_Field(form) &&
+ !(form->status & _FCHECK_REQUIRED) &&
+ !(form->status & _WINDOW_MODIFIED))
+ werase(form->w);
+
+ if (form->status & _OVLMODE)
+ {
+ waddch(form->w, (chtype)c);
+ }
+ else
+ /* no _OVLMODE */
+ {
+ bool There_Is_Room = Is_There_Room_For_A_Char_In_Line(form);
+
+ if (!(There_Is_Room ||
+ ((Single_Line_Field(field) && Growable(field)))))
+ RETURN(E_REQUEST_DENIED);
+
+ if (!There_Is_Room && !Field_Grown(field, 1))
+ RETURN(E_SYSTEM_ERROR);
+
+ winsch(form->w, (chtype)c);
+ }
+
+ if ((result = Wrapping_Not_Necessary_Or_Wrapping_Ok(form)) == E_OK)
+ {
+ bool End_Of_Field = (((field->drows - 1) == form->currow) &&
+ ((field->dcols - 1) == form->curcol));
+
+ form->status |= _WINDOW_MODIFIED;
+ if (End_Of_Field && !Growable(field) && (field->opts & O_AUTOSKIP))
+ result = Inter_Field_Navigation(FN_Next_Field, form);
+ else
+ {
+ if (End_Of_Field && Growable(field) && !Field_Grown(field, 1))
+ result = E_SYSTEM_ERROR;
+ else
+ {
+#if USE_WIDEC_SUPPORT
+ /*
+ * We have just added a byte to the form field. It may have
+ * been part of a multibyte character. If it was, the
+ * addch_used field is nonzero and we should not try to move
+ * to a new column.
+ */
+ if (WINDOW_EXT(form->w, addch_used) == 0)
+ IFN_Next_Character(form);
+#else
+ IFN_Next_Character(form);
+#endif
+ result = E_OK;
+ }
+ }
+ }
+ }
+ RETURN(result);
+}
+
+/* Structure to describe the binding of a request code to a function.
+ The member keycode codes the request value as well as the generic
+ routine to use for the request. The code for the generic routine
+ is coded in the upper 16 Bits while the request code is coded in
+ the lower 16 bits.
+
+ In terms of C++ you might think of a request as a class with a
+ virtual method "perform". The different types of request are
+ derived from this base class and overload (or not) the base class
+ implementation of perform.
+*/
+typedef struct
+{
+ int keycode; /* must be at least 32 bit: hi:mode, lo: key */
+ int (*cmd) (FORM *); /* low level driver routine for this key */
+}
+Binding_Info;
+
+/* You may see this is the class-id of the request type class */
+#define ID_PN (0x00000000) /* Page navigation */
+#define ID_FN (0x00010000) /* Inter-Field navigation */
+#define ID_IFN (0x00020000) /* Intra-Field navigation */
+#define ID_VSC (0x00030000) /* Vertical Scrolling */
+#define ID_HSC (0x00040000) /* Horizontal Scrolling */
+#define ID_FE (0x00050000) /* Field Editing */
+#define ID_EM (0x00060000) /* Edit Mode */
+#define ID_FV (0x00070000) /* Field Validation */
+#define ID_CH (0x00080000) /* Choice */
+#define ID_Mask (0xffff0000)
+#define Key_Mask (0x0000ffff)
+#define ID_Shft (16)
+
+/* This array holds all the Binding Infos */
+/* *INDENT-OFF* */
+static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
+{
+ { REQ_NEXT_PAGE |ID_PN ,PN_Next_Page},
+ { REQ_PREV_PAGE |ID_PN ,PN_Previous_Page},
+ { REQ_FIRST_PAGE |ID_PN ,PN_First_Page},
+ { REQ_LAST_PAGE |ID_PN ,PN_Last_Page},
+
+ { REQ_NEXT_FIELD |ID_FN ,FN_Next_Field},
+ { REQ_PREV_FIELD |ID_FN ,FN_Previous_Field},
+ { REQ_FIRST_FIELD |ID_FN ,FN_First_Field},
+ { REQ_LAST_FIELD |ID_FN ,FN_Last_Field},
+ { REQ_SNEXT_FIELD |ID_FN ,FN_Sorted_Next_Field},
+ { REQ_SPREV_FIELD |ID_FN ,FN_Sorted_Previous_Field},
+ { REQ_SFIRST_FIELD |ID_FN ,FN_Sorted_First_Field},
+ { REQ_SLAST_FIELD |ID_FN ,FN_Sorted_Last_Field},
+ { REQ_LEFT_FIELD |ID_FN ,FN_Left_Field},
+ { REQ_RIGHT_FIELD |ID_FN ,FN_Right_Field},
+ { REQ_UP_FIELD |ID_FN ,FN_Up_Field},
+ { REQ_DOWN_FIELD |ID_FN ,FN_Down_Field},
+
+ { REQ_NEXT_CHAR |ID_IFN ,IFN_Next_Character},
+ { REQ_PREV_CHAR |ID_IFN ,IFN_Previous_Character},
+ { REQ_NEXT_LINE |ID_IFN ,IFN_Next_Line},
+ { REQ_PREV_LINE |ID_IFN ,IFN_Previous_Line},
+ { REQ_NEXT_WORD |ID_IFN ,IFN_Next_Word},
+ { REQ_PREV_WORD |ID_IFN ,IFN_Previous_Word},
+ { REQ_BEG_FIELD |ID_IFN ,IFN_Beginning_Of_Field},
+ { REQ_END_FIELD |ID_IFN ,IFN_End_Of_Field},
+ { REQ_BEG_LINE |ID_IFN ,IFN_Beginning_Of_Line},
+ { REQ_END_LINE |ID_IFN ,IFN_End_Of_Line},
+ { REQ_LEFT_CHAR |ID_IFN ,IFN_Left_Character},
+ { REQ_RIGHT_CHAR |ID_IFN ,IFN_Right_Character},
+ { REQ_UP_CHAR |ID_IFN ,IFN_Up_Character},
+ { REQ_DOWN_CHAR |ID_IFN ,IFN_Down_Character},
+
+ { REQ_NEW_LINE |ID_FE ,FE_New_Line},
+ { REQ_INS_CHAR |ID_FE ,FE_Insert_Character},
+ { REQ_INS_LINE |ID_FE ,FE_Insert_Line},
+ { REQ_DEL_CHAR |ID_FE ,FE_Delete_Character},
+ { REQ_DEL_PREV |ID_FE ,FE_Delete_Previous},
+ { REQ_DEL_LINE |ID_FE ,FE_Delete_Line},
+ { REQ_DEL_WORD |ID_FE ,FE_Delete_Word},
+ { REQ_CLR_EOL |ID_FE ,FE_Clear_To_End_Of_Line},
+ { REQ_CLR_EOF |ID_FE ,FE_Clear_To_End_Of_Field},
+ { REQ_CLR_FIELD |ID_FE ,FE_Clear_Field},
+
+ { REQ_OVL_MODE |ID_EM ,EM_Overlay_Mode},
+ { REQ_INS_MODE |ID_EM ,EM_Insert_Mode},
+
+ { REQ_SCR_FLINE |ID_VSC ,VSC_Scroll_Line_Forward},
+ { REQ_SCR_BLINE |ID_VSC ,VSC_Scroll_Line_Backward},
+ { REQ_SCR_FPAGE |ID_VSC ,VSC_Scroll_Page_Forward},
+ { REQ_SCR_BPAGE |ID_VSC ,VSC_Scroll_Page_Backward},
+ { REQ_SCR_FHPAGE |ID_VSC ,VSC_Scroll_Half_Page_Forward},
+ { REQ_SCR_BHPAGE |ID_VSC ,VSC_Scroll_Half_Page_Backward},
+
+ { REQ_SCR_FCHAR |ID_HSC ,HSC_Scroll_Char_Forward},
+ { REQ_SCR_BCHAR |ID_HSC ,HSC_Scroll_Char_Backward},
+ { REQ_SCR_HFLINE |ID_HSC ,HSC_Horizontal_Line_Forward},
+ { REQ_SCR_HBLINE |ID_HSC ,HSC_Horizontal_Line_Backward},
+ { REQ_SCR_HFHALF |ID_HSC ,HSC_Horizontal_Half_Line_Forward},
+ { REQ_SCR_HBHALF |ID_HSC ,HSC_Horizontal_Half_Line_Backward},
+
+ { REQ_VALIDATION |ID_FV ,FV_Validation},
+
+ { REQ_NEXT_CHOICE |ID_CH ,CR_Next_Choice},
+ { REQ_PREV_CHOICE |ID_CH ,CR_Previous_Choice}
+};
+/* *INDENT-ON* */
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int form_driver(FORM * form,int c)
+|
+| Description : This is the workhorse of the forms system. It checks
+| to determine whether the character c is a request or
+| data. If it is a request, the form driver executes
+| the request and returns the result. If it is data
+| (printable character), it enters the data into the
+| current position in the current field. If it is not
+| recognized, the form driver assumes it is an application
+| defined command and returns E_UNKNOWN_COMMAND.
+| Application defined command should be defined relative
+| to MAX_FORM_COMMAND, the maximum value of a request.
+|
+| Return Values : E_OK - success
+| E_SYSTEM_ERROR - system error
+| E_BAD_ARGUMENT - an argument is incorrect
+| E_NOT_POSTED - form is not posted
+| E_INVALID_FIELD - field contents are invalid
+| E_BAD_STATE - called from inside a hook routine
+| E_REQUEST_DENIED - request failed
+| E_NOT_CONNECTED - no fields are connected to the form
+| E_UNKNOWN_COMMAND - command not known
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+form_driver(FORM *form, int c)
+{
+ const Binding_Info *BI = (Binding_Info *) 0;
+ int res = E_UNKNOWN_COMMAND;
+
+ T((T_CALLED("form_driver(%p,%d)"), (void *)form, c));
+
+ if (!form)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (!(form->field))
+ RETURN(E_NOT_CONNECTED);
+
+ assert(form->page);
+
+ if (c == FIRST_ACTIVE_MAGIC)
+ {
+ form->current = _nc_First_Active_Field(form);
+ RETURN(E_OK);
+ }
+
+ assert(form->current &&
+ form->current->buf &&
+ (form->current->form == form)
+ );
+
+ if (form->status & _IN_DRIVER)
+ RETURN(E_BAD_STATE);
+
+ if (!(form->status & _POSTED))
+ RETURN(E_NOT_POSTED);
+
+ if ((c >= MIN_FORM_COMMAND && c <= MAX_FORM_COMMAND) &&
+ ((bindings[c - MIN_FORM_COMMAND].keycode & Key_Mask) == c))
+ BI = &(bindings[c - MIN_FORM_COMMAND]);
+
+ if (BI)
+ {
+ typedef int (*Generic_Method) (int (*const) (FORM *), FORM *);
+ static const Generic_Method Generic_Methods[] =
+ {
+ Page_Navigation, /* overloaded to call field&form hooks */
+ Inter_Field_Navigation, /* overloaded to call field hooks */
+ NULL, /* Intra-Field is generic */
+ Vertical_Scrolling, /* Overloaded to check multi-line */
+ Horizontal_Scrolling, /* Overloaded to check single-line */
+ Field_Editing, /* Overloaded to mark modification */
+ NULL, /* Edit Mode is generic */
+ NULL, /* Field Validation is generic */
+ NULL /* Choice Request is generic */
+ };
+ size_t nMethods = (sizeof(Generic_Methods) / sizeof(Generic_Methods[0]));
+ size_t method = (BI->keycode >> ID_Shft) & 0xffff; /* see ID_Mask */
+
+ if ((method >= nMethods) || !(BI->cmd))
+ res = E_SYSTEM_ERROR;
+ else
+ {
+ Generic_Method fct = Generic_Methods[method];
+
+ if (fct)
+ res = fct(BI->cmd, form);
+ else
+ res = (BI->cmd) (form);
+ }
+ }
+#ifdef NCURSES_MOUSE_VERSION
+ else if (KEY_MOUSE == c)
+ {
+ MEVENT event;
+ WINDOW *win = form->win ? form->win : StdScreen(Get_Form_Screen(form));
+ WINDOW *sub = form->sub ? form->sub : win;
+
+ getmouse(&event);
+ if ((event.bstate & (BUTTON1_CLICKED |
+ BUTTON1_DOUBLE_CLICKED |
+ BUTTON1_TRIPLE_CLICKED))
+ && wenclose(win, event.y, event.x))
+ { /* we react only if the click was in the userwin, that means
+ * inside the form display area or at the decoration window.
+ */
+ int ry = event.y, rx = event.x; /* screen coordinates */
+
+ res = E_REQUEST_DENIED;
+ if (mouse_trafo(&ry, &rx, FALSE))
+ { /* rx, ry are now "curses" coordinates */
+ if (ry < sub->_begy)
+ { /* we clicked above the display region; this is
+ * interpreted as "scroll up" request
+ */
+ if (event.bstate & BUTTON1_CLICKED)
+ res = form_driver(form, REQ_PREV_FIELD);
+ else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ res = form_driver(form, REQ_PREV_PAGE);
+ else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+ res = form_driver(form, REQ_FIRST_FIELD);
+ }
+ else if (ry > sub->_begy + sub->_maxy)
+ { /* we clicked below the display region; this is
+ * interpreted as "scroll down" request
+ */
+ if (event.bstate & BUTTON1_CLICKED)
+ res = form_driver(form, REQ_NEXT_FIELD);
+ else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ res = form_driver(form, REQ_NEXT_PAGE);
+ else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+ res = form_driver(form, REQ_LAST_FIELD);
+ }
+ else if (wenclose(sub, event.y, event.x))
+ { /* Inside the area we try to find the hit item */
+ int i;
+
+ ry = event.y;
+ rx = event.x;
+ if (wmouse_trafo(sub, &ry, &rx, FALSE))
+ {
+ int min_field = form->page[form->curpage].pmin;
+ int max_field = form->page[form->curpage].pmax;
+
+ for (i = min_field; i <= max_field; ++i)
+ {
+ FIELD *field = form->field[i];
+
+ if (Field_Is_Selectable(field)
+ && Field_encloses(field, ry, rx) == E_OK)
+ {
+ res = _nc_Set_Current_Field(form, field);
+ if (res == E_OK)
+ res = _nc_Position_Form_Cursor(form);
+ if (res == E_OK
+ && (event.bstate & BUTTON1_DOUBLE_CLICKED))
+ res = E_UNKNOWN_COMMAND;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ res = E_REQUEST_DENIED;
+ }
+#endif /* NCURSES_MOUSE_VERSION */
+ else if (!(c & (~(int)MAX_REGULAR_CHARACTER)))
+ {
+ /*
+ * If we're using 8-bit characters, iscntrl+isprint cover the whole set.
+ * But with multibyte characters, there is a third possibility, i.e.,
+ * parts of characters that build up into printable characters which are
+ * not considered printable.
+ *
+ * FIXME: the wide-character branch should also use Check_Char().
+ */
+#if USE_WIDEC_SUPPORT
+ if (!iscntrl(UChar(c)))
+#else
+ if (isprint(UChar(c)) &&
+ Check_Char(form, form->current, form->current->type, c,
+ (TypeArgument *)(form->current->arg)))
+#endif
+ res = Data_Entry(form, c);
+ }
+ _nc_Refresh_Current_Field(form);
+ RETURN(res);
+}
+
+/*----------------------------------------------------------------------------
+ Field-Buffer manipulation routines.
+ The effects of setting a buffer are tightly coupled to the core of the form
+ driver logic. This is especially true in the case of growable fields.
+ So I don't separate this into a separate module.
+ --------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_field_buffer(FIELD *field,
+| int buffer, char *value)
+|
+| Description : Set the given buffer of the field to the given value.
+| Buffer 0 stores the displayed content of the field.
+| For dynamic fields this may grow the fieldbuffers if
+| the length of the value exceeds the current buffer
+| length. For buffer 0 only printable values are allowed.
+| For static fields, the value needs not to be zero ter-
+| minated. It is copied up to the length of the buffer.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid argument
+| E_SYSTEM_ERROR - system error
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_field_buffer(FIELD *field, int buffer, const char *value)
+{
+ FIELD_CELL *p;
+ int res = E_OK;
+ unsigned int i;
+ unsigned int len;
+
+#if USE_WIDEC_SUPPORT
+ FIELD_CELL *widevalue = 0;
+#endif
+
+ T((T_CALLED("set_field_buffer(%p,%d,%s)"), (void *)field, buffer, _nc_visbuf(value)));
+
+ if (!field || !value || ((buffer < 0) || (buffer > field->nbuf)))
+ RETURN(E_BAD_ARGUMENT);
+
+ len = Buffer_Length(field);
+
+ if (Growable(field))
+ {
+ /* for a growable field we must assume zero terminated strings, because
+ somehow we have to detect the length of what should be copied.
+ */
+ unsigned int vlen = strlen(value);
+
+ if (vlen > len)
+ {
+ if (!Field_Grown(field,
+ (int)(1 + (vlen - len) / ((field->rows + field->nrow)
+ * field->cols))))
+ RETURN(E_SYSTEM_ERROR);
+
+#if !USE_WIDEC_SUPPORT
+ len = vlen;
+#endif
+ }
+ }
+
+ p = Address_Of_Nth_Buffer(field, buffer);
+
+#if USE_WIDEC_SUPPORT
+ /*
+ * Use addstr's logic for converting a string to an array of cchar_t's.
+ * There should be a better way, but this handles nonspacing characters
+ * and other special cases that we really do not want to handle here.
+ */
+#if NCURSES_EXT_FUNCS
+ if (wresize(field->working, 1, Buffer_Length(field) + 1) == ERR)
+#endif
+ {
+ delwin(field->working);
+ field->working = newpad(1, Buffer_Length(field) + 1);
+ }
+ len = Buffer_Length(field);
+ wclear(field->working);
+ (void)mvwaddstr(field->working, 0, 0, value);
+
+ if ((widevalue = typeCalloc(FIELD_CELL, len + 1)) == 0)
+ {
+ RETURN(E_SYSTEM_ERROR);
+ }
+ else
+ {
+ for (i = 0; i < (unsigned)field->drows; ++i)
+ {
+ (void)mvwin_wchnstr(field->working, 0, i * field->dcols,
+ widevalue + (i * field->dcols),
+ field->dcols);
+ }
+ for (i = 0; i < len; ++i)
+ {
+ if (CharEq(myZEROS, widevalue[i]))
+ {
+ while (i < len)
+ p[i++] = myBLANK;
+ break;
+ }
+ p[i] = widevalue[i];
+ }
+ free(widevalue);
+ }
+#else
+ for (i = 0; i < len; ++i)
+ {
+ if (value[i] == '\0')
+ {
+ while (i < len)
+ p[i++] = myBLANK;
+ break;
+ }
+ p[i] = value[i];
+ }
+#endif
+
+ if (buffer == 0)
+ {
+ int syncres;
+
+ if (((syncres = Synchronize_Field(field)) != E_OK) &&
+ (res == E_OK))
+ res = syncres;
+ if (((syncres = Synchronize_Linked_Fields(field)) != E_OK) &&
+ (res == E_OK))
+ res = syncres;
+ }
+ RETURN(res);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : char *field_buffer(const FIELD *field,int buffer)
+|
+| Description : Return the address of the buffer for the field.
+|
+| Return Values : Pointer to buffer or NULL if arguments were invalid.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(char *)
+field_buffer(const FIELD *field, int buffer)
+{
+ char *result = 0;
+
+ T((T_CALLED("field_buffer(%p,%d)"), (const void *)field, buffer));
+
+ if (field && (buffer >= 0) && (buffer <= field->nbuf))
+ {
+#if USE_WIDEC_SUPPORT
+ FIELD_CELL *data = Address_Of_Nth_Buffer(field, buffer);
+ unsigned need = 0;
+ int size = Buffer_Length(field);
+ int n;
+
+ /* determine the number of bytes needed to store the expanded string */
+ for (n = 0; n < size; ++n)
+ {
+ if (!isWidecExt(data[n]) && data[n].chars[0] != L'\0')
+ {
+ mbstate_t state;
+ size_t next;
+
+ init_mb(state);
+ next = _nc_wcrtomb(0, data[n].chars[0], &state);
+ if (!isEILSEQ(next))
+ need += next;
+ }
+ }
+
+ /* allocate a place to store the expanded string */
+ if (field->expanded[buffer] != 0)
+ free(field->expanded[buffer]);
+ field->expanded[buffer] = typeMalloc(char, need + 1);
+
+ /*
+ * Expand the multibyte data.
+ *
+ * It may also be multi-column data. In that case, the data for a row
+ * may be null-padded to align to the dcols/drows layout (or it may
+ * contain embedded wide-character extensions). Change the null-padding
+ * to blanks as needed.
+ */
+ if ((result = field->expanded[buffer]) != 0)
+ {
+ wclear(field->working);
+ wmove(field->working, 0, 0);
+ for (n = 0; n < size; ++n)
+ {
+ if (!isWidecExt(data[n]) && data[n].chars[0] != L'\0')
+ wadd_wch(field->working, &data[n]);
+ }
+ wmove(field->working, 0, 0);
+ winnstr(field->working, result, (int)need);
+ }
+#else
+ result = Address_Of_Nth_Buffer(field, buffer);
+#endif
+ }
+ returnPtr(result);
+}
+
+#if USE_WIDEC_SUPPORT
+
+/*---------------------------------------------------------------------------
+| Convert a multibyte string to a wide-character string. The result must be
+| freed by the caller.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(wchar_t *)
+_nc_Widen_String(char *source, int *lengthp)
+{
+ wchar_t *result = 0;
+ wchar_t wch;
+ size_t given = strlen(source);
+ size_t tries;
+ int pass;
+ int status;
+
+#ifndef state_unused
+ mbstate_t state;
+#endif
+
+ for (pass = 0; pass < 2; ++pass)
+ {
+ unsigned need = 0;
+ size_t passed = 0;
+
+ while (passed < given)
+ {
+ bool found = FALSE;
+
+ for (tries = 1, status = 0; tries <= (given - passed); ++tries)
+ {
+ int save = source[passed + tries];
+
+ source[passed + tries] = 0;
+ reset_mbytes(state);
+ status = check_mbytes(wch, source + passed, tries, state);
+ source[passed + tries] = (char)save;
+
+ if (status > 0)
+ {
+ found = TRUE;
+ break;
+ }
+ }
+ if (found)
+ {
+ if (pass)
+ {
+ result[need] = wch;
+ }
+ passed += status;
+ ++need;
+ }
+ else
+ {
+ if (pass)
+ {
+ result[need] = source[passed];
+ }
+ ++need;
+ ++passed;
+ }
+ }
+
+ if (!pass)
+ {
+ if (!need)
+ break;
+ result = typeCalloc(wchar_t, need);
+
+ *lengthp = need;
+ if (result == 0)
+ break;
+ }
+ }
+
+ return result;
+}
+#endif
+
+/* frm_driver.c ends here */
diff --git a/payloads/libpayload/curses/form/frm_hook.c b/payloads/libpayload/curses/form/frm_hook.c
new file mode 100644
index 0000000000..7daa396b70
--- /dev/null
+++ b/payloads/libpayload/curses/form/frm_hook.c
@@ -0,0 +1,142 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: frm_hook.c,v 1.15 2010/01/23 21:12:08 tom Exp $")
+
+/* "Template" macro to generate function to set application specific hook */
+#define GEN_HOOK_SET_FUNCTION( typ, name ) \
+NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (FORM *form, Form_Hook func)\
+{\
+ T((T_CALLED("set_" #typ"_"#name"(%p,%p)"), form, func));\
+ (Normalize_Form( form ) -> typ ## name) = func ;\
+ RETURN(E_OK);\
+}
+
+/* "Template" macro to generate function to get application specific hook */
+#define GEN_HOOK_GET_FUNCTION( typ, name ) \
+NCURSES_IMPEXP Form_Hook NCURSES_API typ ## _ ## name ( const FORM *form )\
+{\
+ T((T_CALLED(#typ "_" #name "(%p)"), (const void *) form));\
+ returnFormHook( Normalize_Form( form ) -> typ ## name );\
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_field_init(FORM *form, Form_Hook f)
+|
+| Description : Assigns an application defined initialization function
+| to be called when the form is posted and just after
+| the current field changes.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+GEN_HOOK_SET_FUNCTION(field, init)
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : Form_Hook field_init(const FORM *form)
+|
+| Description : Retrieve field initialization routine address.
+|
+| Return Values : The address or NULL if no hook defined.
++--------------------------------------------------------------------------*/
+GEN_HOOK_GET_FUNCTION(field, init)
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_field_term(FORM *form, Form_Hook f)
+|
+| Description : Assigns an application defined finalization function
+| to be called when the form is unposted and just before
+| the current field changes.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+GEN_HOOK_SET_FUNCTION(field, term)
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : Form_Hook field_term(const FORM *form)
+|
+| Description : Retrieve field finalization routine address.
+|
+| Return Values : The address or NULL if no hook defined.
++--------------------------------------------------------------------------*/
+GEN_HOOK_GET_FUNCTION(field, term)
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_form_init(FORM *form, Form_Hook f)
+|
+| Description : Assigns an application defined initialization function
+| to be called when the form is posted and just after
+| a page change.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+GEN_HOOK_SET_FUNCTION(form, init)
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : Form_Hook form_init(const FORM *form)
+|
+| Description : Retrieve form initialization routine address.
+|
+| Return Values : The address or NULL if no hook defined.
++--------------------------------------------------------------------------*/
+GEN_HOOK_GET_FUNCTION(form, init)
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_form_term(FORM *form, Form_Hook f)
+|
+| Description : Assigns an application defined finalization function
+| to be called when the form is unposted and just before
+| a page change.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+GEN_HOOK_SET_FUNCTION(form, term)
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : Form_Hook form_term(const FORM *form)
+|
+| Description : Retrieve form finalization routine address.
+|
+| Return Values : The address or NULL if no hook defined.
++--------------------------------------------------------------------------*/
+GEN_HOOK_GET_FUNCTION(form, term)
+
+/* frm_hook.c ends here */
diff --git a/payloads/libpayload/curses/form/frm_opts.c b/payloads/libpayload/curses/form/frm_opts.c
new file mode 100644
index 0000000000..3557fcd7ff
--- /dev/null
+++ b/payloads/libpayload/curses/form/frm_opts.c
@@ -0,0 +1,127 @@
+/****************************************************************************
+ * Copyright (c) 1998-2005,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: frm_opts.c,v 1.15 2010/01/23 21:14:36 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_form_opts(FORM *form, Form_Options opts)
+|
+| Description : Turns on the named options and turns off all the
+| remaining options for that form.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid options
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_form_opts(FORM *form, Form_Options opts)
+{
+ T((T_CALLED("set_form_opts(%p,%d)"), (void *)form, opts));
+
+ opts &= ALL_FORM_OPTS;
+ if (opts & ~ALL_FORM_OPTS)
+ RETURN(E_BAD_ARGUMENT);
+ else
+ {
+ Normalize_Form(form)->opts = opts;
+ RETURN(E_OK);
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : Form_Options form_opts(const FORM *)
+|
+| Description : Retrieves the current form options.
+|
+| Return Values : The option flags.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(Form_Options)
+form_opts(const FORM *form)
+{
+ T((T_CALLED("form_opts(%p)"), (const void *)form));
+ returnCode((int)(Normalize_Form(form)->opts & ALL_FORM_OPTS));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int form_opts_on(FORM *form, Form_Options opts)
+|
+| Description : Turns on the named options; no other options are
+| changed.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid options
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+form_opts_on(FORM *form, Form_Options opts)
+{
+ T((T_CALLED("form_opts_on(%p,%d)"), (void *)form, opts));
+
+ opts &= ALL_FORM_OPTS;
+ if (opts & ~ALL_FORM_OPTS)
+ RETURN(E_BAD_ARGUMENT);
+ else
+ {
+ Normalize_Form(form)->opts |= opts;
+ RETURN(E_OK);
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int form_opts_off(FORM *form, Form_Options opts)
+|
+| Description : Turns off the named options; no other options are
+| changed.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid options
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+form_opts_off(FORM *form, Form_Options opts)
+{
+ T((T_CALLED("form_opts_off(%p,%d)"), (void *)form, opts));
+
+ opts &= ALL_FORM_OPTS;
+ if (opts & ~ALL_FORM_OPTS)
+ RETURN(E_BAD_ARGUMENT);
+ else
+ {
+ Normalize_Form(form)->opts &= ~opts;
+ RETURN(E_OK);
+ }
+}
+
+/* frm_opts.c ends here */
diff --git a/payloads/libpayload/curses/form/frm_page.c b/payloads/libpayload/curses/form/frm_page.c
new file mode 100644
index 0000000000..5a76ca9957
--- /dev/null
+++ b/payloads/libpayload/curses/form/frm_page.c
@@ -0,0 +1,106 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: frm_page.c,v 1.11 2010/01/23 21:14:36 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_form_page(FORM * form,int page)
+|
+| Description : Set the page number of the form.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid form pointer or page number
+| E_BAD_STATE - called from a hook routine
+| E_INVALID_FIELD - current field can't be left
+| E_SYSTEM_ERROR - system error
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_form_page(FORM *form, int page)
+{
+ int err = E_OK;
+
+ T((T_CALLED("set_form_page(%p,%d)"), (void *)form, page));
+
+ if (!form || (page < 0) || (page >= form->maxpage))
+ RETURN(E_BAD_ARGUMENT);
+
+ if (!(form->status & _POSTED))
+ {
+ form->curpage = page;
+ form->current = _nc_First_Active_Field(form);
+ }
+ else
+ {
+ if (form->status & _IN_DRIVER)
+ err = E_BAD_STATE;
+ else
+ {
+ if (form->curpage != page)
+ {
+ if (!_nc_Internal_Validation(form))
+ err = E_INVALID_FIELD;
+ else
+ {
+ Call_Hook(form, fieldterm);
+ Call_Hook(form, formterm);
+ err = _nc_Set_Form_Page(form, page, (FIELD *)0);
+ Call_Hook(form, forminit);
+ Call_Hook(form, fieldinit);
+ _nc_Refresh_Current_Field(form);
+ }
+ }
+ }
+ }
+ RETURN(err);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int form_page(const FORM * form)
+|
+| Description : Return the current page of the form.
+|
+| Return Values : >= 0 : current page number
+| -1 : invalid form pointer
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+form_page(const FORM *form)
+{
+ T((T_CALLED("form_page(%p)"), (const void *)form));
+
+ returnCode(Normalize_Form(form)->curpage);
+}
+
+/* frm_page.c ends here */
diff --git a/payloads/libpayload/curses/form/frm_post.c b/payloads/libpayload/curses/form/frm_post.c
new file mode 100644
index 0000000000..8e29aff5f6
--- /dev/null
+++ b/payloads/libpayload/curses/form/frm_post.c
@@ -0,0 +1,124 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: frm_post.c,v 1.10 2010/01/23 21:14:36 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int post_form(FORM * form)
+|
+| Description : Writes the form into its associated subwindow.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid form pointer
+| E_POSTED - form already posted
+| E_NOT_CONNECTED - no fields connected to form
+| E_NO_ROOM - form doesn't fit into subwindow
+| E_SYSTEM_ERROR - system error
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+post_form(FORM *form)
+{
+ WINDOW *formwin;
+ int err;
+ int page;
+
+ T((T_CALLED("post_form(%p)"), (void *)form));
+
+ if (!form)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (form->status & _POSTED)
+ RETURN(E_POSTED);
+
+ if (!(form->field))
+ RETURN(E_NOT_CONNECTED);
+
+ formwin = Get_Form_Window(form);
+ if ((form->cols > getmaxx(formwin)) || (form->rows > getmaxy(formwin)))
+ RETURN(E_NO_ROOM);
+
+ /* reset form->curpage to an invald value. This forces Set_Form_Page
+ to do the page initialization which is required by post_form.
+ */
+ page = form->curpage;
+ form->curpage = -1;
+ if ((err = _nc_Set_Form_Page(form, page, form->current)) != E_OK)
+ RETURN(err);
+
+ form->status |= _POSTED;
+
+ Call_Hook(form, forminit);
+ Call_Hook(form, fieldinit);
+
+ _nc_Refresh_Current_Field(form);
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int unpost_form(FORM * form)
+|
+| Description : Erase form from its associated subwindow.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid form pointer
+| E_NOT_POSTED - form isn't posted
+| E_BAD_STATE - called from a hook routine
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+unpost_form(FORM *form)
+{
+ T((T_CALLED("unpost_form(%p)"), (void *)form));
+
+ if (!form)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (!(form->status & _POSTED))
+ RETURN(E_NOT_POSTED);
+
+ if (form->status & _IN_DRIVER)
+ RETURN(E_BAD_STATE);
+
+ Call_Hook(form, fieldterm);
+ Call_Hook(form, formterm);
+
+ werase(Get_Form_Window(form));
+ delwin(form->w);
+ form->w = (WINDOW *)0;
+ form->status &= ~_POSTED;
+ RETURN(E_OK);
+}
+
+/* frm_post.c ends here */
diff --git a/payloads/libpayload/curses/form/frm_req_name.c b/payloads/libpayload/curses/form/frm_req_name.c
new file mode 100644
index 0000000000..99abd7e3c1
--- /dev/null
+++ b/payloads/libpayload/curses/form/frm_req_name.c
@@ -0,0 +1,170 @@
+/****************************************************************************
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module form_request_name *
+* Routines to handle external names of menu requests *
+***************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: frm_req_name.c,v 1.17 2009/10/10 16:17:01 tom Exp $")
+
+static const char *request_names[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
+{
+ "NEXT_PAGE",
+ "PREV_PAGE",
+ "FIRST_PAGE",
+ "LAST_PAGE",
+
+ "NEXT_FIELD",
+ "PREV_FIELD",
+ "FIRST_FIELD",
+ "LAST_FIELD",
+ "SNEXT_FIELD",
+ "SPREV_FIELD",
+ "SFIRST_FIELD",
+ "SLAST_FIELD",
+ "LEFT_FIELD",
+ "RIGHT_FIELD",
+ "UP_FIELD",
+ "DOWN_FIELD",
+
+ "NEXT_CHAR",
+ "PREV_CHAR",
+ "NEXT_LINE",
+ "PREV_LINE",
+ "NEXT_WORD",
+ "PREV_WORD",
+ "BEG_FIELD",
+ "END_FIELD",
+ "BEG_LINE",
+ "END_LINE",
+ "LEFT_CHAR",
+ "RIGHT_CHAR",
+ "UP_CHAR",
+ "DOWN_CHAR",
+
+ "NEW_LINE",
+ "INS_CHAR",
+ "INS_LINE",
+ "DEL_CHAR",
+ "DEL_PREV",
+ "DEL_LINE",
+ "DEL_WORD",
+ "CLR_EOL",
+ "CLR_EOF",
+ "CLR_FIELD",
+ "OVL_MODE",
+ "INS_MODE",
+ "SCR_FLINE",
+ "SCR_BLINE",
+ "SCR_FPAGE",
+ "SCR_BPAGE",
+ "SCR_FHPAGE",
+ "SCR_BHPAGE",
+ "SCR_FCHAR",
+ "SCR_BCHAR",
+ "SCR_HFLINE",
+ "SCR_HBLINE",
+ "SCR_HFHALF",
+ "SCR_HBHALF",
+
+ "VALIDATION",
+ "NEXT_CHOICE",
+ "PREV_CHOICE"
+};
+
+#define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : const char * form_request_name (int request);
+|
+| Description : Get the external name of a form request.
+|
+| Return Values : Pointer to name - on success
+| NULL - on invalid request code
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(const char *)
+form_request_name(int request)
+{
+ T((T_CALLED("form_request_name(%d)"), request));
+
+ if ((request < MIN_FORM_COMMAND) || (request > MAX_FORM_COMMAND))
+ {
+ SET_ERROR(E_BAD_ARGUMENT);
+ returnCPtr((const char *)0);
+ }
+ else
+ returnCPtr(request_names[request - MIN_FORM_COMMAND]);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int form_request_by_name (const char *str);
+|
+| Description : Search for a request with this name.
+|
+| Return Values : Request Id - on success
+| E_NO_MATCH - request not found
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+form_request_by_name(const char *str)
+{
+ /* because the table is so small, it doesn't really hurt
+ to run sequentially through it.
+ */
+ unsigned int i = 0;
+ char buf[16];
+
+ T((T_CALLED("form_request_by_name(%s)"), _nc_visbuf(str)));
+
+ if (str)
+ {
+ strncpy(buf, str, sizeof(buf));
+ while ((i < sizeof(buf)) && (buf[i] != '\0'))
+ {
+ buf[i] = (char)toupper(UChar(buf[i]));
+ i++;
+ }
+
+ for (i = 0; i < A_SIZE; i++)
+ {
+ if (strncmp(request_names[i], buf, sizeof(buf)) == 0)
+ returnCode(MIN_FORM_COMMAND + (int)i);
+ }
+ }
+ RETURN(E_NO_MATCH);
+}
+
+/* frm_req_name.c ends here */
diff --git a/payloads/libpayload/curses/form/frm_scale.c b/payloads/libpayload/curses/form/frm_scale.c
new file mode 100644
index 0000000000..27e154e243
--- /dev/null
+++ b/payloads/libpayload/curses/form/frm_scale.c
@@ -0,0 +1,69 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: frm_scale.c,v 1.10 2010/01/23 21:14:36 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int scale_form( const FORM *form, int *rows, int *cols )
+|
+| Description : Retrieve size of form
+|
+| Return Values : E_OK - no error
+| E_BAD_ARGUMENT - invalid form pointer
+| E_NOT_CONNECTED - no fields connected to form
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+scale_form(const FORM *form, int *rows, int *cols)
+{
+ T((T_CALLED("scale_form(%p,%p,%p)"),
+ (const void *)form,
+ (void *)rows,
+ (void *)cols));
+
+ if (!form)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (!(form->field))
+ RETURN(E_NOT_CONNECTED);
+
+ if (rows)
+ *rows = form->rows;
+ if (cols)
+ *cols = form->cols;
+
+ RETURN(E_OK);
+}
+
+/* frm_scale.c ends here */
diff --git a/payloads/libpayload/curses/form/frm_sub.c b/payloads/libpayload/curses/form/frm_sub.c
new file mode 100644
index 0000000000..1ab131a593
--- /dev/null
+++ b/payloads/libpayload/curses/form/frm_sub.c
@@ -0,0 +1,86 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995-1997,2009 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: frm_sub.c,v 1.12 2010/01/23 21:14:36 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_form_sub(FORM *form, WINDOW *win)
+|
+| Description : Set the subwindow of the form to win.
+|
+| Return Values : E_OK - success
+| E_POSTED - form is posted
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_form_sub(FORM *form, WINDOW *win)
+{
+ T((T_CALLED("set_form_sub(%p,%p)"), (void *)form, (void *)win));
+
+ if (form && (form->status & _POSTED))
+ RETURN(E_POSTED);
+ else
+ {
+#if NCURSES_SP_FUNCS
+ FORM *f = Normalize_Form(form);
+
+ f->sub = win ? win : StdScreen(Get_Form_Screen(f));
+ RETURN(E_OK);
+#else
+ Normalize_Form(form)->sub = win;
+ RETURN(E_OK);
+#endif
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : WINDOW *form_sub(const FORM *)
+|
+| Description : Retrieve the window of the form.
+|
+| Return Values : The pointer to the Subwindow.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(WINDOW *)
+form_sub(const FORM *form)
+{
+ const FORM *f;
+
+ T((T_CALLED("form_sub(%p)"), (const void *)form));
+
+ f = Normalize_Form(form);
+ returnWin(Get_Form_Window(f));
+}
+
+/* frm_sub.c ends here */
diff --git a/payloads/libpayload/curses/form/frm_user.c b/payloads/libpayload/curses/form/frm_user.c
new file mode 100644
index 0000000000..1375b5e90a
--- /dev/null
+++ b/payloads/libpayload/curses/form/frm_user.c
@@ -0,0 +1,72 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: frm_user.c,v 1.15 2010/01/23 21:14:36 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_form_userptr(FORM *form, void *usrptr)
+|
+| Description : Set the pointer that is reserved in any form to store
+| application relevant informations
+|
+| Return Values : E_OK - on success
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_form_userptr(FORM *form, void *usrptr)
+{
+ T((T_CALLED("set_form_userptr(%p,%p)"), (void *)form, (void *)usrptr));
+
+ Normalize_Form(form)->usrptr = usrptr;
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : void *form_userptr(const FORM *form)
+|
+| Description : Return the pointer that is reserved in any form to
+| store application relevant informations.
+|
+| Return Values : Value of pointer. If no such pointer has been set,
+| NULL is returned
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(void *)
+form_userptr(const FORM *form)
+{
+ T((T_CALLED("form_userptr(%p)"), (const void *)form));
+ returnVoidPtr(Normalize_Form(form)->usrptr);
+}
+
+/* frm_user.c ends here */
diff --git a/payloads/libpayload/curses/form/frm_win.c b/payloads/libpayload/curses/form/frm_win.c
new file mode 100644
index 0000000000..a65cc59f84
--- /dev/null
+++ b/payloads/libpayload/curses/form/frm_win.c
@@ -0,0 +1,92 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: frm_win.c,v 1.16 2010/01/23 21:14:36 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int set_form_win(FORM *form,WINDOW *win)
+|
+| Description : Set the window of the form to win.
+|
+| Return Values : E_OK - success
+| E_POSTED - form is posted
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_form_win(FORM *form, WINDOW *win)
+{
+ T((T_CALLED("set_form_win(%p,%p)"), (void *)form, (void *)win));
+
+ if (form && (form->status & _POSTED))
+ RETURN(E_POSTED);
+ else
+ {
+#if NCURSES_SP_FUNCS
+ FORM *f = Normalize_Form(form);
+
+ f->win = win ? win : StdScreen(Get_Form_Screen(f));
+ RETURN(E_OK);
+#else
+ Normalize_Form(form)->win = win;
+ RETURN(E_OK);
+#endif
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : WINDOW *form_win(const FORM *)
+|
+| Description : Retrieve the window of the form.
+|
+| Return Values : The pointer to the Window or stdscr if there is none.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(WINDOW *)
+form_win(const FORM *form)
+{
+ WINDOW *result;
+ const FORM *f;
+
+ T((T_CALLED("form_win(%p)"), (const void *)form));
+
+ f = Normalize_Form(form);
+#if NCURSES_SP_FUNCS
+ result = (f->win ? f->win : StdScreen(Get_Form_Screen(f)));
+#else
+ result = (f->win ? f->win : stdscr);
+#endif
+ returnWin(result);
+}
+
+/* frm_win.c ends here */
diff --git a/payloads/libpayload/curses/form/fty_alnum.c b/payloads/libpayload/curses/form/fty_alnum.c
new file mode 100644
index 0000000000..cda23dc2b6
--- /dev/null
+++ b/payloads/libpayload/curses/form/fty_alnum.c
@@ -0,0 +1,202 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/***************************************************************************
+* *
+* Author : Juergen Pfeifer *
+* *
+***************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fty_alnum.c,v 1.24 2010/01/23 21:14:36 tom Exp $")
+
+#define thisARG alnumARG
+
+typedef struct
+ {
+ int width;
+ }
+thisARG;
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Generic_This_Type(void *arg)
+|
+| Description : Allocate structure for alphanumeric type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error
++--------------------------------------------------------------------------*/
+static void *
+Generic_This_Type(void *arg)
+{
+ thisARG *argp = (thisARG *) 0;
+
+ if (arg)
+ {
+ argp = typeMalloc(thisARG, 1);
+
+ if (argp)
+ {
+ T((T_CREATE("thisARG %p"), (void *)argp));
+ argp->width = *((int *)arg);
+ }
+ }
+ return ((void *)argp);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Make_This_Type(va_list *ap)
+|
+| Description : Allocate structure for alphanumeric type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error
++--------------------------------------------------------------------------*/
+static void *
+Make_This_Type(va_list *ap)
+{
+ int w = va_arg(*ap, int);
+
+ return Generic_This_Type((void *)&w);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Copy_ThisType(const void *argp)
+|
+| Description : Copy structure for alphanumeric type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error.
++--------------------------------------------------------------------------*/
+static void *
+Copy_This_Type(const void *argp)
+{
+ const thisARG *ap = (const thisARG *)argp;
+ thisARG *result = typeMalloc(thisARG, 1);
+
+ if (result)
+ {
+ T((T_CREATE("thisARG %p"), (void *)result));
+ *result = *ap;
+ }
+
+ return ((void *)result);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void Free_This_Type(void *argp)
+|
+| Description : Free structure for alphanumeric type argument.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+static void
+Free_This_Type(void *argp)
+{
+ if (argp)
+ free(argp);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Check_This_Character(
+| int c,
+| const void *argp)
+|
+| Description : Check a character for the alphanumeric type.
+|
+| Return Values : TRUE - character is valid
+| FALSE - character is invalid
++--------------------------------------------------------------------------*/
+static bool
+Check_This_Character(int c, const void *argp GCC_UNUSED)
+{
+#if USE_WIDEC_SUPPORT
+ if (iswalnum((wint_t) c))
+ return TRUE;
+#endif
+ return (isalnum(UChar(c)) ? TRUE : FALSE);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Check_This_Field(
+| FIELD *field,
+| const void *argp)
+|
+| Description : Validate buffer content to be a valid alphanumeric value
+|
+| Return Values : TRUE - field is valid
+| FALSE - field is invalid
++--------------------------------------------------------------------------*/
+static bool
+Check_This_Field(FIELD *field, const void *argp)
+{
+ int width = ((const thisARG *)argp)->width;
+ unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+ bool result = (width < 0);
+
+ Check_CTYPE_Field(result, bp, width, Check_This_Character);
+ return (result);
+}
+
+static FIELDTYPE typeTHIS =
+{
+ _HAS_ARGS | _RESIDENT,
+ 1, /* this is mutable, so we can't be const */
+ (FIELDTYPE *)0,
+ (FIELDTYPE *)0,
+ Make_This_Type,
+ Copy_This_Type,
+ Free_This_Type,
+ INIT_FT_FUNC(Check_This_Field),
+ INIT_FT_FUNC(Check_This_Character),
+ INIT_FT_FUNC(NULL),
+ INIT_FT_FUNC(NULL),
+#if NCURSES_INTEROP_FUNCS
+ Generic_This_Type
+#endif
+};
+
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALNUM = &typeTHIS;
+
+#if NCURSES_INTEROP_FUNCS
+/* The next routines are to simplify the use of ncurses from
+ programming languages with restictions on interop with C level
+ constructs (e.g. variable access or va_list + ellipsis constructs)
+*/
+NCURSES_EXPORT(FIELDTYPE *)
+_nc_TYPE_ALNUM(void)
+{
+ return TYPE_ALNUM;
+}
+#endif
+
+/* fty_alnum.c ends here */
diff --git a/payloads/libpayload/curses/form/fty_alpha.c b/payloads/libpayload/curses/form/fty_alpha.c
new file mode 100644
index 0000000000..917a9e0ea0
--- /dev/null
+++ b/payloads/libpayload/curses/form/fty_alpha.c
@@ -0,0 +1,202 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/***************************************************************************
+* *
+* Author : Juergen Pfeifer *
+* *
+***************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fty_alpha.c,v 1.26 2010/01/23 21:14:36 tom Exp $")
+
+#define thisARG alphaARG
+
+typedef struct
+ {
+ int width;
+ }
+thisARG;
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Generic_This_Type(va_list *ap)
+|
+| Description : Allocate structure for alpha type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error
++--------------------------------------------------------------------------*/
+static void *
+Generic_This_Type(void *arg)
+{
+ thisARG *argp = (thisARG *) 0;
+
+ if (arg)
+ {
+ argp = typeMalloc(thisARG, 1);
+
+ if (argp)
+ {
+ T((T_CREATE("thisARG %p"), (void *)argp));
+ argp->width = *((int *)arg);
+ }
+ }
+ return ((void *)argp);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Make_This_Type(va_list *ap)
+|
+| Description : Allocate structure for alpha type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error
++--------------------------------------------------------------------------*/
+static void *
+Make_This_Type(va_list *ap)
+{
+ int w = va_arg(*ap, int);
+
+ return Generic_This_Type((void *)&w);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Copy_This_Type(const void * argp)
+|
+| Description : Copy structure for alpha type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error.
++--------------------------------------------------------------------------*/
+static void *
+Copy_This_Type(const void *argp)
+{
+ const thisARG *ap = (const thisARG *)argp;
+ thisARG *result = typeMalloc(thisARG, 1);
+
+ if (result)
+ {
+ T((T_CREATE("thisARG %p"), (void *)result));
+ *result = *ap;
+ }
+
+ return ((void *)result);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void Free_This_Type(void *argp)
+|
+| Description : Free structure for alpha type argument.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+static void
+Free_This_Type(void *argp)
+{
+ if (argp)
+ free(argp);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Check_This_Character(
+| int c,
+| const void *argp)
+|
+| Description : Check a character for the alpha type.
+|
+| Return Values : TRUE - character is valid
+| FALSE - character is invalid
++--------------------------------------------------------------------------*/
+static bool
+Check_This_Character(int c, const void *argp GCC_UNUSED)
+{
+#if USE_WIDEC_SUPPORT
+ if (iswalpha((wint_t) c))
+ return TRUE;
+#endif
+ return (isalpha(UChar(c)) ? TRUE : FALSE);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Check_This_Field(
+| FIELD *field,
+| const void *argp)
+|
+| Description : Validate buffer content to be a valid alpha value
+|
+| Return Values : TRUE - field is valid
+| FALSE - field is invalid
++--------------------------------------------------------------------------*/
+static bool
+Check_This_Field(FIELD *field, const void *argp)
+{
+ int width = ((const thisARG *)argp)->width;
+ unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+ bool result = (width < 0);
+
+ Check_CTYPE_Field(result, bp, width, Check_This_Character);
+ return (result);
+}
+
+static FIELDTYPE typeTHIS =
+{
+ _HAS_ARGS | _RESIDENT,
+ 1, /* this is mutable, so we can't be const */
+ (FIELDTYPE *)0,
+ (FIELDTYPE *)0,
+ Make_This_Type,
+ Copy_This_Type,
+ Free_This_Type,
+ INIT_FT_FUNC(Check_This_Field),
+ INIT_FT_FUNC(Check_This_Character),
+ INIT_FT_FUNC(NULL),
+ INIT_FT_FUNC(NULL),
+#if NCURSES_INTEROP_FUNCS
+ Generic_This_Type
+#endif
+};
+
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALPHA = &typeTHIS;
+
+#if NCURSES_INTEROP_FUNCS
+/* The next routines are to simplify the use of ncurses from
+ programming languages with restictions on interop with C level
+ constructs (e.g. variable access or va_list + ellipsis constructs)
+*/
+NCURSES_EXPORT(FIELDTYPE *)
+_nc_TYPE_ALPHA(void)
+{
+ return TYPE_ALPHA;
+}
+#endif
+
+/* fty_alpha.c ends here */
diff --git a/payloads/libpayload/curses/form/fty_enum.c b/payloads/libpayload/curses/form/fty_enum.c
new file mode 100644
index 0000000000..d3351644ef
--- /dev/null
+++ b/payloads/libpayload/curses/form/fty_enum.c
@@ -0,0 +1,442 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/***************************************************************************
+* *
+* Author : Juergen Pfeifer *
+* *
+***************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fty_enum.c,v 1.26 2010/05/01 21:11:07 tom Exp $")
+
+typedef struct
+ {
+ char **kwds;
+ int count;
+ bool checkcase;
+ bool checkunique;
+ }
+enumARG;
+
+typedef struct
+ {
+ char **kwds;
+ int ccase;
+ int cunique;
+ }
+enumParams;
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Generic_Enum_Type(void * arg)
+|
+| Description : Allocate structure for enumeration type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error
++--------------------------------------------------------------------------*/
+static void *
+Generic_Enum_Type(void *arg)
+{
+ enumARG *argp = (enumARG *)0;
+ enumParams *params = (enumParams *) arg;
+
+ if (params)
+ {
+ argp = typeMalloc(enumARG, 1);
+
+ if (argp)
+ {
+ int cnt = 0;
+ char **kp = (char **)0;
+ char **kwds = (char **)0;
+ char **kptarget;
+ int ccase, cunique;
+
+ T((T_CREATE("enumARG %p"), (void *)argp));
+ kwds = params->kwds;
+ ccase = params->ccase;
+ cunique = params->cunique;
+
+ argp->checkcase = ccase ? TRUE : FALSE;
+ argp->checkunique = cunique ? TRUE : FALSE;
+ argp->kwds = (char **)0;
+
+ kp = kwds;
+ while (kp && (*kp++))
+ cnt++;
+ argp->count = cnt;
+
+ if (cnt > 0)
+ {
+ /* We copy the keywords, because we can't rely on the fact
+ that the caller doesn't relocate or free the memory used
+ for the keywords (maybe he has GC)
+ */
+ argp->kwds = typeMalloc(char *, cnt + 1);
+
+ kp = kwds;
+ if ((kptarget = argp->kwds) != 0)
+ {
+ while (kp && (*kp))
+ {
+ (*kptarget++) = strdup(*kp++);
+ }
+ *kptarget = (char *)0;
+ }
+ }
+ }
+ }
+ return (void *)argp;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Make_Enum_Type( va_list * ap )
+|
+| Description : Allocate structure for enumeration type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error
++--------------------------------------------------------------------------*/
+static void *
+Make_Enum_Type(va_list *ap)
+{
+ enumParams params;
+
+ params.kwds = va_arg(*ap, char **);
+ params.ccase = va_arg(*ap, int);
+ params.cunique = va_arg(*ap, int);
+
+ return Generic_Enum_Type((void *)&params);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Copy_Enum_Type( const void * argp )
+|
+| Description : Copy structure for enumeration type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error.
++--------------------------------------------------------------------------*/
+static void *
+Copy_Enum_Type(const void *argp)
+{
+ enumARG *result = (enumARG *)0;
+
+ if (argp)
+ {
+ const enumARG *ap = (const enumARG *)argp;
+
+ result = typeMalloc(enumARG, 1);
+
+ if (result)
+ {
+ T((T_CREATE("enumARG %p"), (void *)result));
+ *result = *ap;
+
+ if (ap->count > 0)
+ {
+ char **kptarget;
+ char **kp = ap->kwds;
+ result->kwds = typeMalloc(char *, 1 + ap->count);
+
+ if ((kptarget = result->kwds) != 0)
+ {
+ while (kp && (*kp))
+ {
+ (*kptarget++) = strdup(*kp++);
+ }
+ *kptarget = (char *)0;
+ }
+ }
+ }
+ }
+ return (void *)result;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void Free_Enum_Type( void * argp )
+|
+| Description : Free structure for enumeration type argument.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+static void
+Free_Enum_Type(void *argp)
+{
+ if (argp)
+ {
+ const enumARG *ap = (const enumARG *)argp;
+
+ if (ap->kwds && ap->count > 0)
+ {
+ char **kp = ap->kwds;
+ int cnt = 0;
+
+ while (kp && (*kp))
+ {
+ free(*kp++);
+ cnt++;
+ }
+ assert(cnt == ap->count);
+ free(ap->kwds);
+ }
+ free(argp);
+ }
+}
+
+#define SKIP_SPACE(x) while(((*(x))!='\0') && (is_blank(*(x)))) (x)++
+#define NOMATCH 0
+#define PARTIAL 1
+#define EXACT 2
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int Compare(const unsigned char * s,
+| const unsigned char * buf,
+| bool ccase )
+|
+| Description : Check whether or not the text in 'buf' matches the
+| text in 's', at least partial.
+|
+| Return Values : NOMATCH - buffer doesn't match
+| PARTIAL - buffer matches partially
+| EXACT - buffer matches exactly
++--------------------------------------------------------------------------*/
+static int
+Compare(const unsigned char *s, const unsigned char *buf,
+ bool ccase)
+{
+ SKIP_SPACE(buf); /* Skip leading spaces in both texts */
+ SKIP_SPACE(s);
+
+ if (*buf == '\0')
+ {
+ return (((*s) != '\0') ? NOMATCH : EXACT);
+ }
+ else
+ {
+ if (ccase)
+ {
+ while (*s++ == *buf)
+ {
+ if (*buf++ == '\0')
+ return EXACT;
+ }
+ }
+ else
+ {
+ while (toupper(*s++) == toupper(*buf))
+ {
+ if (*buf++ == '\0')
+ return EXACT;
+ }
+ }
+ }
+ /* At this location buf points to the first character where it no longer
+ matches with s. So if only blanks are following, we have a partial
+ match otherwise there is no match */
+ SKIP_SPACE(buf);
+ if (*buf)
+ return NOMATCH;
+
+ /* If it happens that the reference buffer is at its end, the partial
+ match is actually an exact match. */
+ return ((s[-1] != '\0') ? PARTIAL : EXACT);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Check_Enum_Field(
+| FIELD * field,
+| const void * argp)
+|
+| Description : Validate buffer content to be a valid enumeration value
+|
+| Return Values : TRUE - field is valid
+| FALSE - field is invalid
++--------------------------------------------------------------------------*/
+static bool
+Check_Enum_Field(FIELD *field, const void *argp)
+{
+ char **kwds = ((const enumARG *)argp)->kwds;
+ bool ccase = ((const enumARG *)argp)->checkcase;
+ bool unique = ((const enumARG *)argp)->checkunique;
+ unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+ char *s, *t, *p;
+ int res;
+
+ while (kwds && (s = (*kwds++)))
+ {
+ if ((res = Compare((unsigned char *)s, bp, ccase)) != NOMATCH)
+ {
+ p = t = s; /* t is at least a partial match */
+ if ((unique && res != EXACT))
+ {
+ while (kwds && (p = *kwds++))
+ {
+ if ((res = Compare((unsigned char *)p, bp, ccase)) != NOMATCH)
+ {
+ if (res == EXACT)
+ {
+ t = p;
+ break;
+ }
+ else
+ t = (char *)0;
+ }
+ }
+ }
+ if (t)
+ {
+ set_field_buffer(field, 0, t);
+ return TRUE;
+ }
+ if (!p)
+ break;
+ }
+ }
+ return FALSE;
+}
+
+static const char *dummy[] =
+{(char *)0};
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Next_Enum(FIELD * field,
+| const void * argp)
+|
+| Description : Check for the next enumeration value
+|
+| Return Values : TRUE - next value found and loaded
+| FALSE - no next value loaded
++--------------------------------------------------------------------------*/
+static bool
+Next_Enum(FIELD *field, const void *argp)
+{
+ const enumARG *args = (const enumARG *)argp;
+ char **kwds = args->kwds;
+ bool ccase = args->checkcase;
+ int cnt = args->count;
+ unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+
+ if (kwds)
+ {
+ while (cnt--)
+ {
+ if (Compare((unsigned char *)(*kwds++), bp, ccase) == EXACT)
+ break;
+ }
+ if (cnt <= 0)
+ kwds = args->kwds;
+ if ((cnt >= 0) || (Compare((const unsigned char *)dummy, bp, ccase) == EXACT))
+ {
+ set_field_buffer(field, 0, *kwds);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Previous_Enum(
+| FIELD * field,
+| const void * argp)
+|
+| Description : Check for the previous enumeration value
+|
+| Return Values : TRUE - previous value found and loaded
+| FALSE - no previous value loaded
++--------------------------------------------------------------------------*/
+static bool
+Previous_Enum(FIELD *field, const void *argp)
+{
+ const enumARG *args = (const enumARG *)argp;
+ int cnt = args->count;
+ char **kwds = &args->kwds[cnt - 1];
+ bool ccase = args->checkcase;
+ unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+
+ if (kwds)
+ {
+ while (cnt--)
+ {
+ if (Compare((unsigned char *)(*kwds--), bp, ccase) == EXACT)
+ break;
+ }
+
+ if (cnt <= 0)
+ kwds = &args->kwds[args->count - 1];
+
+ if ((cnt >= 0) || (Compare((const unsigned char *)dummy, bp, ccase) == EXACT))
+ {
+ set_field_buffer(field, 0, *kwds);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static FIELDTYPE typeENUM =
+{
+ _HAS_ARGS | _HAS_CHOICE | _RESIDENT,
+ 1, /* this is mutable, so we can't be const */
+ (FIELDTYPE *)0,
+ (FIELDTYPE *)0,
+ Make_Enum_Type,
+ Copy_Enum_Type,
+ Free_Enum_Type,
+ INIT_FT_FUNC(Check_Enum_Field),
+ INIT_FT_FUNC(NULL),
+ INIT_FT_FUNC(Next_Enum),
+ INIT_FT_FUNC(Previous_Enum),
+#if NCURSES_INTEROP_FUNCS
+ Generic_Enum_Type
+#endif
+};
+
+NCURSES_EXPORT_VAR(FIELDTYPE *)
+TYPE_ENUM = &typeENUM;
+
+#if NCURSES_INTEROP_FUNCS
+/* The next routines are to simplify the use of ncurses from
+ programming languages with restictions on interop with C level
+ constructs (e.g. variable access or va_list + ellipsis constructs)
+*/
+NCURSES_EXPORT(FIELDTYPE *)
+_nc_TYPE_ENUM(void)
+{
+ return TYPE_ENUM;
+}
+#endif
+
+/* fty_enum.c ends here */
diff --git a/payloads/libpayload/curses/form/fty_generic.c b/payloads/libpayload/curses/form/fty_generic.c
new file mode 100644
index 0000000000..3e7a575a26
--- /dev/null
+++ b/payloads/libpayload/curses/form/fty_generic.c
@@ -0,0 +1,297 @@
+/****************************************************************************
+ * Copyright (c) 2008-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/***************************************************************************
+* *
+* Author : Juergen Pfeifer *
+* *
+***************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fty_generic.c,v 1.5 2010/01/23 21:14:36 tom Exp $")
+
+/*
+ * This is not a full implementation of a field type, but adds some
+ * support for higher level languages with some restrictions to interop
+ * with C language. Especially the collection of arguments for the
+ * various fieldtypes is not based on the vararg C mechanism, but on a
+ * iterator based callback mechanism that allowes the high level language
+ * to provide the arguments as a structure. Most languages have mechanisms
+ * to layout structures so that they can be passed to C.
+ * The languages can register a new generic fieldtype dynamically and store
+ * a handle (key) to the calling object as an argument. Together with that
+ * it can register a freearg callback, so that the high level language
+ * remains in control of the memory management of the arguments they pass.
+ * The design idea is, that the high-level language - typically a OO
+ * language like C# or Java, uses it's own dispatching mechanisms
+ * (polymorphism) to call the proper check routines responsible for the
+ * argument type. So these language implement typically only one generic
+ * fieldtype they register with the forms library using this call.
+ *
+ * For that purpose we have extended the fieldtype struc by a new element
+ * that gets the arguments from a single struct passed by the caller.
+ *
+ */
+#if NCURSES_INTEROP_FUNCS
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Generic_This_Type( void * arg )
+|
+| Description : We interpret the passed arg just as a handle the
+| calling language uses to keep track of its allocated
+| argument structures. We can simply copy it back.
+|
+| Return Values : Pointer to argument structure
++--------------------------------------------------------------------------*/
+static void *
+Generic_This_Type(void *arg)
+{
+ return (arg);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : FIELDTYPE *_nc_generic_fieldtype(
+| bool (* const field_check)(FIELD *,const void *),
+| bool (* const char_check) (int, const void *),
+| bool (*const next)(FORM*,FIELD*,const void*),
+| bool (*const prev)(FORM*,FIELD*,const void*),
+| void (*freecallback)(void*))
+|
+| Description : Create a new fieldtype. The application programmer must
+| write a field_check and a char_check function and give
+| them as input to this call. A callback to allow the
+| release of the allocated memory must also be provided.
+| For generic field types, we provide some more
+| information about the field as parameters.
+|
+| If an error occurs, errno is set to
+| E_BAD_ARGUMENT - invalid arguments
+| E_SYSTEM_ERROR - system error (no memory)
+|
+| Return Values : Fieldtype pointer or NULL if error occurred
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(FIELDTYPE *)
+_nc_generic_fieldtype(bool (*const field_check) (FORM *, FIELD *, const void *),
+ bool (*const char_check) (int, FORM *, FIELD *, const
+ void *),
+ bool (*const next) (FORM *, FIELD *, const void *),
+ bool (*const prev) (FORM *, FIELD *, const void *),
+ void (*freecallback) (void *))
+{
+ int code = E_SYSTEM_ERROR;
+ FIELDTYPE *res = (FIELDTYPE *)0;
+
+ T((T_CALLED("_nc_generic_fieldtype(%p,%p,%p,%p,%p)"),
+ field_check, char_check, next, prev, freecallback));
+
+ if (field_check || char_check)
+ {
+ res = typeMalloc(FIELDTYPE, 1);
+
+ if (res)
+ {
+ *res = *_nc_Default_FieldType;
+ res->status |= (_HAS_ARGS | _GENERIC);
+ res->fieldcheck.gfcheck = field_check;
+ res->charcheck.gccheck = char_check;
+ res->genericarg = Generic_This_Type;
+ res->freearg = freecallback;
+ res->enum_next.gnext = next;
+ res->enum_prev.gprev = prev;
+ code = E_OK;
+ }
+ }
+ else
+ code = E_BAD_ARGUMENT;
+
+ if (E_OK != code)
+ SET_ERROR(code);
+
+ returnFieldType(res);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static TypeArgument *GenericArgument(
+| const FIELDTYPE* typ,
+| int (*argiterator)(void**),
+| int* err)
+|
+| Description : The iterator callback must browse through all fieldtype
+| parameters that have an argument associated with the
+| type. The iterator returns 1 if the operation to get
+| the next element was successfull, 0 otherwise. If the
+| iterator could move to the next argument, it fills
+| the void* pointer representing the argument into the
+| location provided as argument to the iterator.
+| The err reference is used to keep track of errors.
+|
+| Return Values : Pointer to argument structure
++--------------------------------------------------------------------------*/
+static TypeArgument *
+GenericArgument(const FIELDTYPE *typ,
+ int (*argiterator) (void **), int *err)
+{
+ TypeArgument *res = (TypeArgument *)0;
+
+ if (typ != 0 && (typ->status & _HAS_ARGS) != 0 && err != 0 && argiterator != 0)
+ {
+ if (typ->status & _LINKED_TYPE)
+ {
+ /* Composite fieldtypes keep track internally of their own memory */
+ TypeArgument *p = typeMalloc(TypeArgument, 1);
+
+ if (p)
+ {
+ p->left = GenericArgument(typ->left, argiterator, err);
+ p->right = GenericArgument(typ->right, argiterator, err);
+ return p;
+ }
+ else
+ *err += 1;
+ }
+ else
+ {
+ assert(typ->genericarg != (void *)0);
+ if (typ->genericarg == 0)
+ *err += 1;
+ else
+ {
+ void *argp;
+ int valid = argiterator(&argp);
+
+ if (valid == 0 || argp == 0 ||
+ !(res = (TypeArgument *)typ->genericarg(argp)))
+ {
+ *err += 1;
+ }
+ }
+ }
+ }
+ return res;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int _nc_set_generic_fieldtype(
+| FIELD* field,
+| FIELDTYPE* ftyp,
+| int (*argiterator)(void**))
+|
+| Description : Assign the fieldtype to the field and use the iterator
+| mechanism to get the arguments when a check is
+| performed.
+|
+| Return Values : E_OK if all went well
+| E_SYSTEM_ERROR if an error occurred
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+_nc_set_generic_fieldtype(FIELD *field,
+ FIELDTYPE *ftyp,
+ int (*argiterator) (void **))
+{
+ int code = E_SYSTEM_ERROR;
+ int err = 0;
+
+ if (field)
+ {
+ if (field && field->type)
+ _nc_Free_Type(field);
+
+ field->type = ftyp;
+ if (ftyp)
+ {
+ if (argiterator)
+ {
+ /* The precondition is that the iterator is reset */
+ field->arg = (void *)GenericArgument(field->type, argiterator, &err);
+
+ if (err)
+ {
+ _nc_Free_Argument(field->type, (TypeArgument *)(field->arg));
+ field->type = (FIELDTYPE *)0;
+ field->arg = (void *)0;
+ }
+ else
+ {
+ code = E_OK;
+ if (field->type)
+ field->type->ref++;
+ }
+ }
+ }
+ else
+ {
+ field->arg = (void *)0;
+ code = E_OK;
+ }
+ }
+ return code;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : WINDOW* _nc_form_cursor(
+| FORM* form,
+| int *pRow, int *pCol)
+|
+| Description : Get the current position of the form cursor position
+| We also return the field window
+|
+| Return Values : The fields Window or NULL on error
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(WINDOW *)
+_nc_form_cursor(const FORM *form, int *pRow, int *pCol)
+{
+ int code = E_SYSTEM_ERROR;
+ WINDOW *res = (WINDOW *)0;
+
+ if (!(form == 0 || pRow == 0 || pCol == 0))
+ {
+ *pRow = form->currow;
+ *pCol = form->curcol;
+ res = form->w;
+ code = E_OK;
+ }
+ if (code != E_OK)
+ SET_ERROR(code);
+ return res;
+}
+
+#else
+extern void _nc_fty_generic(void);
+void
+_nc_fty_generic(void)
+{
+}
+#endif
+
+/* fty_generic.c ends here */
diff --git a/payloads/libpayload/curses/form/fty_int.c b/payloads/libpayload/curses/form/fty_int.c
new file mode 100644
index 0000000000..e643ad975f
--- /dev/null
+++ b/payloads/libpayload/curses/form/fty_int.c
@@ -0,0 +1,293 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/***************************************************************************
+* *
+* Author : Juergen Pfeifer *
+* *
+***************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fty_int.c,v 1.25 2010/01/23 21:14:36 tom Exp $")
+
+#if USE_WIDEC_SUPPORT
+#define isDigit(c) (iswdigit((wint_t)(c)) || isdigit(UChar(c)))
+#else
+#define isDigit(c) isdigit(UChar(c))
+#endif
+
+#define thisARG integerARG
+
+typedef struct
+ {
+ int precision;
+ long low;
+ long high;
+ }
+thisARG;
+
+typedef struct
+ {
+ int precision;
+ long low;
+ long high;
+ }
+integerPARM;
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Generic_This_Type( void * arg )
+|
+| Description : Allocate structure for integer type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error
++--------------------------------------------------------------------------*/
+static void *
+Generic_This_Type(void *arg)
+{
+ thisARG *argp = (thisARG *) 0;
+ thisARG *param = (thisARG *) arg;
+
+ if (param)
+ {
+ argp = typeMalloc(thisARG, 1);
+
+ if (argp)
+ {
+ T((T_CREATE("thisARG %p"), (void *)argp));
+ *argp = *param;
+ }
+ }
+ return (void *)argp;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Make_This_Type( va_list * ap )
+|
+| Description : Allocate structure for integer type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error
++--------------------------------------------------------------------------*/
+static void *
+Make_This_Type(va_list *ap)
+{
+ thisARG arg;
+
+ arg.precision = va_arg(*ap, int);
+ arg.low = va_arg(*ap, long);
+ arg.high = va_arg(*ap, long);
+
+ return Generic_This_Type((void *)&arg);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Copy_This_Type(const void * argp)
+|
+| Description : Copy structure for integer type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error.
++--------------------------------------------------------------------------*/
+static void *
+Copy_This_Type(const void *argp)
+{
+ const thisARG *ap = (const thisARG *)argp;
+ thisARG *result = (thisARG *) 0;
+
+ if (argp)
+ {
+ result = typeMalloc(thisARG, 1);
+ if (result)
+ {
+ T((T_CREATE("thisARG %p"), (void *)result));
+ *result = *ap;
+ }
+ }
+ return (void *)result;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void Free_This_Type(void * argp)
+|
+| Description : Free structure for integer type argument.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+static void
+Free_This_Type(void *argp)
+{
+ if (argp)
+ free(argp);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Check_This_Field(
+| FIELD * field,
+| const void * argp)
+|
+| Description : Validate buffer content to be a valid integer value
+|
+| Return Values : TRUE - field is valid
+| FALSE - field is invalid
++--------------------------------------------------------------------------*/
+static bool
+Check_This_Field(FIELD *field, const void *argp)
+{
+ const thisARG *argi = (const thisARG *)argp;
+ long low = argi->low;
+ long high = argi->high;
+ int prec = argi->precision;
+ unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+ char *s = (char *)bp;
+ long val;
+ char buf[100];
+ bool result = FALSE;
+
+ while (*bp && *bp == ' ')
+ bp++;
+ if (*bp)
+ {
+ if (*bp == '-')
+ bp++;
+#if USE_WIDEC_SUPPORT
+ if (*bp)
+ {
+ bool blank = FALSE;
+ int len;
+ int n;
+ wchar_t *list = _nc_Widen_String((char *)bp, &len);
+
+ if (list != 0)
+ {
+ result = TRUE;
+ for (n = 0; n < len; ++n)
+ {
+ if (blank)
+ {
+ if (list[n] != ' ')
+ {
+ result = FALSE;
+ break;
+ }
+ }
+ else if (list[n] == ' ')
+ {
+ blank = TRUE;
+ }
+ else if (!isDigit(list[n]))
+ {
+ result = FALSE;
+ break;
+ }
+ }
+ free(list);
+ }
+ }
+#else
+ while (*bp)
+ {
+ if (!isdigit(UChar(*bp)))
+ break;
+ bp++;
+ }
+ while (*bp && *bp == ' ')
+ bp++;
+ result = (*bp == '\0');
+#endif
+ if (result)
+ {
+ val = atol(s);
+ if (low < high)
+ {
+ if (val < low || val > high)
+ result = FALSE;
+ }
+ if (result)
+ {
+ sprintf(buf, "%.*ld", (prec > 0 ? prec : 0), val);
+ set_field_buffer(field, 0, buf);
+ }
+ }
+ }
+ return (result);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Check_This_Character(
+| int c,
+| const void * argp)
+|
+| Description : Check a character for the integer type.
+|
+| Return Values : TRUE - character is valid
+| FALSE - character is invalid
++--------------------------------------------------------------------------*/
+static bool
+Check_This_Character(int c, const void *argp GCC_UNUSED)
+{
+ return ((isDigit(UChar(c)) || (c == '-')) ? TRUE : FALSE);
+}
+
+static FIELDTYPE typeTHIS =
+{
+ _HAS_ARGS | _RESIDENT,
+ 1, /* this is mutable, so we can't be const */
+ (FIELDTYPE *)0,
+ (FIELDTYPE *)0,
+ Make_This_Type,
+ Copy_This_Type,
+ Free_This_Type,
+ INIT_FT_FUNC(Check_This_Field),
+ INIT_FT_FUNC(Check_This_Character),
+ INIT_FT_FUNC(NULL),
+ INIT_FT_FUNC(NULL),
+#if NCURSES_INTEROP_FUNCS
+ Generic_This_Type
+#endif
+};
+
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_INTEGER = &typeTHIS;
+
+#if NCURSES_INTEROP_FUNCS
+/* The next routines are to simplify the use of ncurses from
+ programming languages with restictions on interop with C level
+ constructs (e.g. variable access or va_list + ellipsis constructs)
+*/
+NCURSES_EXPORT(FIELDTYPE *)
+_nc_TYPE_INTEGER(void)
+{
+ return TYPE_INTEGER;
+}
+#endif
+
+/* fty_int.c ends here */
diff --git a/payloads/libpayload/curses/form/fty_ipv4.c b/payloads/libpayload/curses/form/fty_ipv4.c
new file mode 100644
index 0000000000..8dc04f8c53
--- /dev/null
+++ b/payloads/libpayload/curses/form/fty_ipv4.c
@@ -0,0 +1,120 @@
+/****************************************************************************
+ * Copyright (c) 1998-2006,2009 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/***************************************************************************
+* *
+* Author : Per Foreby, perf@efd.lth.se *
+* *
+***************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fty_ipv4.c,v 1.10 2009/11/07 20:17:58 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Check_IPV4_Field(
+| FIELD * field,
+| const void * argp)
+|
+| Description : Validate buffer content to be a valid IP number (Ver. 4)
+|
+| Return Values : TRUE - field is valid
+| FALSE - field is invalid
++--------------------------------------------------------------------------*/
+static bool
+Check_IPV4_Field(FIELD *field, const void *argp GCC_UNUSED)
+{
+ char *bp = field_buffer(field, 0);
+ int num = 0, len;
+ unsigned int d1, d2, d3, d4;
+
+ if (isdigit(UChar(*bp))) /* Must start with digit */
+ {
+ num = sscanf(bp, "%u.%u.%u.%u%n", &d1, &d2, &d3, &d4, &len);
+ if (num == 4)
+ {
+ bp += len; /* Make bp point to what sscanf() left */
+ while (isspace(UChar(*bp)))
+ bp++; /* Allow trailing whitespace */
+ }
+ }
+ return ((num != 4 || *bp || d1 > 255 || d2 > 255
+ || d3 > 255 || d4 > 255) ? FALSE : TRUE);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Check_IPV4_Character(
+| int c,
+| const void *argp )
+|
+| Description : Check a character for unsigned type or period.
+|
+| Return Values : TRUE - character is valid
+| FALSE - character is invalid
++--------------------------------------------------------------------------*/
+static bool
+Check_IPV4_Character(int c, const void *argp GCC_UNUSED)
+{
+ return ((isdigit(UChar(c)) || (c == '.')) ? TRUE : FALSE);
+}
+
+static FIELDTYPE typeIPV4 =
+{
+ _RESIDENT,
+ 1, /* this is mutable, so we can't be const */
+ (FIELDTYPE *)0,
+ (FIELDTYPE *)0,
+ NULL,
+ NULL,
+ NULL,
+ INIT_FT_FUNC(Check_IPV4_Field),
+ INIT_FT_FUNC(Check_IPV4_Character),
+ INIT_FT_FUNC(NULL),
+ INIT_FT_FUNC(NULL),
+#if NCURSES_INTEROP_FUNCS
+ NULL
+#endif
+};
+
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_IPV4 = &typeIPV4;
+
+#if NCURSES_INTEROP_FUNCS
+/* The next routines are to simplify the use of ncurses from
+ programming languages with restictions on interop with C level
+ constructs (e.g. variable access or va_list + ellipsis constructs)
+*/
+NCURSES_EXPORT(FIELDTYPE *)
+_nc_TYPE_IPV4(void)
+{
+ return TYPE_IPV4;
+}
+#endif
+
+/* fty_ipv4.c ends here */
diff --git a/payloads/libpayload/curses/form/fty_num.c b/payloads/libpayload/curses/form/fty_num.c
new file mode 100644
index 0000000000..4bd71321d6
--- /dev/null
+++ b/payloads/libpayload/curses/form/fty_num.c
@@ -0,0 +1,339 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/***************************************************************************
+* *
+* Author : Juergen Pfeifer *
+* *
+***************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fty_num.c,v 1.28 2010/01/23 21:14:36 tom Exp $")
+
+#if HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
+#if HAVE_LOCALE_H
+#define isDecimalPoint(c) ((c) == ((L && L->decimal_point) ? *(L->decimal_point) : '.'))
+#else
+#define isDecimalPoint(c) ((c) == '.')
+#endif
+
+#if USE_WIDEC_SUPPORT
+#define isDigit(c) (iswdigit((wint_t)(c)) || isdigit(UChar(c)))
+#else
+#define isDigit(c) isdigit(UChar(c))
+#endif
+
+#define thisARG numericARG
+
+typedef struct
+ {
+ int precision;
+ double low;
+ double high;
+ struct lconv *L;
+ }
+thisARG;
+
+typedef struct
+ {
+ int precision;
+ double low;
+ double high;
+ }
+thisPARM;
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Generic_This_Type(void * arg)
+|
+| Description : Allocate structure for numeric type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error
++--------------------------------------------------------------------------*/
+static void *
+Generic_This_Type(void *arg)
+{
+ thisARG *argn = (thisARG *) 0;
+ thisPARM *args = (thisPARM *) arg;
+
+ if (args)
+ {
+ argn = typeMalloc(thisARG, 1);
+
+ if (argn)
+ {
+ T((T_CREATE("thisARG %p"), (void *)argn));
+ argn->precision = args->precision;
+ argn->low = args->low;
+ argn->high = args->high;
+
+#if HAVE_LOCALE_H
+ argn->L = localeconv();
+#else
+ argn->L = NULL;
+#endif
+ }
+ }
+ return (void *)argn;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Make_This_Type(va_list * ap)
+|
+| Description : Allocate structure for numeric type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error
++--------------------------------------------------------------------------*/
+static void *
+Make_This_Type(va_list *ap)
+{
+ thisPARM arg;
+
+ arg.precision = va_arg(*ap, int);
+ arg.low = va_arg(*ap, double);
+ arg.high = va_arg(*ap, double);
+
+ return Generic_This_Type((void *)&arg);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Copy_This_Type(const void * argp)
+|
+| Description : Copy structure for numeric type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error.
++--------------------------------------------------------------------------*/
+static void *
+Copy_This_Type(const void *argp)
+{
+ const thisARG *ap = (const thisARG *)argp;
+ thisARG *result = (thisARG *) 0;
+
+ if (argp)
+ {
+ result = typeMalloc(thisARG, 1);
+ if (result)
+ {
+ T((T_CREATE("thisARG %p"), (void *)result));
+ *result = *ap;
+ }
+ }
+ return (void *)result;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void Free_This_Type(void * argp)
+|
+| Description : Free structure for numeric type argument.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+static void
+Free_This_Type(void *argp)
+{
+ if (argp)
+ free(argp);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Check_This_Field(FIELD * field,
+| const void * argp)
+|
+| Description : Validate buffer content to be a valid numeric value
+|
+| Return Values : TRUE - field is valid
+| FALSE - field is invalid
++--------------------------------------------------------------------------*/
+static bool
+Check_This_Field(FIELD *field, const void *argp)
+{
+ const thisARG *argn = (const thisARG *)argp;
+ double low = argn->low;
+ double high = argn->high;
+ int prec = argn->precision;
+ unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+ char *s = (char *)bp;
+ double val = 0.0;
+ struct lconv *L = argn->L;
+ char buf[64];
+ bool result = FALSE;
+
+ while (*bp && *bp == ' ')
+ bp++;
+ if (*bp)
+ {
+ if (*bp == '-' || *bp == '+')
+ bp++;
+#if USE_WIDEC_SUPPORT
+ if (*bp)
+ {
+ bool blank = FALSE;
+ int state = 0;
+ int len;
+ int n;
+ wchar_t *list = _nc_Widen_String((char *)bp, &len);
+
+ if (list != 0)
+ {
+ result = TRUE;
+ for (n = 0; n < len; ++n)
+ {
+ if (blank)
+ {
+ if (list[n] != ' ')
+ {
+ result = FALSE;
+ break;
+ }
+ }
+ else if (list[n] == ' ')
+ {
+ blank = TRUE;
+ }
+ else if (isDecimalPoint(list[n]))
+ {
+ if (++state > 1)
+ {
+ result = FALSE;
+ break;
+ }
+ }
+ else if (!isDigit(list[n]))
+ {
+ result = FALSE;
+ break;
+ }
+ }
+ free(list);
+ }
+ }
+#else
+ while (*bp)
+ {
+ if (!isdigit(UChar(*bp)))
+ break;
+ bp++;
+ }
+ if (isDecimalPoint(*bp))
+ {
+ bp++;
+ while (*bp)
+ {
+ if (!isdigit(UChar(*bp)))
+ break;
+ bp++;
+ }
+ }
+ while (*bp && *bp == ' ')
+ bp++;
+ result = (*bp == '\0');
+#endif
+ if (result)
+ {
+ val = atof(s);
+ if (low < high)
+ {
+ if (val < low || val > high)
+ result = FALSE;
+ }
+ if (result)
+ {
+ sprintf(buf, "%.*f", (prec > 0 ? prec : 0), val);
+ set_field_buffer(field, 0, buf);
+ }
+ }
+ }
+ return (result);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Check_This_Character(
+| int c,
+| const void * argp)
+|
+| Description : Check a character for the numeric type.
+|
+| Return Values : TRUE - character is valid
+| FALSE - character is invalid
++--------------------------------------------------------------------------*/
+static bool
+Check_This_Character(int c, const void *argp)
+{
+ const thisARG *argn = (const thisARG *)argp;
+ struct lconv *L = argn->L;
+
+ return ((isDigit(c) ||
+ c == '+' ||
+ c == '-' ||
+ isDecimalPoint(c))
+ ? TRUE
+ : FALSE);
+}
+
+static FIELDTYPE typeTHIS =
+{
+ _HAS_ARGS | _RESIDENT,
+ 1, /* this is mutable, so we can't be const */
+ (FIELDTYPE *)0,
+ (FIELDTYPE *)0,
+ Make_This_Type,
+ Copy_This_Type,
+ Free_This_Type,
+ INIT_FT_FUNC(Check_This_Field),
+ INIT_FT_FUNC(Check_This_Character),
+ INIT_FT_FUNC(NULL),
+ INIT_FT_FUNC(NULL),
+#if NCURSES_INTEROP_FUNCS
+ Generic_This_Type
+#endif
+};
+
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_NUMERIC = &typeTHIS;
+
+#if NCURSES_INTEROP_FUNCS
+/* The next routines are to simplify the use of ncurses from
+ programming languages with restictions on interop with C level
+ constructs (e.g. variable access or va_list + ellipsis constructs)
+*/
+NCURSES_EXPORT(FIELDTYPE *)
+_nc_TYPE_NUMERIC(void)
+{
+ return TYPE_NUMERIC;
+}
+#endif
+
+/* fty_num.c ends here */
diff --git a/payloads/libpayload/curses/form/fty_regex.c b/payloads/libpayload/curses/form/fty_regex.c
new file mode 100644
index 0000000000..2c0a4caa6b
--- /dev/null
+++ b/payloads/libpayload/curses/form/fty_regex.c
@@ -0,0 +1,350 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/***************************************************************************
+* *
+* Author : Juergen Pfeifer *
+* *
+***************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fty_regex.c,v 1.24 2010/01/23 21:14:37 tom Exp $")
+
+#if HAVE_REGEX_H_FUNCS /* We prefer POSIX regex */
+#include <regex.h>
+
+typedef struct
+ {
+ regex_t *pRegExp;
+ unsigned long *refCount;
+ }
+RegExp_Arg;
+
+#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
+#undef RETURN
+static int reg_errno;
+
+static char *
+RegEx_Init(char *instring)
+{
+ reg_errno = 0;
+ return instring;
+}
+
+static char *
+RegEx_Error(int code)
+{
+ reg_errno = code;
+ return 0;
+}
+
+#define INIT register char *sp = RegEx_Init(instring);
+#define GETC() (*sp++)
+#define PEEKC() (*sp)
+#define UNGETC(c) (--sp)
+#define RETURN(c) return(c)
+#define ERROR(c) return RegEx_Error(c)
+
+#if HAVE_REGEXP_H_FUNCS
+#include <regexp.h>
+#else
+#include <regexpr.h>
+#endif
+
+typedef struct
+{
+ char *compiled_expression;
+ unsigned long *refCount;
+}
+RegExp_Arg;
+
+/* Maximum Length we allow for a compiled regular expression */
+#define MAX_RX_LEN (2048)
+#define RX_INCREMENT (256)
+
+#endif
+
+#if HAVE_REGEX_H_FUNCS | HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
+# define MAYBE_UNUSED
+#else
+# define MAYBE_UNUSED GCC_UNUSED
+#endif
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Generic_RegularExpression_Type(void * arg)
+|
+| Description : Allocate structure for regex type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error
++--------------------------------------------------------------------------*/
+static void *
+Generic_RegularExpression_Type(void *arg MAYBE_UNUSED)
+{
+#if HAVE_REGEX_H_FUNCS
+ char *rx = (char *)arg;
+ RegExp_Arg *preg = (RegExp_Arg *)0;
+
+ if (rx)
+ {
+ preg = typeMalloc(RegExp_Arg, 1);
+
+ if (preg)
+ {
+ T((T_CREATE("RegExp_Arg %p"), (void *)preg));
+ if (((preg->pRegExp = typeMalloc(regex_t, 1)) != 0)
+ && !regcomp(preg->pRegExp, rx,
+ (REG_EXTENDED | REG_NOSUB | REG_NEWLINE)))
+ {
+ T((T_CREATE("regex_t %p"), (void *)preg->pRegExp));
+ preg->refCount = typeMalloc(unsigned long, 1);
+
+ *(preg->refCount) = 1;
+ }
+ else
+ {
+ if (preg->pRegExp)
+ free(preg->pRegExp);
+ free(preg);
+ preg = (RegExp_Arg *)0;
+ }
+ }
+ }
+ return ((void *)preg);
+#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
+ char *rx = (char *)arg;
+ RegExp_Arg *pArg = (RegExp_Arg *)0;
+
+ if (rx)
+ {
+ pArg = typeMalloc(RegExp_Arg, 1);
+
+ if (pArg)
+ {
+ int blen = RX_INCREMENT;
+
+ T((T_CREATE("RegExp_Arg %p"), pArg));
+ pArg->compiled_expression = NULL;
+ pArg->refCount = typeMalloc(unsigned long, 1);
+
+ *(pArg->refCount) = 1;
+
+ do
+ {
+ char *buf = typeMalloc(char, blen);
+
+ if (buf)
+ {
+#if HAVE_REGEXP_H_FUNCS
+ char *last_pos = compile(rx, buf, &buf[blen], '\0');
+
+#else /* HAVE_REGEXPR_H_FUNCS */
+ char *last_pos = compile(rx, buf, &buf[blen]);
+#endif
+ if (reg_errno)
+ {
+ free(buf);
+ if (reg_errno == 50)
+ blen += RX_INCREMENT;
+ else
+ {
+ free(pArg);
+ pArg = NULL;
+ break;
+ }
+ }
+ else
+ {
+ pArg->compiled_expression = buf;
+ break;
+ }
+ }
+ }
+ while (blen <= MAX_RX_LEN);
+ }
+ if (pArg && !pArg->compiled_expression)
+ {
+ free(pArg);
+ pArg = NULL;
+ }
+ }
+ return (void *)pArg;
+#else
+ return 0;
+#endif
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Make_RegularExpression_Type(va_list * ap)
+|
+| Description : Allocate structure for regex type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error
++--------------------------------------------------------------------------*/
+static void *
+Make_RegularExpression_Type(va_list *ap)
+{
+ char *rx = va_arg(*ap, char *);
+
+ return Generic_RegularExpression_Type((void *)rx);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void *Copy_RegularExpression_Type(
+| const void * argp)
+|
+| Description : Copy structure for regex type argument.
+|
+| Return Values : Pointer to argument structure or NULL on error.
++--------------------------------------------------------------------------*/
+static void *
+Copy_RegularExpression_Type(const void *argp MAYBE_UNUSED)
+{
+#if (HAVE_REGEX_H_FUNCS | HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS)
+ const RegExp_Arg *ap = (const RegExp_Arg *)argp;
+ const RegExp_Arg *result = (const RegExp_Arg *)0;
+
+ if (ap)
+ {
+ *(ap->refCount) += 1;
+ result = ap;
+ }
+ return (void *)result;
+#else
+ return 0;
+#endif
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static void Free_RegularExpression_Type(void * argp)
+|
+| Description : Free structure for regex type argument.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+static void
+Free_RegularExpression_Type(void *argp MAYBE_UNUSED)
+{
+#if HAVE_REGEX_H_FUNCS | HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
+ RegExp_Arg *ap = (RegExp_Arg *)argp;
+
+ if (ap)
+ {
+ if (--(*(ap->refCount)) == 0)
+ {
+#if HAVE_REGEX_H_FUNCS
+ if (ap->pRegExp)
+ {
+ free(ap->refCount);
+ regfree(ap->pRegExp);
+ }
+#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
+ if (ap->compiled_expression)
+ {
+ free(ap->refCount);
+ free(ap->compiled_expression);
+ }
+#endif
+ free(ap);
+ }
+ }
+#endif
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Check_RegularExpression_Field(
+| FIELD * field,
+| const void * argp)
+|
+| Description : Validate buffer content to be a valid regular expression
+|
+| Return Values : TRUE - field is valid
+| FALSE - field is invalid
++--------------------------------------------------------------------------*/
+static bool
+Check_RegularExpression_Field(FIELD *field MAYBE_UNUSED,
+ const void *argp MAYBE_UNUSED)
+{
+ bool match = FALSE;
+
+#if HAVE_REGEX_H_FUNCS
+ const RegExp_Arg *ap = (const RegExp_Arg *)argp;
+
+ if (ap && ap->pRegExp)
+ match = (regexec(ap->pRegExp, field_buffer(field, 0), 0, NULL, 0)
+ ? FALSE
+ : TRUE);
+#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
+ RegExp_Arg *ap = (RegExp_Arg *)argp;
+
+ if (ap && ap->compiled_expression)
+ match = (step(field_buffer(field, 0), ap->compiled_expression)
+ ? TRUE
+ : FALSE);
+#endif
+ return match;
+}
+
+static FIELDTYPE typeREGEXP =
+{
+ _HAS_ARGS | _RESIDENT,
+ 1, /* this is mutable, so we can't be const */
+ (FIELDTYPE *)0,
+ (FIELDTYPE *)0,
+ Make_RegularExpression_Type,
+ Copy_RegularExpression_Type,
+ Free_RegularExpression_Type,
+ INIT_FT_FUNC(Check_RegularExpression_Field),
+ INIT_FT_FUNC(NULL),
+ INIT_FT_FUNC(NULL),
+ INIT_FT_FUNC(NULL),
+#if NCURSES_INTEROP_FUNCS
+ Generic_RegularExpression_Type
+#endif
+};
+
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_REGEXP = &typeREGEXP;
+
+#if NCURSES_INTEROP_FUNCS
+/* The next routines are to simplify the use of ncurses from
+ programming languages with restictions on interop with C level
+ constructs (e.g. variable access or va_list + ellipsis constructs)
+*/
+NCURSES_EXPORT(FIELDTYPE *)
+_nc_TYPE_REGEXP(void)
+{
+ return TYPE_REGEXP;
+}
+#endif
+
+/* fty_regex.c ends here */
diff --git a/payloads/libpayload/curses/form/headers b/payloads/libpayload/curses/form/headers
new file mode 100644
index 0000000000..56d72f0122
--- /dev/null
+++ b/payloads/libpayload/curses/form/headers
@@ -0,0 +1,32 @@
+##############################################################################
+# Copyright (c) 1998,2006 Free Software Foundation, Inc. #
+# #
+# Permission is hereby granted, free of charge, to any person obtaining a #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation #
+# the rights to use, copy, modify, merge, publish, distribute, distribute #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the #
+# following conditions: #
+# #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software. #
+# #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
+# DEALINGS IN THE SOFTWARE. #
+# #
+# Except as contained in this notice, the name(s) of the above copyright #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written #
+# authorization. #
+##############################################################################
+#
+# Author: Thomas E. Dickey <dickey@clark.net> 1996
+#
+$(srcdir)/form.h
+# vile:makemode
diff --git a/payloads/libpayload/curses/form/llib-lform b/payloads/libpayload/curses/form/llib-lform
new file mode 100644
index 0000000000..2b6abdcd7c
--- /dev/null
+++ b/payloads/libpayload/curses/form/llib-lform
@@ -0,0 +1,777 @@
+/****************************************************************************
+ * Copyright (c) 1998-2005,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 1996-2005,2010 *
+ ****************************************************************************/
+/* LINTLIBRARY */
+
+/* ./f_trace.c */
+
+#include <form.priv.h>
+
+#undef _nc_retrace_field_ptr
+FIELD **_nc_retrace_field_ptr(
+ FIELD **code)
+ { return(*(FIELD ***)0); }
+
+#undef _nc_retrace_field
+FIELD *_nc_retrace_field(
+ FIELD *code)
+ { return(*(FIELD **)0); }
+
+#undef _nc_retrace_field_type
+FIELDTYPE *_nc_retrace_field_type(
+ FIELDTYPE *code)
+ { return(*(FIELDTYPE **)0); }
+
+#undef _nc_retrace_form
+FORM *_nc_retrace_form(
+ FORM *code)
+ { return(*(FORM **)0); }
+
+#undef _nc_retrace_form_hook
+Form_Hook _nc_retrace_form_hook(
+ Form_Hook code)
+ { return(*(Form_Hook *)0); }
+
+/* ./fld_arg.c */
+
+#undef set_fieldtype_arg
+int set_fieldtype_arg(
+ FIELDTYPE *typ,
+ void *(*const make_arg)(
+ va_list *p1),
+ void *(*const copy_arg)(
+ const void *p1),
+ void (*const free_arg)(
+ void *p1))
+ { return(*(int *)0); }
+
+#undef field_arg
+void *field_arg(
+ const FIELD *field)
+ { return(*(void **)0); }
+
+/* ./fld_attr.c */
+
+#undef set_field_fore
+int set_field_fore(
+ FIELD *field,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef field_fore
+chtype field_fore(
+ const FIELD *field)
+ { return(*(chtype *)0); }
+
+#undef set_field_back
+int set_field_back(
+ FIELD *field,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef field_back
+chtype field_back(
+ const FIELD *field)
+ { return(*(chtype *)0); }
+
+/* ./fld_current.c */
+
+#undef set_current_field
+int set_current_field(
+ FORM *form,
+ FIELD *field)
+ { return(*(int *)0); }
+
+#undef current_field
+FIELD *current_field(
+ const FORM *form)
+ { return(*(FIELD **)0); }
+
+#undef field_index
+int field_index(
+ const FIELD *field)
+ { return(*(int *)0); }
+
+/* ./fld_def.c */
+
+#undef _nc_Default_Field
+FIELD *_nc_Default_Field;
+
+#undef _nc_Make_Argument
+TypeArgument *_nc_Make_Argument(
+ const FIELDTYPE *typ,
+ va_list *ap,
+ int *err)
+ { return(*(TypeArgument **)0); }
+
+#undef _nc_Copy_Argument
+TypeArgument *_nc_Copy_Argument(
+ const FIELDTYPE *typ,
+ const TypeArgument *argp,
+ int *err)
+ { return(*(TypeArgument **)0); }
+
+#undef _nc_Free_Argument
+void _nc_Free_Argument(
+ const FIELDTYPE *typ,
+ TypeArgument *argp)
+ { /* void */ }
+
+#undef _nc_Copy_Type
+NCURSES_BOOL _nc_Copy_Type(
+ FIELD *dst,
+ FIELD const *src)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef _nc_Free_Type
+void _nc_Free_Type(
+ FIELD *field)
+ { /* void */ }
+
+#undef new_field
+FIELD *new_field(
+ int rows,
+ int cols,
+ int frow,
+ int fcol,
+ int nrow,
+ int nbuf)
+ { return(*(FIELD **)0); }
+
+#undef free_field
+int free_field(
+ FIELD *field)
+ { return(*(int *)0); }
+
+/* ./fld_dup.c */
+
+#undef dup_field
+FIELD *dup_field(
+ FIELD *field,
+ int frow,
+ int fcol)
+ { return(*(FIELD **)0); }
+
+/* ./fld_ftchoice.c */
+
+#undef set_fieldtype_choice
+int set_fieldtype_choice(
+ FIELDTYPE *typ,
+ NCURSES_BOOL (*const next_choice)(
+ FIELD *p1,
+ const void *p2),
+ NCURSES_BOOL (*const prev_choice)(
+ FIELD *p1,
+ const void *p2))
+ { return(*(int *)0); }
+
+/* ./fld_ftlink.c */
+
+#undef link_fieldtype
+FIELDTYPE *link_fieldtype(
+ FIELDTYPE *type1,
+ FIELDTYPE *type2)
+ { return(*(FIELDTYPE **)0); }
+
+/* ./fld_info.c */
+
+#undef field_info
+int field_info(
+ const FIELD *field,
+ int *rows,
+ int *cols,
+ int *frow,
+ int *fcol,
+ int *nrow,
+ int *nbuf)
+ { return(*(int *)0); }
+
+#undef dynamic_field_info
+int dynamic_field_info(
+ const FIELD *field,
+ int *drows,
+ int *dcols,
+ int *maxgrow)
+ { return(*(int *)0); }
+
+/* ./fld_just.c */
+
+#undef set_field_just
+int set_field_just(
+ FIELD *field,
+ int just)
+ { return(*(int *)0); }
+
+#undef field_just
+int field_just(
+ const FIELD *field)
+ { return(*(int *)0); }
+
+/* ./fld_link.c */
+
+#undef link_field
+FIELD *link_field(
+ FIELD *field,
+ int frow,
+ int fcol)
+ { return(*(FIELD **)0); }
+
+/* ./fld_max.c */
+
+#undef set_max_field
+int set_max_field(
+ FIELD *field,
+ int maxgrow)
+ { return(*(int *)0); }
+
+/* ./fld_move.c */
+
+#undef move_field
+int move_field(
+ FIELD *field,
+ int frow,
+ int fcol)
+ { return(*(int *)0); }
+
+/* ./fld_newftyp.c */
+
+#undef _nc_Default_FieldType
+FIELDTYPE *_nc_Default_FieldType;
+
+#undef new_fieldtype
+FIELDTYPE *new_fieldtype(
+ NCURSES_BOOL (*const field_check)(
+ FIELD *p1,
+ const void *p2),
+ NCURSES_BOOL (*const char_check)(
+ int p1,
+ const void *p2))
+ { return(*(FIELDTYPE **)0); }
+
+#undef free_fieldtype
+int free_fieldtype(
+ FIELDTYPE *typ)
+ { return(*(int *)0); }
+
+/* ./fld_opts.c */
+
+#undef set_field_opts
+int set_field_opts(
+ FIELD *field,
+ Field_Options opts)
+ { return(*(int *)0); }
+
+#undef field_opts
+Field_Options field_opts(
+ const FIELD *field)
+ { return(*(Field_Options *)0); }
+
+#undef field_opts_on
+int field_opts_on(
+ FIELD *field,
+ Field_Options opts)
+ { return(*(int *)0); }
+
+#undef field_opts_off
+int field_opts_off(
+ FIELD *field,
+ Field_Options opts)
+ { return(*(int *)0); }
+
+/* ./fld_pad.c */
+
+#undef set_field_pad
+int set_field_pad(
+ FIELD *field,
+ int ch)
+ { return(*(int *)0); }
+
+#undef field_pad
+int field_pad(
+ const FIELD *field)
+ { return(*(int *)0); }
+
+/* ./fld_page.c */
+
+#undef set_new_page
+int set_new_page(
+ FIELD *field,
+ NCURSES_BOOL new_page_flag)
+ { return(*(int *)0); }
+
+#undef new_page
+NCURSES_BOOL new_page(
+ const FIELD *field)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./fld_stat.c */
+
+#undef set_field_status
+int set_field_status(
+ FIELD *field,
+ NCURSES_BOOL status)
+ { return(*(int *)0); }
+
+#undef field_status
+NCURSES_BOOL field_status(
+ const FIELD *field)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./fld_type.c */
+
+#undef set_field_type
+int set_field_type(
+ FIELD *field,
+ FIELDTYPE *type,
+ ...)
+ { return(*(int *)0); }
+
+#undef field_type
+FIELDTYPE *field_type(
+ const FIELD *field)
+ { return(*(FIELDTYPE **)0); }
+
+/* ./fld_user.c */
+
+#undef set_field_userptr
+int set_field_userptr(
+ FIELD *field,
+ void *usrptr)
+ { return(*(int *)0); }
+
+#undef field_userptr
+void *field_userptr(
+ const FIELD *field)
+ { return(*(void **)0); }
+
+/* ./frm_cursor.c */
+
+#undef pos_form_cursor
+int pos_form_cursor(
+ FORM *form)
+ { return(*(int *)0); }
+
+/* ./frm_data.c */
+
+#undef data_behind
+NCURSES_BOOL data_behind(
+ const FORM *form)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef data_ahead
+NCURSES_BOOL data_ahead(
+ const FORM *form)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./frm_def.c */
+
+#undef _nc_Default_Form
+FORM *_nc_Default_Form;
+
+#undef new_form_sp
+FORM *new_form_sp(
+ SCREEN *sp,
+ FIELD **fields)
+ { return(*(FORM **)0); }
+
+#undef new_form
+FORM *new_form(
+ FIELD **fields)
+ { return(*(FORM **)0); }
+
+#undef free_form
+int free_form(
+ FORM *form)
+ { return(*(int *)0); }
+
+#undef set_form_fields
+int set_form_fields(
+ FORM *form,
+ FIELD **fields)
+ { return(*(int *)0); }
+
+#undef form_fields
+FIELD **form_fields(
+ const FORM *form)
+ { return(*(FIELD ***)0); }
+
+#undef field_count
+int field_count(
+ const FORM *form)
+ { return(*(int *)0); }
+
+/* ./frm_driver.c */
+
+#undef _nc_get_fieldbuffer
+void _nc_get_fieldbuffer(
+ FORM *form,
+ FIELD *field,
+ char *buf)
+ { /* void */ }
+
+#undef _nc_Position_Form_Cursor
+int _nc_Position_Form_Cursor(
+ FORM *form)
+ { return(*(int *)0); }
+
+#undef _nc_Refresh_Current_Field
+int _nc_Refresh_Current_Field(
+ FORM *form)
+ { return(*(int *)0); }
+
+#undef _nc_Synchronize_Attributes
+int _nc_Synchronize_Attributes(
+ FIELD *field)
+ { return(*(int *)0); }
+
+#undef _nc_Synchronize_Options
+int _nc_Synchronize_Options(
+ FIELD *field,
+ Field_Options newopts)
+ { return(*(int *)0); }
+
+#undef _nc_Set_Current_Field
+int _nc_Set_Current_Field(
+ FORM *form,
+ FIELD *newfield)
+ { return(*(int *)0); }
+
+#undef _nc_Internal_Validation
+NCURSES_BOOL _nc_Internal_Validation(
+ FORM *form)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef _nc_First_Active_Field
+FIELD *_nc_First_Active_Field(
+ FORM *form)
+ { return(*(FIELD **)0); }
+
+#undef _nc_Set_Form_Page
+int _nc_Set_Form_Page(
+ FORM *form,
+ int page,
+ FIELD *field)
+ { return(*(int *)0); }
+
+typedef struct
+{
+ int keycode;
+ int (*cmd) (FORM *);
+}
+Binding_Info;
+
+#undef form_driver
+int form_driver(
+ FORM *form,
+ int c)
+ { return(*(int *)0); }
+
+#undef set_field_buffer
+int set_field_buffer(
+ FIELD *field,
+ int buffer,
+ const char *value)
+ { return(*(int *)0); }
+
+#undef field_buffer
+char *field_buffer(
+ const FIELD *field,
+ int buffer)
+ { return(*(char **)0); }
+
+/* ./frm_hook.c */
+
+#undef set_field_init
+int set_field_init(
+ FORM *form,
+ Form_Hook func)
+ { return(*(int *)0); }
+
+#undef field_init
+Form_Hook field_init(
+ const FORM *form)
+ { return(*(Form_Hook *)0); }
+
+#undef set_field_term
+int set_field_term(
+ FORM *form,
+ Form_Hook func)
+ { return(*(int *)0); }
+
+#undef field_term
+Form_Hook field_term(
+ const FORM *form)
+ { return(*(Form_Hook *)0); }
+
+#undef set_form_init
+int set_form_init(
+ FORM *form,
+ Form_Hook func)
+ { return(*(int *)0); }
+
+#undef form_init
+Form_Hook form_init(
+ const FORM *form)
+ { return(*(Form_Hook *)0); }
+
+#undef set_form_term
+int set_form_term(
+ FORM *form,
+ Form_Hook func)
+ { return(*(int *)0); }
+
+#undef form_term
+Form_Hook form_term(
+ const FORM *form)
+ { return(*(Form_Hook *)0); }
+
+/* ./frm_opts.c */
+
+#undef set_form_opts
+int set_form_opts(
+ FORM *form,
+ Form_Options opts)
+ { return(*(int *)0); }
+
+#undef form_opts
+Form_Options form_opts(
+ const FORM *form)
+ { return(*(Form_Options *)0); }
+
+#undef form_opts_on
+int form_opts_on(
+ FORM *form,
+ Form_Options opts)
+ { return(*(int *)0); }
+
+#undef form_opts_off
+int form_opts_off(
+ FORM *form,
+ Form_Options opts)
+ { return(*(int *)0); }
+
+/* ./frm_page.c */
+
+#undef set_form_page
+int set_form_page(
+ FORM *form,
+ int page)
+ { return(*(int *)0); }
+
+#undef form_page
+int form_page(
+ const FORM *form)
+ { return(*(int *)0); }
+
+/* ./frm_post.c */
+
+#undef post_form
+int post_form(
+ FORM *form)
+ { return(*(int *)0); }
+
+#undef unpost_form
+int unpost_form(
+ FORM *form)
+ { return(*(int *)0); }
+
+/* ./frm_req_name.c */
+
+#undef form_request_name
+const char *form_request_name(
+ int request)
+ { return(*(const char **)0); }
+
+#undef form_request_by_name
+int form_request_by_name(
+ const char *str)
+ { return(*(int *)0); }
+
+/* ./frm_scale.c */
+
+#undef scale_form
+int scale_form(
+ const FORM *form,
+ int *rows,
+ int *cols)
+ { return(*(int *)0); }
+
+/* ./frm_sub.c */
+
+#undef set_form_sub
+int set_form_sub(
+ FORM *form,
+ WINDOW *win)
+ { return(*(int *)0); }
+
+#undef form_sub
+WINDOW *form_sub(
+ const FORM *form)
+ { return(*(WINDOW **)0); }
+
+/* ./frm_user.c */
+
+#undef set_form_userptr
+int set_form_userptr(
+ FORM *form,
+ void *usrptr)
+ { return(*(int *)0); }
+
+#undef form_userptr
+void *form_userptr(
+ const FORM *form)
+ { return(*(void **)0); }
+
+/* ./frm_win.c */
+
+#undef set_form_win
+int set_form_win(
+ FORM *form,
+ WINDOW *win)
+ { return(*(int *)0); }
+
+#undef form_win
+WINDOW *form_win(
+ const FORM *form)
+ { return(*(WINDOW **)0); }
+
+/* ./fty_alnum.c */
+
+typedef struct
+ {
+ int width;
+ }
+alnumARG;
+
+#undef TYPE_ALNUM
+FIELDTYPE *TYPE_ALNUM;
+
+/* ./fty_alpha.c */
+
+typedef struct
+ {
+ int width;
+ }
+alphaARG;
+
+#undef TYPE_ALPHA
+FIELDTYPE *TYPE_ALPHA;
+
+/* ./fty_enum.c */
+
+typedef struct
+ {
+ char **kwds;
+ int count;
+ NCURSES_BOOL checkcase;
+ NCURSES_BOOL checkunique;
+ }
+enumARG;
+
+typedef struct
+ {
+ char **kwds;
+ int ccase;
+ int cunique;
+ }
+enumParams;
+
+#undef TYPE_ENUM
+FIELDTYPE *TYPE_ENUM;
+
+/* ./fty_generic.c */
+
+#undef _nc_fty_generic
+void _nc_fty_generic(void)
+ { /* void */ }
+
+/* ./fty_int.c */
+
+typedef struct
+ {
+ int precision;
+ long low;
+ long high;
+ }
+integerARG;
+
+typedef struct
+ {
+ int precision;
+ long low;
+ long high;
+ }
+integerPARM;
+
+#undef TYPE_INTEGER
+FIELDTYPE *TYPE_INTEGER;
+
+/* ./fty_ipv4.c */
+#undef TYPE_IPV4
+FIELDTYPE *TYPE_IPV4;
+
+/* ./fty_num.c */
+
+#include <locale.h>
+
+typedef struct
+ {
+ int precision;
+ double low;
+ double high;
+ struct lconv *L;
+ }
+numericARG;
+
+typedef struct
+ {
+ int precision;
+ double low;
+ double high;
+ }
+thisPARM;
+
+#undef TYPE_NUMERIC
+FIELDTYPE *TYPE_NUMERIC;
+
+/* ./fty_regex.c */
+
+#include <regex.h>
+
+typedef struct
+ {
+ regex_t *pRegExp;
+ unsigned long *refCount;
+ }
+RegExp_Arg;
+
+#undef TYPE_REGEXP
+FIELDTYPE *TYPE_REGEXP;
diff --git a/payloads/libpayload/curses/form/llib-lformt b/payloads/libpayload/curses/form/llib-lformt
new file mode 100644
index 0000000000..33de63cde9
--- /dev/null
+++ b/payloads/libpayload/curses/form/llib-lformt
@@ -0,0 +1,777 @@
+/****************************************************************************
+ * Copyright (c) 2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2010 *
+ ****************************************************************************/
+/* LINTLIBRARY */
+
+/* ./f_trace.c */
+
+#include <form.priv.h>
+
+#undef _nc_retrace_field_ptr
+FIELD **_nc_retrace_field_ptr(
+ FIELD **code)
+ { return(*(FIELD ***)0); }
+
+#undef _nc_retrace_field
+FIELD *_nc_retrace_field(
+ FIELD *code)
+ { return(*(FIELD **)0); }
+
+#undef _nc_retrace_field_type
+FIELDTYPE *_nc_retrace_field_type(
+ FIELDTYPE *code)
+ { return(*(FIELDTYPE **)0); }
+
+#undef _nc_retrace_form
+FORM *_nc_retrace_form(
+ FORM *code)
+ { return(*(FORM **)0); }
+
+#undef _nc_retrace_form_hook
+Form_Hook _nc_retrace_form_hook(
+ Form_Hook code)
+ { return(*(Form_Hook *)0); }
+
+/* ./fld_arg.c */
+
+#undef set_fieldtype_arg
+int set_fieldtype_arg(
+ FIELDTYPE *typ,
+ void *(*const make_arg)(
+ va_list *p1),
+ void *(*const copy_arg)(
+ const void *p1),
+ void (*const free_arg)(
+ void *p1))
+ { return(*(int *)0); }
+
+#undef field_arg
+void *field_arg(
+ const FIELD *field)
+ { return(*(void **)0); }
+
+/* ./fld_attr.c */
+
+#undef set_field_fore
+int set_field_fore(
+ FIELD *field,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef field_fore
+chtype field_fore(
+ const FIELD *field)
+ { return(*(chtype *)0); }
+
+#undef set_field_back
+int set_field_back(
+ FIELD *field,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef field_back
+chtype field_back(
+ const FIELD *field)
+ { return(*(chtype *)0); }
+
+/* ./fld_current.c */
+
+#undef set_current_field
+int set_current_field(
+ FORM *form,
+ FIELD *field)
+ { return(*(int *)0); }
+
+#undef current_field
+FIELD *current_field(
+ const FORM *form)
+ { return(*(FIELD **)0); }
+
+#undef field_index
+int field_index(
+ const FIELD *field)
+ { return(*(int *)0); }
+
+/* ./fld_def.c */
+
+#undef _nc_Default_Field
+FIELD *_nc_Default_Field;
+
+#undef _nc_Make_Argument
+TypeArgument *_nc_Make_Argument(
+ const FIELDTYPE *typ,
+ va_list *ap,
+ int *err)
+ { return(*(TypeArgument **)0); }
+
+#undef _nc_Copy_Argument
+TypeArgument *_nc_Copy_Argument(
+ const FIELDTYPE *typ,
+ const TypeArgument *argp,
+ int *err)
+ { return(*(TypeArgument **)0); }
+
+#undef _nc_Free_Argument
+void _nc_Free_Argument(
+ const FIELDTYPE *typ,
+ TypeArgument *argp)
+ { /* void */ }
+
+#undef _nc_Copy_Type
+NCURSES_BOOL _nc_Copy_Type(
+ FIELD *dst,
+ FIELD const *src)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef _nc_Free_Type
+void _nc_Free_Type(
+ FIELD *field)
+ { /* void */ }
+
+#undef new_field
+FIELD *new_field(
+ int rows,
+ int cols,
+ int frow,
+ int fcol,
+ int nrow,
+ int nbuf)
+ { return(*(FIELD **)0); }
+
+#undef free_field
+int free_field(
+ FIELD *field)
+ { return(*(int *)0); }
+
+/* ./fld_dup.c */
+
+#undef dup_field
+FIELD *dup_field(
+ FIELD *field,
+ int frow,
+ int fcol)
+ { return(*(FIELD **)0); }
+
+/* ./fld_ftchoice.c */
+
+#undef set_fieldtype_choice
+int set_fieldtype_choice(
+ FIELDTYPE *typ,
+ NCURSES_BOOL (*const next_choice)(
+ FIELD *p1,
+ const void *p2),
+ NCURSES_BOOL (*const prev_choice)(
+ FIELD *p1,
+ const void *p2))
+ { return(*(int *)0); }
+
+/* ./fld_ftlink.c */
+
+#undef link_fieldtype
+FIELDTYPE *link_fieldtype(
+ FIELDTYPE *type1,
+ FIELDTYPE *type2)
+ { return(*(FIELDTYPE **)0); }
+
+/* ./fld_info.c */
+
+#undef field_info
+int field_info(
+ const FIELD *field,
+ int *rows,
+ int *cols,
+ int *frow,
+ int *fcol,
+ int *nrow,
+ int *nbuf)
+ { return(*(int *)0); }
+
+#undef dynamic_field_info
+int dynamic_field_info(
+ const FIELD *field,
+ int *drows,
+ int *dcols,
+ int *maxgrow)
+ { return(*(int *)0); }
+
+/* ./fld_just.c */
+
+#undef set_field_just
+int set_field_just(
+ FIELD *field,
+ int just)
+ { return(*(int *)0); }
+
+#undef field_just
+int field_just(
+ const FIELD *field)
+ { return(*(int *)0); }
+
+/* ./fld_link.c */
+
+#undef link_field
+FIELD *link_field(
+ FIELD *field,
+ int frow,
+ int fcol)
+ { return(*(FIELD **)0); }
+
+/* ./fld_max.c */
+
+#undef set_max_field
+int set_max_field(
+ FIELD *field,
+ int maxgrow)
+ { return(*(int *)0); }
+
+/* ./fld_move.c */
+
+#undef move_field
+int move_field(
+ FIELD *field,
+ int frow,
+ int fcol)
+ { return(*(int *)0); }
+
+/* ./fld_newftyp.c */
+
+#undef _nc_Default_FieldType
+FIELDTYPE *_nc_Default_FieldType;
+
+#undef new_fieldtype
+FIELDTYPE *new_fieldtype(
+ NCURSES_BOOL (*const field_check)(
+ FIELD *p1,
+ const void *p2),
+ NCURSES_BOOL (*const char_check)(
+ int p1,
+ const void *p2))
+ { return(*(FIELDTYPE **)0); }
+
+#undef free_fieldtype
+int free_fieldtype(
+ FIELDTYPE *typ)
+ { return(*(int *)0); }
+
+/* ./fld_opts.c */
+
+#undef set_field_opts
+int set_field_opts(
+ FIELD *field,
+ Field_Options opts)
+ { return(*(int *)0); }
+
+#undef field_opts
+Field_Options field_opts(
+ const FIELD *field)
+ { return(*(Field_Options *)0); }
+
+#undef field_opts_on
+int field_opts_on(
+ FIELD *field,
+ Field_Options opts)
+ { return(*(int *)0); }
+
+#undef field_opts_off
+int field_opts_off(
+ FIELD *field,
+ Field_Options opts)
+ { return(*(int *)0); }
+
+/* ./fld_pad.c */
+
+#undef set_field_pad
+int set_field_pad(
+ FIELD *field,
+ int ch)
+ { return(*(int *)0); }
+
+#undef field_pad
+int field_pad(
+ const FIELD *field)
+ { return(*(int *)0); }
+
+/* ./fld_page.c */
+
+#undef set_new_page
+int set_new_page(
+ FIELD *field,
+ NCURSES_BOOL new_page_flag)
+ { return(*(int *)0); }
+
+#undef new_page
+NCURSES_BOOL new_page(
+ const FIELD *field)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./fld_stat.c */
+
+#undef set_field_status
+int set_field_status(
+ FIELD *field,
+ NCURSES_BOOL status)
+ { return(*(int *)0); }
+
+#undef field_status
+NCURSES_BOOL field_status(
+ const FIELD *field)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./fld_type.c */
+
+#undef set_field_type
+int set_field_type(
+ FIELD *field,
+ FIELDTYPE *type,
+ ...)
+ { return(*(int *)0); }
+
+#undef field_type
+FIELDTYPE *field_type(
+ const FIELD *field)
+ { return(*(FIELDTYPE **)0); }
+
+/* ./fld_user.c */
+
+#undef set_field_userptr
+int set_field_userptr(
+ FIELD *field,
+ void *usrptr)
+ { return(*(int *)0); }
+
+#undef field_userptr
+void *field_userptr(
+ const FIELD *field)
+ { return(*(void **)0); }
+
+/* ./frm_cursor.c */
+
+#undef pos_form_cursor
+int pos_form_cursor(
+ FORM *form)
+ { return(*(int *)0); }
+
+/* ./frm_data.c */
+
+#undef data_behind
+NCURSES_BOOL data_behind(
+ const FORM *form)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef data_ahead
+NCURSES_BOOL data_ahead(
+ const FORM *form)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./frm_def.c */
+
+#undef _nc_Default_Form
+FORM *_nc_Default_Form;
+
+#undef new_form_sp
+FORM *new_form_sp(
+ SCREEN *sp,
+ FIELD **fields)
+ { return(*(FORM **)0); }
+
+#undef new_form
+FORM *new_form(
+ FIELD **fields)
+ { return(*(FORM **)0); }
+
+#undef free_form
+int free_form(
+ FORM *form)
+ { return(*(int *)0); }
+
+#undef set_form_fields
+int set_form_fields(
+ FORM *form,
+ FIELD **fields)
+ { return(*(int *)0); }
+
+#undef form_fields
+FIELD **form_fields(
+ const FORM *form)
+ { return(*(FIELD ***)0); }
+
+#undef field_count
+int field_count(
+ const FORM *form)
+ { return(*(int *)0); }
+
+/* ./frm_driver.c */
+
+#undef _nc_get_fieldbuffer
+void _nc_get_fieldbuffer(
+ FORM *form,
+ FIELD *field,
+ char *buf)
+ { /* void */ }
+
+#undef _nc_Position_Form_Cursor
+int _nc_Position_Form_Cursor(
+ FORM *form)
+ { return(*(int *)0); }
+
+#undef _nc_Refresh_Current_Field
+int _nc_Refresh_Current_Field(
+ FORM *form)
+ { return(*(int *)0); }
+
+#undef _nc_Synchronize_Attributes
+int _nc_Synchronize_Attributes(
+ FIELD *field)
+ { return(*(int *)0); }
+
+#undef _nc_Synchronize_Options
+int _nc_Synchronize_Options(
+ FIELD *field,
+ Field_Options newopts)
+ { return(*(int *)0); }
+
+#undef _nc_Set_Current_Field
+int _nc_Set_Current_Field(
+ FORM *form,
+ FIELD *newfield)
+ { return(*(int *)0); }
+
+#undef _nc_Internal_Validation
+NCURSES_BOOL _nc_Internal_Validation(
+ FORM *form)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef _nc_First_Active_Field
+FIELD *_nc_First_Active_Field(
+ FORM *form)
+ { return(*(FIELD **)0); }
+
+#undef _nc_Set_Form_Page
+int _nc_Set_Form_Page(
+ FORM *form,
+ int page,
+ FIELD *field)
+ { return(*(int *)0); }
+
+typedef struct
+{
+ int keycode;
+ int (*cmd) (FORM *);
+}
+Binding_Info;
+
+#undef form_driver
+int form_driver(
+ FORM *form,
+ int c)
+ { return(*(int *)0); }
+
+#undef set_field_buffer
+int set_field_buffer(
+ FIELD *field,
+ int buffer,
+ const char *value)
+ { return(*(int *)0); }
+
+#undef field_buffer
+char *field_buffer(
+ const FIELD *field,
+ int buffer)
+ { return(*(char **)0); }
+
+/* ./frm_hook.c */
+
+#undef set_field_init
+int set_field_init(
+ FORM *form,
+ Form_Hook func)
+ { return(*(int *)0); }
+
+#undef field_init
+Form_Hook field_init(
+ const FORM *form)
+ { return(*(Form_Hook *)0); }
+
+#undef set_field_term
+int set_field_term(
+ FORM *form,
+ Form_Hook func)
+ { return(*(int *)0); }
+
+#undef field_term
+Form_Hook field_term(
+ const FORM *form)
+ { return(*(Form_Hook *)0); }
+
+#undef set_form_init
+int set_form_init(
+ FORM *form,
+ Form_Hook func)
+ { return(*(int *)0); }
+
+#undef form_init
+Form_Hook form_init(
+ const FORM *form)
+ { return(*(Form_Hook *)0); }
+
+#undef set_form_term
+int set_form_term(
+ FORM *form,
+ Form_Hook func)
+ { return(*(int *)0); }
+
+#undef form_term
+Form_Hook form_term(
+ const FORM *form)
+ { return(*(Form_Hook *)0); }
+
+/* ./frm_opts.c */
+
+#undef set_form_opts
+int set_form_opts(
+ FORM *form,
+ Form_Options opts)
+ { return(*(int *)0); }
+
+#undef form_opts
+Form_Options form_opts(
+ const FORM *form)
+ { return(*(Form_Options *)0); }
+
+#undef form_opts_on
+int form_opts_on(
+ FORM *form,
+ Form_Options opts)
+ { return(*(int *)0); }
+
+#undef form_opts_off
+int form_opts_off(
+ FORM *form,
+ Form_Options opts)
+ { return(*(int *)0); }
+
+/* ./frm_page.c */
+
+#undef set_form_page
+int set_form_page(
+ FORM *form,
+ int page)
+ { return(*(int *)0); }
+
+#undef form_page
+int form_page(
+ const FORM *form)
+ { return(*(int *)0); }
+
+/* ./frm_post.c */
+
+#undef post_form
+int post_form(
+ FORM *form)
+ { return(*(int *)0); }
+
+#undef unpost_form
+int unpost_form(
+ FORM *form)
+ { return(*(int *)0); }
+
+/* ./frm_req_name.c */
+
+#undef form_request_name
+const char *form_request_name(
+ int request)
+ { return(*(const char **)0); }
+
+#undef form_request_by_name
+int form_request_by_name(
+ const char *str)
+ { return(*(int *)0); }
+
+/* ./frm_scale.c */
+
+#undef scale_form
+int scale_form(
+ const FORM *form,
+ int *rows,
+ int *cols)
+ { return(*(int *)0); }
+
+/* ./frm_sub.c */
+
+#undef set_form_sub
+int set_form_sub(
+ FORM *form,
+ WINDOW *win)
+ { return(*(int *)0); }
+
+#undef form_sub
+WINDOW *form_sub(
+ const FORM *form)
+ { return(*(WINDOW **)0); }
+
+/* ./frm_user.c */
+
+#undef set_form_userptr
+int set_form_userptr(
+ FORM *form,
+ void *usrptr)
+ { return(*(int *)0); }
+
+#undef form_userptr
+void *form_userptr(
+ const FORM *form)
+ { return(*(void **)0); }
+
+/* ./frm_win.c */
+
+#undef set_form_win
+int set_form_win(
+ FORM *form,
+ WINDOW *win)
+ { return(*(int *)0); }
+
+#undef form_win
+WINDOW *form_win(
+ const FORM *form)
+ { return(*(WINDOW **)0); }
+
+/* ./fty_alnum.c */
+
+typedef struct
+ {
+ int width;
+ }
+alnumARG;
+
+#undef TYPE_ALNUM
+FIELDTYPE *TYPE_ALNUM;
+
+/* ./fty_alpha.c */
+
+typedef struct
+ {
+ int width;
+ }
+alphaARG;
+
+#undef TYPE_ALPHA
+FIELDTYPE *TYPE_ALPHA;
+
+/* ./fty_enum.c */
+
+typedef struct
+ {
+ char **kwds;
+ int count;
+ NCURSES_BOOL checkcase;
+ NCURSES_BOOL checkunique;
+ }
+enumARG;
+
+typedef struct
+ {
+ char **kwds;
+ int ccase;
+ int cunique;
+ }
+enumParams;
+
+#undef TYPE_ENUM
+FIELDTYPE *TYPE_ENUM;
+
+/* ./fty_generic.c */
+
+#undef _nc_fty_generic
+void _nc_fty_generic(void)
+ { /* void */ }
+
+/* ./fty_int.c */
+
+typedef struct
+ {
+ int precision;
+ long low;
+ long high;
+ }
+integerARG;
+
+typedef struct
+ {
+ int precision;
+ long low;
+ long high;
+ }
+integerPARM;
+
+#undef TYPE_INTEGER
+FIELDTYPE *TYPE_INTEGER;
+
+/* ./fty_ipv4.c */
+#undef TYPE_IPV4
+FIELDTYPE *TYPE_IPV4;
+
+/* ./fty_num.c */
+
+#include <locale.h>
+
+typedef struct
+ {
+ int precision;
+ double low;
+ double high;
+ struct lconv *L;
+ }
+numericARG;
+
+typedef struct
+ {
+ int precision;
+ double low;
+ double high;
+ }
+thisPARM;
+
+#undef TYPE_NUMERIC
+FIELDTYPE *TYPE_NUMERIC;
+
+/* ./fty_regex.c */
+
+#include <regex.h>
+
+typedef struct
+ {
+ regex_t *pRegExp;
+ unsigned long *refCount;
+ }
+RegExp_Arg;
+
+#undef TYPE_REGEXP
+FIELDTYPE *TYPE_REGEXP;
diff --git a/payloads/libpayload/curses/form/llib-lformtw b/payloads/libpayload/curses/form/llib-lformtw
new file mode 100644
index 0000000000..10639490e3
--- /dev/null
+++ b/payloads/libpayload/curses/form/llib-lformtw
@@ -0,0 +1,783 @@
+/****************************************************************************
+ * Copyright (c) 2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2010 *
+ ****************************************************************************/
+/* LINTLIBRARY */
+
+/* ./f_trace.c */
+
+#include <form.priv.h>
+
+#undef _nc_retrace_field_ptr
+FIELD **_nc_retrace_field_ptr(
+ FIELD **code)
+ { return(*(FIELD ***)0); }
+
+#undef _nc_retrace_field
+FIELD *_nc_retrace_field(
+ FIELD *code)
+ { return(*(FIELD **)0); }
+
+#undef _nc_retrace_field_type
+FIELDTYPE *_nc_retrace_field_type(
+ FIELDTYPE *code)
+ { return(*(FIELDTYPE **)0); }
+
+#undef _nc_retrace_form
+FORM *_nc_retrace_form(
+ FORM *code)
+ { return(*(FORM **)0); }
+
+#undef _nc_retrace_form_hook
+Form_Hook _nc_retrace_form_hook(
+ Form_Hook code)
+ { return(*(Form_Hook *)0); }
+
+/* ./fld_arg.c */
+
+#undef set_fieldtype_arg
+int set_fieldtype_arg(
+ FIELDTYPE *typ,
+ void *(*const make_arg)(
+ va_list *p1),
+ void *(*const copy_arg)(
+ const void *p1),
+ void (*const free_arg)(
+ void *p1))
+ { return(*(int *)0); }
+
+#undef field_arg
+void *field_arg(
+ const FIELD *field)
+ { return(*(void **)0); }
+
+/* ./fld_attr.c */
+
+#undef set_field_fore
+int set_field_fore(
+ FIELD *field,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef field_fore
+chtype field_fore(
+ const FIELD *field)
+ { return(*(chtype *)0); }
+
+#undef set_field_back
+int set_field_back(
+ FIELD *field,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef field_back
+chtype field_back(
+ const FIELD *field)
+ { return(*(chtype *)0); }
+
+/* ./fld_current.c */
+
+#undef set_current_field
+int set_current_field(
+ FORM *form,
+ FIELD *field)
+ { return(*(int *)0); }
+
+#undef current_field
+FIELD *current_field(
+ const FORM *form)
+ { return(*(FIELD **)0); }
+
+#undef field_index
+int field_index(
+ const FIELD *field)
+ { return(*(int *)0); }
+
+/* ./fld_def.c */
+
+#undef _nc_Default_Field
+FIELD *_nc_Default_Field;
+
+#undef _nc_Make_Argument
+TypeArgument *_nc_Make_Argument(
+ const FIELDTYPE *typ,
+ va_list *ap,
+ int *err)
+ { return(*(TypeArgument **)0); }
+
+#undef _nc_Copy_Argument
+TypeArgument *_nc_Copy_Argument(
+ const FIELDTYPE *typ,
+ const TypeArgument *argp,
+ int *err)
+ { return(*(TypeArgument **)0); }
+
+#undef _nc_Free_Argument
+void _nc_Free_Argument(
+ const FIELDTYPE *typ,
+ TypeArgument *argp)
+ { /* void */ }
+
+#undef _nc_Copy_Type
+NCURSES_BOOL _nc_Copy_Type(
+ FIELD *dst,
+ FIELD const *src)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef _nc_Free_Type
+void _nc_Free_Type(
+ FIELD *field)
+ { /* void */ }
+
+#undef new_field
+FIELD *new_field(
+ int rows,
+ int cols,
+ int frow,
+ int fcol,
+ int nrow,
+ int nbuf)
+ { return(*(FIELD **)0); }
+
+#undef free_field
+int free_field(
+ FIELD *field)
+ { return(*(int *)0); }
+
+/* ./fld_dup.c */
+
+#undef dup_field
+FIELD *dup_field(
+ FIELD *field,
+ int frow,
+ int fcol)
+ { return(*(FIELD **)0); }
+
+/* ./fld_ftchoice.c */
+
+#undef set_fieldtype_choice
+int set_fieldtype_choice(
+ FIELDTYPE *typ,
+ NCURSES_BOOL (*const next_choice)(
+ FIELD *p1,
+ const void *p2),
+ NCURSES_BOOL (*const prev_choice)(
+ FIELD *p1,
+ const void *p2))
+ { return(*(int *)0); }
+
+/* ./fld_ftlink.c */
+
+#undef link_fieldtype
+FIELDTYPE *link_fieldtype(
+ FIELDTYPE *type1,
+ FIELDTYPE *type2)
+ { return(*(FIELDTYPE **)0); }
+
+/* ./fld_info.c */
+
+#undef field_info
+int field_info(
+ const FIELD *field,
+ int *rows,
+ int *cols,
+ int *frow,
+ int *fcol,
+ int *nrow,
+ int *nbuf)
+ { return(*(int *)0); }
+
+#undef dynamic_field_info
+int dynamic_field_info(
+ const FIELD *field,
+ int *drows,
+ int *dcols,
+ int *maxgrow)
+ { return(*(int *)0); }
+
+/* ./fld_just.c */
+
+#undef set_field_just
+int set_field_just(
+ FIELD *field,
+ int just)
+ { return(*(int *)0); }
+
+#undef field_just
+int field_just(
+ const FIELD *field)
+ { return(*(int *)0); }
+
+/* ./fld_link.c */
+
+#undef link_field
+FIELD *link_field(
+ FIELD *field,
+ int frow,
+ int fcol)
+ { return(*(FIELD **)0); }
+
+/* ./fld_max.c */
+
+#undef set_max_field
+int set_max_field(
+ FIELD *field,
+ int maxgrow)
+ { return(*(int *)0); }
+
+/* ./fld_move.c */
+
+#undef move_field
+int move_field(
+ FIELD *field,
+ int frow,
+ int fcol)
+ { return(*(int *)0); }
+
+/* ./fld_newftyp.c */
+
+#undef _nc_Default_FieldType
+FIELDTYPE *_nc_Default_FieldType;
+
+#undef new_fieldtype
+FIELDTYPE *new_fieldtype(
+ NCURSES_BOOL (*const field_check)(
+ FIELD *p1,
+ const void *p2),
+ NCURSES_BOOL (*const char_check)(
+ int p1,
+ const void *p2))
+ { return(*(FIELDTYPE **)0); }
+
+#undef free_fieldtype
+int free_fieldtype(
+ FIELDTYPE *typ)
+ { return(*(int *)0); }
+
+/* ./fld_opts.c */
+
+#undef set_field_opts
+int set_field_opts(
+ FIELD *field,
+ Field_Options opts)
+ { return(*(int *)0); }
+
+#undef field_opts
+Field_Options field_opts(
+ const FIELD *field)
+ { return(*(Field_Options *)0); }
+
+#undef field_opts_on
+int field_opts_on(
+ FIELD *field,
+ Field_Options opts)
+ { return(*(int *)0); }
+
+#undef field_opts_off
+int field_opts_off(
+ FIELD *field,
+ Field_Options opts)
+ { return(*(int *)0); }
+
+/* ./fld_pad.c */
+
+#undef set_field_pad
+int set_field_pad(
+ FIELD *field,
+ int ch)
+ { return(*(int *)0); }
+
+#undef field_pad
+int field_pad(
+ const FIELD *field)
+ { return(*(int *)0); }
+
+/* ./fld_page.c */
+
+#undef set_new_page
+int set_new_page(
+ FIELD *field,
+ NCURSES_BOOL new_page_flag)
+ { return(*(int *)0); }
+
+#undef new_page
+NCURSES_BOOL new_page(
+ const FIELD *field)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./fld_stat.c */
+
+#undef set_field_status
+int set_field_status(
+ FIELD *field,
+ NCURSES_BOOL status)
+ { return(*(int *)0); }
+
+#undef field_status
+NCURSES_BOOL field_status(
+ const FIELD *field)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./fld_type.c */
+
+#undef set_field_type
+int set_field_type(
+ FIELD *field,
+ FIELDTYPE *type,
+ ...)
+ { return(*(int *)0); }
+
+#undef field_type
+FIELDTYPE *field_type(
+ const FIELD *field)
+ { return(*(FIELDTYPE **)0); }
+
+/* ./fld_user.c */
+
+#undef set_field_userptr
+int set_field_userptr(
+ FIELD *field,
+ void *usrptr)
+ { return(*(int *)0); }
+
+#undef field_userptr
+void *field_userptr(
+ const FIELD *field)
+ { return(*(void **)0); }
+
+/* ./frm_cursor.c */
+
+#undef pos_form_cursor
+int pos_form_cursor(
+ FORM *form)
+ { return(*(int *)0); }
+
+/* ./frm_data.c */
+
+#undef data_behind
+NCURSES_BOOL data_behind(
+ const FORM *form)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef data_ahead
+NCURSES_BOOL data_ahead(
+ const FORM *form)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./frm_def.c */
+
+#undef _nc_Default_Form
+FORM *_nc_Default_Form;
+
+#undef new_form_sp
+FORM *new_form_sp(
+ SCREEN *sp,
+ FIELD **fields)
+ { return(*(FORM **)0); }
+
+#undef new_form
+FORM *new_form(
+ FIELD **fields)
+ { return(*(FORM **)0); }
+
+#undef free_form
+int free_form(
+ FORM *form)
+ { return(*(int *)0); }
+
+#undef set_form_fields
+int set_form_fields(
+ FORM *form,
+ FIELD **fields)
+ { return(*(int *)0); }
+
+#undef form_fields
+FIELD **form_fields(
+ const FORM *form)
+ { return(*(FIELD ***)0); }
+
+#undef field_count
+int field_count(
+ const FORM *form)
+ { return(*(int *)0); }
+
+/* ./frm_driver.c */
+
+#undef _nc_get_fieldbuffer
+void _nc_get_fieldbuffer(
+ FORM *form,
+ FIELD *field,
+ cchar_t *buf)
+ { /* void */ }
+
+#undef _nc_Position_Form_Cursor
+int _nc_Position_Form_Cursor(
+ FORM *form)
+ { return(*(int *)0); }
+
+#undef _nc_Refresh_Current_Field
+int _nc_Refresh_Current_Field(
+ FORM *form)
+ { return(*(int *)0); }
+
+#undef _nc_Synchronize_Attributes
+int _nc_Synchronize_Attributes(
+ FIELD *field)
+ { return(*(int *)0); }
+
+#undef _nc_Synchronize_Options
+int _nc_Synchronize_Options(
+ FIELD *field,
+ Field_Options newopts)
+ { return(*(int *)0); }
+
+#undef _nc_Set_Current_Field
+int _nc_Set_Current_Field(
+ FORM *form,
+ FIELD *newfield)
+ { return(*(int *)0); }
+
+#undef _nc_Internal_Validation
+NCURSES_BOOL _nc_Internal_Validation(
+ FORM *form)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef _nc_First_Active_Field
+FIELD *_nc_First_Active_Field(
+ FORM *form)
+ { return(*(FIELD **)0); }
+
+#undef _nc_Set_Form_Page
+int _nc_Set_Form_Page(
+ FORM *form,
+ int page,
+ FIELD *field)
+ { return(*(int *)0); }
+
+typedef struct
+{
+ int keycode;
+ int (*cmd) (FORM *);
+}
+Binding_Info;
+
+#undef form_driver
+int form_driver(
+ FORM *form,
+ int c)
+ { return(*(int *)0); }
+
+#undef set_field_buffer
+int set_field_buffer(
+ FIELD *field,
+ int buffer,
+ const char *value)
+ { return(*(int *)0); }
+
+#undef field_buffer
+char *field_buffer(
+ const FIELD *field,
+ int buffer)
+ { return(*(char **)0); }
+
+#undef _nc_Widen_String
+wchar_t *_nc_Widen_String(
+ char *source,
+ int *lengthp)
+ { return(*(wchar_t **)0); }
+
+/* ./frm_hook.c */
+
+#undef set_field_init
+int set_field_init(
+ FORM *form,
+ Form_Hook func)
+ { return(*(int *)0); }
+
+#undef field_init
+Form_Hook field_init(
+ const FORM *form)
+ { return(*(Form_Hook *)0); }
+
+#undef set_field_term
+int set_field_term(
+ FORM *form,
+ Form_Hook func)
+ { return(*(int *)0); }
+
+#undef field_term
+Form_Hook field_term(
+ const FORM *form)
+ { return(*(Form_Hook *)0); }
+
+#undef set_form_init
+int set_form_init(
+ FORM *form,
+ Form_Hook func)
+ { return(*(int *)0); }
+
+#undef form_init
+Form_Hook form_init(
+ const FORM *form)
+ { return(*(Form_Hook *)0); }
+
+#undef set_form_term
+int set_form_term(
+ FORM *form,
+ Form_Hook func)
+ { return(*(int *)0); }
+
+#undef form_term
+Form_Hook form_term(
+ const FORM *form)
+ { return(*(Form_Hook *)0); }
+
+/* ./frm_opts.c */
+
+#undef set_form_opts
+int set_form_opts(
+ FORM *form,
+ Form_Options opts)
+ { return(*(int *)0); }
+
+#undef form_opts
+Form_Options form_opts(
+ const FORM *form)
+ { return(*(Form_Options *)0); }
+
+#undef form_opts_on
+int form_opts_on(
+ FORM *form,
+ Form_Options opts)
+ { return(*(int *)0); }
+
+#undef form_opts_off
+int form_opts_off(
+ FORM *form,
+ Form_Options opts)
+ { return(*(int *)0); }
+
+/* ./frm_page.c */
+
+#undef set_form_page
+int set_form_page(
+ FORM *form,
+ int page)
+ { return(*(int *)0); }
+
+#undef form_page
+int form_page(
+ const FORM *form)
+ { return(*(int *)0); }
+
+/* ./frm_post.c */
+
+#undef post_form
+int post_form(
+ FORM *form)
+ { return(*(int *)0); }
+
+#undef unpost_form
+int unpost_form(
+ FORM *form)
+ { return(*(int *)0); }
+
+/* ./frm_req_name.c */
+
+#undef form_request_name
+const char *form_request_name(
+ int request)
+ { return(*(const char **)0); }
+
+#undef form_request_by_name
+int form_request_by_name(
+ const char *str)
+ { return(*(int *)0); }
+
+/* ./frm_scale.c */
+
+#undef scale_form
+int scale_form(
+ const FORM *form,
+ int *rows,
+ int *cols)
+ { return(*(int *)0); }
+
+/* ./frm_sub.c */
+
+#undef set_form_sub
+int set_form_sub(
+ FORM *form,
+ WINDOW *win)
+ { return(*(int *)0); }
+
+#undef form_sub
+WINDOW *form_sub(
+ const FORM *form)
+ { return(*(WINDOW **)0); }
+
+/* ./frm_user.c */
+
+#undef set_form_userptr
+int set_form_userptr(
+ FORM *form,
+ void *usrptr)
+ { return(*(int *)0); }
+
+#undef form_userptr
+void *form_userptr(
+ const FORM *form)
+ { return(*(void **)0); }
+
+/* ./frm_win.c */
+
+#undef set_form_win
+int set_form_win(
+ FORM *form,
+ WINDOW *win)
+ { return(*(int *)0); }
+
+#undef form_win
+WINDOW *form_win(
+ const FORM *form)
+ { return(*(WINDOW **)0); }
+
+/* ./fty_alnum.c */
+
+typedef struct
+ {
+ int width;
+ }
+alnumARG;
+
+#undef TYPE_ALNUM
+FIELDTYPE *TYPE_ALNUM;
+
+/* ./fty_alpha.c */
+
+typedef struct
+ {
+ int width;
+ }
+alphaARG;
+
+#undef TYPE_ALPHA
+FIELDTYPE *TYPE_ALPHA;
+
+/* ./fty_enum.c */
+
+typedef struct
+ {
+ char **kwds;
+ int count;
+ NCURSES_BOOL checkcase;
+ NCURSES_BOOL checkunique;
+ }
+enumARG;
+
+typedef struct
+ {
+ char **kwds;
+ int ccase;
+ int cunique;
+ }
+enumParams;
+
+#undef TYPE_ENUM
+FIELDTYPE *TYPE_ENUM;
+
+/* ./fty_generic.c */
+
+#undef _nc_fty_generic
+void _nc_fty_generic(void)
+ { /* void */ }
+
+/* ./fty_int.c */
+
+typedef struct
+ {
+ int precision;
+ long low;
+ long high;
+ }
+integerARG;
+
+typedef struct
+ {
+ int precision;
+ long low;
+ long high;
+ }
+integerPARM;
+
+#undef TYPE_INTEGER
+FIELDTYPE *TYPE_INTEGER;
+
+/* ./fty_ipv4.c */
+#undef TYPE_IPV4
+FIELDTYPE *TYPE_IPV4;
+
+/* ./fty_num.c */
+
+#include <locale.h>
+
+typedef struct
+ {
+ int precision;
+ double low;
+ double high;
+ struct lconv *L;
+ }
+numericARG;
+
+typedef struct
+ {
+ int precision;
+ double low;
+ double high;
+ }
+thisPARM;
+
+#undef TYPE_NUMERIC
+FIELDTYPE *TYPE_NUMERIC;
+
+/* ./fty_regex.c */
+
+#include <regex.h>
+
+typedef struct
+ {
+ regex_t *pRegExp;
+ unsigned long *refCount;
+ }
+RegExp_Arg;
+
+#undef TYPE_REGEXP
+FIELDTYPE *TYPE_REGEXP;
diff --git a/payloads/libpayload/curses/form/llib-lformw b/payloads/libpayload/curses/form/llib-lformw
new file mode 100644
index 0000000000..30c24b5602
--- /dev/null
+++ b/payloads/libpayload/curses/form/llib-lformw
@@ -0,0 +1,783 @@
+/****************************************************************************
+ * Copyright (c) 2002-2005,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2002-2005,2010 *
+ ****************************************************************************/
+/* LINTLIBRARY */
+
+/* ./f_trace.c */
+
+#include <form.priv.h>
+
+#undef _nc_retrace_field_ptr
+FIELD **_nc_retrace_field_ptr(
+ FIELD **code)
+ { return(*(FIELD ***)0); }
+
+#undef _nc_retrace_field
+FIELD *_nc_retrace_field(
+ FIELD *code)
+ { return(*(FIELD **)0); }
+
+#undef _nc_retrace_field_type
+FIELDTYPE *_nc_retrace_field_type(
+ FIELDTYPE *code)
+ { return(*(FIELDTYPE **)0); }
+
+#undef _nc_retrace_form
+FORM *_nc_retrace_form(
+ FORM *code)
+ { return(*(FORM **)0); }
+
+#undef _nc_retrace_form_hook
+Form_Hook _nc_retrace_form_hook(
+ Form_Hook code)
+ { return(*(Form_Hook *)0); }
+
+/* ./fld_arg.c */
+
+#undef set_fieldtype_arg
+int set_fieldtype_arg(
+ FIELDTYPE *typ,
+ void *(*const make_arg)(
+ va_list *p1),
+ void *(*const copy_arg)(
+ const void *p1),
+ void (*const free_arg)(
+ void *p1))
+ { return(*(int *)0); }
+
+#undef field_arg
+void *field_arg(
+ const FIELD *field)
+ { return(*(void **)0); }
+
+/* ./fld_attr.c */
+
+#undef set_field_fore
+int set_field_fore(
+ FIELD *field,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef field_fore
+chtype field_fore(
+ const FIELD *field)
+ { return(*(chtype *)0); }
+
+#undef set_field_back
+int set_field_back(
+ FIELD *field,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef field_back
+chtype field_back(
+ const FIELD *field)
+ { return(*(chtype *)0); }
+
+/* ./fld_current.c */
+
+#undef set_current_field
+int set_current_field(
+ FORM *form,
+ FIELD *field)
+ { return(*(int *)0); }
+
+#undef current_field
+FIELD *current_field(
+ const FORM *form)
+ { return(*(FIELD **)0); }
+
+#undef field_index
+int field_index(
+ const FIELD *field)
+ { return(*(int *)0); }
+
+/* ./fld_def.c */
+
+#undef _nc_Default_Field
+FIELD *_nc_Default_Field;
+
+#undef _nc_Make_Argument
+TypeArgument *_nc_Make_Argument(
+ const FIELDTYPE *typ,
+ va_list *ap,
+ int *err)
+ { return(*(TypeArgument **)0); }
+
+#undef _nc_Copy_Argument
+TypeArgument *_nc_Copy_Argument(
+ const FIELDTYPE *typ,
+ const TypeArgument *argp,
+ int *err)
+ { return(*(TypeArgument **)0); }
+
+#undef _nc_Free_Argument
+void _nc_Free_Argument(
+ const FIELDTYPE *typ,
+ TypeArgument *argp)
+ { /* void */ }
+
+#undef _nc_Copy_Type
+NCURSES_BOOL _nc_Copy_Type(
+ FIELD *dst,
+ FIELD const *src)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef _nc_Free_Type
+void _nc_Free_Type(
+ FIELD *field)
+ { /* void */ }
+
+#undef new_field
+FIELD *new_field(
+ int rows,
+ int cols,
+ int frow,
+ int fcol,
+ int nrow,
+ int nbuf)
+ { return(*(FIELD **)0); }
+
+#undef free_field
+int free_field(
+ FIELD *field)
+ { return(*(int *)0); }
+
+/* ./fld_dup.c */
+
+#undef dup_field
+FIELD *dup_field(
+ FIELD *field,
+ int frow,
+ int fcol)
+ { return(*(FIELD **)0); }
+
+/* ./fld_ftchoice.c */
+
+#undef set_fieldtype_choice
+int set_fieldtype_choice(
+ FIELDTYPE *typ,
+ NCURSES_BOOL (*const next_choice)(
+ FIELD *p1,
+ const void *p2),
+ NCURSES_BOOL (*const prev_choice)(
+ FIELD *p1,
+ const void *p2))
+ { return(*(int *)0); }
+
+/* ./fld_ftlink.c */
+
+#undef link_fieldtype
+FIELDTYPE *link_fieldtype(
+ FIELDTYPE *type1,
+ FIELDTYPE *type2)
+ { return(*(FIELDTYPE **)0); }
+
+/* ./fld_info.c */
+
+#undef field_info
+int field_info(
+ const FIELD *field,
+ int *rows,
+ int *cols,
+ int *frow,
+ int *fcol,
+ int *nrow,
+ int *nbuf)
+ { return(*(int *)0); }
+
+#undef dynamic_field_info
+int dynamic_field_info(
+ const FIELD *field,
+ int *drows,
+ int *dcols,
+ int *maxgrow)
+ { return(*(int *)0); }
+
+/* ./fld_just.c */
+
+#undef set_field_just
+int set_field_just(
+ FIELD *field,
+ int just)
+ { return(*(int *)0); }
+
+#undef field_just
+int field_just(
+ const FIELD *field)
+ { return(*(int *)0); }
+
+/* ./fld_link.c */
+
+#undef link_field
+FIELD *link_field(
+ FIELD *field,
+ int frow,
+ int fcol)
+ { return(*(FIELD **)0); }
+
+/* ./fld_max.c */
+
+#undef set_max_field
+int set_max_field(
+ FIELD *field,
+ int maxgrow)
+ { return(*(int *)0); }
+
+/* ./fld_move.c */
+
+#undef move_field
+int move_field(
+ FIELD *field,
+ int frow,
+ int fcol)
+ { return(*(int *)0); }
+
+/* ./fld_newftyp.c */
+
+#undef _nc_Default_FieldType
+FIELDTYPE *_nc_Default_FieldType;
+
+#undef new_fieldtype
+FIELDTYPE *new_fieldtype(
+ NCURSES_BOOL (*const field_check)(
+ FIELD *p1,
+ const void *p2),
+ NCURSES_BOOL (*const char_check)(
+ int p1,
+ const void *p2))
+ { return(*(FIELDTYPE **)0); }
+
+#undef free_fieldtype
+int free_fieldtype(
+ FIELDTYPE *typ)
+ { return(*(int *)0); }
+
+/* ./fld_opts.c */
+
+#undef set_field_opts
+int set_field_opts(
+ FIELD *field,
+ Field_Options opts)
+ { return(*(int *)0); }
+
+#undef field_opts
+Field_Options field_opts(
+ const FIELD *field)
+ { return(*(Field_Options *)0); }
+
+#undef field_opts_on
+int field_opts_on(
+ FIELD *field,
+ Field_Options opts)
+ { return(*(int *)0); }
+
+#undef field_opts_off
+int field_opts_off(
+ FIELD *field,
+ Field_Options opts)
+ { return(*(int *)0); }
+
+/* ./fld_pad.c */
+
+#undef set_field_pad
+int set_field_pad(
+ FIELD *field,
+ int ch)
+ { return(*(int *)0); }
+
+#undef field_pad
+int field_pad(
+ const FIELD *field)
+ { return(*(int *)0); }
+
+/* ./fld_page.c */
+
+#undef set_new_page
+int set_new_page(
+ FIELD *field,
+ NCURSES_BOOL new_page_flag)
+ { return(*(int *)0); }
+
+#undef new_page
+NCURSES_BOOL new_page(
+ const FIELD *field)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./fld_stat.c */
+
+#undef set_field_status
+int set_field_status(
+ FIELD *field,
+ NCURSES_BOOL status)
+ { return(*(int *)0); }
+
+#undef field_status
+NCURSES_BOOL field_status(
+ const FIELD *field)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./fld_type.c */
+
+#undef set_field_type
+int set_field_type(
+ FIELD *field,
+ FIELDTYPE *type,
+ ...)
+ { return(*(int *)0); }
+
+#undef field_type
+FIELDTYPE *field_type(
+ const FIELD *field)
+ { return(*(FIELDTYPE **)0); }
+
+/* ./fld_user.c */
+
+#undef set_field_userptr
+int set_field_userptr(
+ FIELD *field,
+ void *usrptr)
+ { return(*(int *)0); }
+
+#undef field_userptr
+void *field_userptr(
+ const FIELD *field)
+ { return(*(void **)0); }
+
+/* ./frm_cursor.c */
+
+#undef pos_form_cursor
+int pos_form_cursor(
+ FORM *form)
+ { return(*(int *)0); }
+
+/* ./frm_data.c */
+
+#undef data_behind
+NCURSES_BOOL data_behind(
+ const FORM *form)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef data_ahead
+NCURSES_BOOL data_ahead(
+ const FORM *form)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./frm_def.c */
+
+#undef _nc_Default_Form
+FORM *_nc_Default_Form;
+
+#undef new_form_sp
+FORM *new_form_sp(
+ SCREEN *sp,
+ FIELD **fields)
+ { return(*(FORM **)0); }
+
+#undef new_form
+FORM *new_form(
+ FIELD **fields)
+ { return(*(FORM **)0); }
+
+#undef free_form
+int free_form(
+ FORM *form)
+ { return(*(int *)0); }
+
+#undef set_form_fields
+int set_form_fields(
+ FORM *form,
+ FIELD **fields)
+ { return(*(int *)0); }
+
+#undef form_fields
+FIELD **form_fields(
+ const FORM *form)
+ { return(*(FIELD ***)0); }
+
+#undef field_count
+int field_count(
+ const FORM *form)
+ { return(*(int *)0); }
+
+/* ./frm_driver.c */
+
+#undef _nc_get_fieldbuffer
+void _nc_get_fieldbuffer(
+ FORM *form,
+ FIELD *field,
+ cchar_t *buf)
+ { /* void */ }
+
+#undef _nc_Position_Form_Cursor
+int _nc_Position_Form_Cursor(
+ FORM *form)
+ { return(*(int *)0); }
+
+#undef _nc_Refresh_Current_Field
+int _nc_Refresh_Current_Field(
+ FORM *form)
+ { return(*(int *)0); }
+
+#undef _nc_Synchronize_Attributes
+int _nc_Synchronize_Attributes(
+ FIELD *field)
+ { return(*(int *)0); }
+
+#undef _nc_Synchronize_Options
+int _nc_Synchronize_Options(
+ FIELD *field,
+ Field_Options newopts)
+ { return(*(int *)0); }
+
+#undef _nc_Set_Current_Field
+int _nc_Set_Current_Field(
+ FORM *form,
+ FIELD *newfield)
+ { return(*(int *)0); }
+
+#undef _nc_Internal_Validation
+NCURSES_BOOL _nc_Internal_Validation(
+ FORM *form)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef _nc_First_Active_Field
+FIELD *_nc_First_Active_Field(
+ FORM *form)
+ { return(*(FIELD **)0); }
+
+#undef _nc_Set_Form_Page
+int _nc_Set_Form_Page(
+ FORM *form,
+ int page,
+ FIELD *field)
+ { return(*(int *)0); }
+
+typedef struct
+{
+ int keycode;
+ int (*cmd) (FORM *);
+}
+Binding_Info;
+
+#undef form_driver
+int form_driver(
+ FORM *form,
+ int c)
+ { return(*(int *)0); }
+
+#undef set_field_buffer
+int set_field_buffer(
+ FIELD *field,
+ int buffer,
+ const char *value)
+ { return(*(int *)0); }
+
+#undef field_buffer
+char *field_buffer(
+ const FIELD *field,
+ int buffer)
+ { return(*(char **)0); }
+
+#undef _nc_Widen_String
+wchar_t *_nc_Widen_String(
+ char *source,
+ int *lengthp)
+ { return(*(wchar_t **)0); }
+
+/* ./frm_hook.c */
+
+#undef set_field_init
+int set_field_init(
+ FORM *form,
+ Form_Hook func)
+ { return(*(int *)0); }
+
+#undef field_init
+Form_Hook field_init(
+ const FORM *form)
+ { return(*(Form_Hook *)0); }
+
+#undef set_field_term
+int set_field_term(
+ FORM *form,
+ Form_Hook func)
+ { return(*(int *)0); }
+
+#undef field_term
+Form_Hook field_term(
+ const FORM *form)
+ { return(*(Form_Hook *)0); }
+
+#undef set_form_init
+int set_form_init(
+ FORM *form,
+ Form_Hook func)
+ { return(*(int *)0); }
+
+#undef form_init
+Form_Hook form_init(
+ const FORM *form)
+ { return(*(Form_Hook *)0); }
+
+#undef set_form_term
+int set_form_term(
+ FORM *form,
+ Form_Hook func)
+ { return(*(int *)0); }
+
+#undef form_term
+Form_Hook form_term(
+ const FORM *form)
+ { return(*(Form_Hook *)0); }
+
+/* ./frm_opts.c */
+
+#undef set_form_opts
+int set_form_opts(
+ FORM *form,
+ Form_Options opts)
+ { return(*(int *)0); }
+
+#undef form_opts
+Form_Options form_opts(
+ const FORM *form)
+ { return(*(Form_Options *)0); }
+
+#undef form_opts_on
+int form_opts_on(
+ FORM *form,
+ Form_Options opts)
+ { return(*(int *)0); }
+
+#undef form_opts_off
+int form_opts_off(
+ FORM *form,
+ Form_Options opts)
+ { return(*(int *)0); }
+
+/* ./frm_page.c */
+
+#undef set_form_page
+int set_form_page(
+ FORM *form,
+ int page)
+ { return(*(int *)0); }
+
+#undef form_page
+int form_page(
+ const FORM *form)
+ { return(*(int *)0); }
+
+/* ./frm_post.c */
+
+#undef post_form
+int post_form(
+ FORM *form)
+ { return(*(int *)0); }
+
+#undef unpost_form
+int unpost_form(
+ FORM *form)
+ { return(*(int *)0); }
+
+/* ./frm_req_name.c */
+
+#undef form_request_name
+const char *form_request_name(
+ int request)
+ { return(*(const char **)0); }
+
+#undef form_request_by_name
+int form_request_by_name(
+ const char *str)
+ { return(*(int *)0); }
+
+/* ./frm_scale.c */
+
+#undef scale_form
+int scale_form(
+ const FORM *form,
+ int *rows,
+ int *cols)
+ { return(*(int *)0); }
+
+/* ./frm_sub.c */
+
+#undef set_form_sub
+int set_form_sub(
+ FORM *form,
+ WINDOW *win)
+ { return(*(int *)0); }
+
+#undef form_sub
+WINDOW *form_sub(
+ const FORM *form)
+ { return(*(WINDOW **)0); }
+
+/* ./frm_user.c */
+
+#undef set_form_userptr
+int set_form_userptr(
+ FORM *form,
+ void *usrptr)
+ { return(*(int *)0); }
+
+#undef form_userptr
+void *form_userptr(
+ const FORM *form)
+ { return(*(void **)0); }
+
+/* ./frm_win.c */
+
+#undef set_form_win
+int set_form_win(
+ FORM *form,
+ WINDOW *win)
+ { return(*(int *)0); }
+
+#undef form_win
+WINDOW *form_win(
+ const FORM *form)
+ { return(*(WINDOW **)0); }
+
+/* ./fty_alnum.c */
+
+typedef struct
+ {
+ int width;
+ }
+alnumARG;
+
+#undef TYPE_ALNUM
+FIELDTYPE *TYPE_ALNUM;
+
+/* ./fty_alpha.c */
+
+typedef struct
+ {
+ int width;
+ }
+alphaARG;
+
+#undef TYPE_ALPHA
+FIELDTYPE *TYPE_ALPHA;
+
+/* ./fty_enum.c */
+
+typedef struct
+ {
+ char **kwds;
+ int count;
+ NCURSES_BOOL checkcase;
+ NCURSES_BOOL checkunique;
+ }
+enumARG;
+
+typedef struct
+ {
+ char **kwds;
+ int ccase;
+ int cunique;
+ }
+enumParams;
+
+#undef TYPE_ENUM
+FIELDTYPE *TYPE_ENUM;
+
+/* ./fty_generic.c */
+
+#undef _nc_fty_generic
+void _nc_fty_generic(void)
+ { /* void */ }
+
+/* ./fty_int.c */
+
+typedef struct
+ {
+ int precision;
+ long low;
+ long high;
+ }
+integerARG;
+
+typedef struct
+ {
+ int precision;
+ long low;
+ long high;
+ }
+integerPARM;
+
+#undef TYPE_INTEGER
+FIELDTYPE *TYPE_INTEGER;
+
+/* ./fty_ipv4.c */
+#undef TYPE_IPV4
+FIELDTYPE *TYPE_IPV4;
+
+/* ./fty_num.c */
+
+#include <locale.h>
+
+typedef struct
+ {
+ int precision;
+ double low;
+ double high;
+ struct lconv *L;
+ }
+numericARG;
+
+typedef struct
+ {
+ int precision;
+ double low;
+ double high;
+ }
+thisPARM;
+
+#undef TYPE_NUMERIC
+FIELDTYPE *TYPE_NUMERIC;
+
+/* ./fty_regex.c */
+
+#include <regex.h>
+
+typedef struct
+ {
+ regex_t *pRegExp;
+ unsigned long *refCount;
+ }
+RegExp_Arg;
+
+#undef TYPE_REGEXP
+FIELDTYPE *TYPE_REGEXP;
diff --git a/payloads/libpayload/curses/form/modules b/payloads/libpayload/curses/form/modules
new file mode 100644
index 0000000000..205356bba5
--- /dev/null
+++ b/payloads/libpayload/curses/form/modules
@@ -0,0 +1,78 @@
+# $Id: modules,v 1.17 2010/01/23 16:26:37 tom Exp $
+##############################################################################
+# Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. #
+# #
+# Permission is hereby granted, free of charge, to any person obtaining a #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation #
+# the rights to use, copy, modify, merge, publish, distribute, distribute #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the #
+# following conditions: #
+# #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software. #
+# #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
+# DEALINGS IN THE SOFTWARE. #
+# #
+# Except as contained in this notice, the name(s) of the above copyright #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written #
+# authorization. #
+##############################################################################
+#
+# Author: Thomas E. Dickey 1995-on
+# and: Juergen Pfeifer 2008
+#
+
+@ base
+# Library objects
+f_trace lib $(srcdir) $(HEADER_DEPS)
+fld_arg lib $(srcdir) $(HEADER_DEPS)
+fld_attr lib $(srcdir) $(HEADER_DEPS)
+fld_current lib $(srcdir) $(HEADER_DEPS)
+fld_def lib $(srcdir) $(HEADER_DEPS)
+fld_dup lib $(srcdir) $(HEADER_DEPS)
+fld_ftchoice lib $(srcdir) $(HEADER_DEPS)
+fld_ftlink lib $(srcdir) $(HEADER_DEPS)
+fld_info lib $(srcdir) $(HEADER_DEPS)
+fld_just lib $(srcdir) $(HEADER_DEPS)
+fld_link lib $(srcdir) $(HEADER_DEPS)
+fld_max lib $(srcdir) $(HEADER_DEPS)
+fld_move lib $(srcdir) $(HEADER_DEPS)
+fld_newftyp lib $(srcdir) $(HEADER_DEPS)
+fld_opts lib $(srcdir) $(HEADER_DEPS)
+fld_pad lib $(srcdir) $(HEADER_DEPS)
+fld_page lib $(srcdir) $(HEADER_DEPS)
+fld_stat lib $(srcdir) $(HEADER_DEPS)
+fld_type lib $(srcdir) $(HEADER_DEPS)
+fld_user lib $(srcdir) $(HEADER_DEPS)
+frm_cursor lib $(srcdir) $(HEADER_DEPS)
+frm_data lib $(srcdir) $(HEADER_DEPS)
+frm_def lib $(srcdir) $(HEADER_DEPS)
+frm_driver lib $(srcdir) $(HEADER_DEPS)
+frm_hook lib $(srcdir) $(HEADER_DEPS)
+frm_opts lib $(srcdir) $(HEADER_DEPS)
+frm_page lib $(srcdir) $(HEADER_DEPS)
+frm_post lib $(srcdir) $(HEADER_DEPS)
+frm_req_name lib $(srcdir) $(HEADER_DEPS)
+frm_scale lib $(srcdir) $(HEADER_DEPS)
+frm_sub lib $(srcdir) $(HEADER_DEPS)
+frm_user lib $(srcdir) $(HEADER_DEPS)
+frm_win lib $(srcdir) $(HEADER_DEPS)
+fty_alnum lib $(srcdir) $(HEADER_DEPS)
+fty_alpha lib $(srcdir) $(HEADER_DEPS)
+fty_enum lib $(srcdir) $(HEADER_DEPS)
+fty_generic lib $(srcdir) $(HEADER_DEPS)
+fty_int lib $(srcdir) $(HEADER_DEPS)
+fty_ipv4 lib $(srcdir) $(HEADER_DEPS)
+fty_num lib $(srcdir) $(HEADER_DEPS)
+fty_regex lib $(srcdir) $(HEADER_DEPS)
+
+# vile:makemode
diff --git a/payloads/libpayload/curses/menu/Makefile.in b/payloads/libpayload/curses/menu/Makefile.in
new file mode 100644
index 0000000000..253ff4f641
--- /dev/null
+++ b/payloads/libpayload/curses/menu/Makefile.in
@@ -0,0 +1,172 @@
+# $Id: Makefile.in,v 1.54 2010/11/27 21:45:27 tom Exp $
+##############################################################################
+# Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. #
+# #
+# Permission is hereby granted, free of charge, to any person obtaining a #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation #
+# the rights to use, copy, modify, merge, publish, distribute, distribute #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the #
+# following conditions: #
+# #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software. #
+# #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
+# DEALINGS IN THE SOFTWARE. #
+# #
+# Except as contained in this notice, the name(s) of the above copyright #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written #
+# authorization. #
+##############################################################################
+#
+# Author: Thomas E. Dickey 1996-on
+#
+# Makefile for menu source code.
+#
+# This makes the following:
+# libraries (normal/debug/profile/shared)
+#
+# The variable 'srcdir' refers to the source-distribution, and can be set with
+# the configure script by "--srcdir=DIR".
+#
+# The rules are organized to produce the libraries for the configured models,
+
+# turn off _all_ suffix rules; we'll generate our own
+.SUFFIXES:
+
+SHELL = /bin/sh
+VPATH = @srcdir@
+THIS = Makefile
+
+x = @EXEEXT@
+o = .@OBJEXT@
+
+MODEL = @DFT_LWR_MODEL@
+DESTDIR = @DESTDIR@
+srcdir = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+libdir = @libdir@
+includedir = @includedir@
+
+LIBTOOL = @LIBTOOL@
+LIBTOOL_CLEAN = @LIB_CLEAN@
+LIBTOOL_COMPILE = @LIB_COMPILE@
+LIBTOOL_LINK = @LIB_LINK@
+LIBTOOL_INSTALL = @LIB_INSTALL@
+LIBTOOL_UNINSTALL = @LIB_UNINSTALL@
+LT_UNDEF = @LT_UNDEF@
+
+INSTALL = @INSTALL@
+INSTALL_LIB = @INSTALL@ @INSTALL_LIB@
+INSTALL_PROG = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+AR = @AR@
+ARFLAGS = @ARFLAGS@
+AWK = @AWK@
+LD = @LD@
+LN_S = @LN_S@
+
+CTAGS = @CTAGS@
+ETAGS = @ETAGS@
+
+CC = @CC@
+CPP = @CPP@
+CFLAGS = @CFLAGS@
+
+CPPFLAGS = -I@top_srcdir@/ncurses -DHAVE_CONFIG_H @CPPFLAGS@
+
+CCFLAGS = $(CPPFLAGS) $(CFLAGS)
+
+CFLAGS_LIBTOOL = $(CCFLAGS)
+CFLAGS_NORMAL = $(CCFLAGS)
+CFLAGS_DEBUG = $(CCFLAGS) @CC_G_OPT@ -DTRACE
+CFLAGS_PROFILE = $(CCFLAGS) -pg
+CFLAGS_SHARED = $(CCFLAGS) @CC_SHARED_OPTS@
+
+CFLAGS_DEFAULT = $(CFLAGS_@DFT_UPR_MODEL@)
+
+LINK = $(LIBTOOL_LINK)
+LDFLAGS = @LDFLAGS@ @LD_MODEL@ @LIBS@
+
+SHLIB_DIRS = -L../lib
+SHLIB_LIST = $(SHLIB_DIRS) -lncurses@LIB_SUFFIX@ @SHLIB_LIST@
+
+MK_SHARED_LIB = @MK_SHARED_LIB@
+
+NCURSES_MAJOR = @NCURSES_MAJOR@
+NCURSES_MINOR = @NCURSES_MINOR@
+REL_VERSION = @cf_cv_rel_version@
+ABI_VERSION = @cf_cv_abi_version@
+
+RANLIB = @LIB_PREP@
+
+LIBRARIES = @LIBS_TO_MAKE@
+
+LINT = @LINT@
+LINT_OPTS = @LINT_OPTS@
+LINT_LIBS = -lmenu -lncurses @LIBS@
+
+AUTO_SRC = \
+ ../include/menu.h \
+ ../include/eti.h \
+ ../include/mf_common.h
+
+################################################################################
+all \
+libs \
+install :: $(AUTO_SRC) $(LIBRARIES)
+
+sources : $(AUTO_SRC)
+
+$(DESTDIR)$(bindir) \
+$(DESTDIR)$(libdir) :
+ mkdir -p $@
+
+# make copies to simplify include-paths while still keeping menu's include
+# file in this directory.
+../include/menu.h : $(srcdir)/menu.h
+ -rm -f $@
+ cp $(srcdir)/menu.h $@
+../include/eti.h : $(srcdir)/eti.h
+ -rm -f $@
+ cp $(srcdir)/eti.h $@
+../include/mf_common.h : $(srcdir)/mf_common.h
+ -rm -f $@
+ cp $(srcdir)/mf_common.h $@
+
+HEADER_DEPS = \
+ $(srcdir)/menu.priv.h \
+ $(AUTO_SRC) \
+ ../include/curses.h
+
+tags:
+ $(CTAGS) *.[ch]
+
+@MAKE_UPPER_TAGS@TAGS:
+@MAKE_UPPER_TAGS@ $(ETAGS) *.[ch]
+
+mostlyclean ::
+ -rm -f core tags TAGS *~ *.bak *.i *.ln *.atac trace
+
+clean :: mostlyclean
+ -rm -f $(AUTO_SRC)
+
+distclean :: clean
+ -rm -f Makefile
+
+realclean :: distclean
+
+###############################################################################
+# The remainder of this file is automatically generated during configuration
+###############################################################################
diff --git a/payloads/libpayload/curses/menu/READ.ME b/payloads/libpayload/curses/menu/READ.ME
new file mode 100644
index 0000000000..10ff5b0114
--- /dev/null
+++ b/payloads/libpayload/curses/menu/READ.ME
@@ -0,0 +1,42 @@
+-------------------------------------------------------------------------------
+-- Copyright (c) 1998-2003,2006 Free Software Foundation, Inc. --
+-- --
+-- Permission is hereby granted, free of charge, to any person obtaining a --
+-- copy of this software and associated documentation files (the --
+-- "Software"), to deal in the Software without restriction, including --
+-- without limitation the rights to use, copy, modify, merge, publish, --
+-- distribute, distribute with modifications, sublicense, and/or sell copies --
+-- of the Software, and to permit persons to whom the Software is furnished --
+-- to do so, subject to the following conditions: --
+-- --
+-- The above copyright notice and this permission notice shall be included --
+-- in all copies or substantial portions of the Software. --
+-- --
+-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
+-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
+-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN --
+-- NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
+-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
+-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE --
+-- USE OR OTHER DEALINGS IN THE SOFTWARE. --
+-- --
+-- Except as contained in this notice, the name(s) of the above copyright --
+-- holders shall not be used in advertising or otherwise to promote the --
+-- sale, use or other dealings in this Software without prior written --
+-- authorization. --
+-------------------------------------------------------------------------------
+-- $Id: READ.ME,v 1.9 2006/04/22 23:13:05 tom Exp $
+-------------------------------------------------------------------------------
+
+This is a clone of the menu library that is available with typical
+System V curses implementations (ETI).
+
+It is modelled after the documentation that comes for this library with
+a 386 based SVR4 implementation (ESIX).
+
+The development environment was and is an ELF based Linux system.
+
+For things that still need doing, see the TO-DO file in the top-level
+directory.
+
+Juergen Pfeifer
diff --git a/payloads/libpayload/curses/menu/eti.h b/payloads/libpayload/curses/menu/eti.h
new file mode 100644
index 0000000000..baa6190d8f
--- /dev/null
+++ b/payloads/libpayload/curses/menu/eti.h
@@ -0,0 +1,54 @@
+/****************************************************************************
+ * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/* $Id: eti.h,v 1.8 2003/10/25 15:24:29 tom Exp $ */
+
+#ifndef NCURSES_ETI_H_incl
+#define NCURSES_ETI_H_incl 1
+
+#define E_OK (0)
+#define E_SYSTEM_ERROR (-1)
+#define E_BAD_ARGUMENT (-2)
+#define E_POSTED (-3)
+#define E_CONNECTED (-4)
+#define E_BAD_STATE (-5)
+#define E_NO_ROOM (-6)
+#define E_NOT_POSTED (-7)
+#define E_UNKNOWN_COMMAND (-8)
+#define E_NO_MATCH (-9)
+#define E_NOT_SELECTABLE (-10)
+#define E_NOT_CONNECTED (-11)
+#define E_REQUEST_DENIED (-12)
+#define E_INVALID_FIELD (-13)
+#define E_CURRENT (-14)
+
+#endif
diff --git a/payloads/libpayload/curses/menu/headers b/payloads/libpayload/curses/menu/headers
new file mode 100644
index 0000000000..18c20af24f
--- /dev/null
+++ b/payloads/libpayload/curses/menu/headers
@@ -0,0 +1,33 @@
+##############################################################################
+# Copyright (c) 1998,2006 Free Software Foundation, Inc. #
+# #
+# Permission is hereby granted, free of charge, to any person obtaining a #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation #
+# the rights to use, copy, modify, merge, publish, distribute, distribute #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the #
+# following conditions: #
+# #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software. #
+# #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
+# DEALINGS IN THE SOFTWARE. #
+# #
+# Except as contained in this notice, the name(s) of the above copyright #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written #
+# authorization. #
+##############################################################################
+#
+# Author: Thomas E. Dickey <dickey@clark.net> 1996
+#
+$(srcdir)/eti.h
+$(srcdir)/menu.h
+# vile:makemode
diff --git a/payloads/libpayload/curses/menu/llib-lmenu b/payloads/libpayload/curses/menu/llib-lmenu
new file mode 100644
index 0000000000..13ecaf8bdd
--- /dev/null
+++ b/payloads/libpayload/curses/menu/llib-lmenu
@@ -0,0 +1,551 @@
+/****************************************************************************
+ * Copyright (c) 1999-2005,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 1996-2005,2010 *
+ ****************************************************************************/
+/* LINTLIBRARY */
+
+/* ./m_attribs.c */
+
+#include <menu.priv.h>
+
+#undef set_menu_fore
+int set_menu_fore(
+ MENU *menu,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef menu_fore
+chtype menu_fore(
+ const MENU *menu)
+ { return(*(chtype *)0); }
+
+#undef set_menu_back
+int set_menu_back(
+ MENU *menu,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef menu_back
+chtype menu_back(
+ const MENU *menu)
+ { return(*(chtype *)0); }
+
+#undef set_menu_grey
+int set_menu_grey(
+ MENU *menu,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef menu_grey
+chtype menu_grey(
+ const MENU *menu)
+ { return(*(chtype *)0); }
+
+/* ./m_cursor.c */
+
+#undef _nc_menu_cursor_pos
+int _nc_menu_cursor_pos(
+ const MENU *menu,
+ const ITEM *item,
+ int *pY,
+ int *pX)
+ { return(*(int *)0); }
+
+#undef pos_menu_cursor
+int pos_menu_cursor(
+ const MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_driver.c */
+
+#undef _nc_Match_Next_Character_In_Item_Name
+int _nc_Match_Next_Character_In_Item_Name(
+ MENU *menu,
+ int ch,
+ ITEM **item)
+ { return(*(int *)0); }
+
+#undef menu_driver
+int menu_driver(
+ MENU *menu,
+ int c)
+ { return(*(int *)0); }
+
+/* ./m_format.c */
+
+#undef set_menu_format
+int set_menu_format(
+ MENU *menu,
+ int rows,
+ int cols)
+ { return(*(int *)0); }
+
+#undef menu_format
+void menu_format(
+ const MENU *menu,
+ int *rows,
+ int *cols)
+ { /* void */ }
+
+/* ./m_global.c */
+
+#undef _nc_Default_Menu
+MENU _nc_Default_Menu;
+#undef _nc_Default_Item
+ITEM _nc_Default_Item;
+
+#undef _nc_Connect_Items
+NCURSES_BOOL _nc_Connect_Items(
+ MENU *menu,
+ ITEM **items)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef _nc_Disconnect_Items
+void _nc_Disconnect_Items(
+ MENU *menu)
+ { /* void */ }
+
+#undef _nc_Calculate_Text_Width
+int _nc_Calculate_Text_Width(
+ const TEXT *item)
+ { return(*(int *)0); }
+
+#undef _nc_Calculate_Item_Length_and_Width
+void _nc_Calculate_Item_Length_and_Width(
+ MENU *menu)
+ { /* void */ }
+
+#undef _nc_Link_Items
+void _nc_Link_Items(
+ MENU *menu)
+ { /* void */ }
+
+#undef _nc_Show_Menu
+void _nc_Show_Menu(
+ const MENU *menu)
+ { /* void */ }
+
+#undef _nc_New_TopRow_and_CurrentItem
+void _nc_New_TopRow_and_CurrentItem(
+ MENU *menu,
+ int new_toprow,
+ ITEM *new_current_item)
+ { /* void */ }
+
+/* ./m_hook.c */
+
+#undef set_menu_init
+int set_menu_init(
+ MENU *menu,
+ Menu_Hook func)
+ { return(*(int *)0); }
+
+#undef menu_init
+Menu_Hook menu_init(
+ const MENU *menu)
+ { return(*(Menu_Hook *)0); }
+
+#undef set_menu_term
+int set_menu_term(
+ MENU *menu,
+ Menu_Hook func)
+ { return(*(int *)0); }
+
+#undef menu_term
+Menu_Hook menu_term(
+ const MENU *menu)
+ { return(*(Menu_Hook *)0); }
+
+#undef set_item_init
+int set_item_init(
+ MENU *menu,
+ Menu_Hook func)
+ { return(*(int *)0); }
+
+#undef item_init
+Menu_Hook item_init(
+ const MENU *menu)
+ { return(*(Menu_Hook *)0); }
+
+#undef set_item_term
+int set_item_term(
+ MENU *menu,
+ Menu_Hook func)
+ { return(*(int *)0); }
+
+#undef item_term
+Menu_Hook item_term(
+ const MENU *menu)
+ { return(*(Menu_Hook *)0); }
+
+/* ./m_item_cur.c */
+
+#undef set_current_item
+int set_current_item(
+ MENU *menu,
+ ITEM *item)
+ { return(*(int *)0); }
+
+#undef current_item
+ITEM *current_item(
+ const MENU *menu)
+ { return(*(ITEM **)0); }
+
+#undef item_index
+int item_index(
+ const ITEM *item)
+ { return(*(int *)0); }
+
+/* ./m_item_nam.c */
+
+#undef item_name
+const char *item_name(
+ const ITEM *item)
+ { return(*(const char **)0); }
+
+#undef item_description
+const char *item_description(
+ const ITEM *item)
+ { return(*(const char **)0); }
+
+/* ./m_item_new.c */
+
+#undef new_item
+ITEM *new_item(
+ const char *name,
+ const char *description)
+ { return(*(ITEM **)0); }
+
+#undef free_item
+int free_item(
+ ITEM *item)
+ { return(*(int *)0); }
+
+#undef set_menu_mark
+int set_menu_mark(
+ MENU *menu,
+ const char *mark)
+ { return(*(int *)0); }
+
+#undef menu_mark
+const char *menu_mark(
+ const MENU *menu)
+ { return(*(const char **)0); }
+
+/* ./m_item_opt.c */
+
+#undef set_item_opts
+int set_item_opts(
+ ITEM *item,
+ Item_Options opts)
+ { return(*(int *)0); }
+
+#undef item_opts_off
+int item_opts_off(
+ ITEM *item,
+ Item_Options opts)
+ { return(*(int *)0); }
+
+#undef item_opts_on
+int item_opts_on(
+ ITEM *item,
+ Item_Options opts)
+ { return(*(int *)0); }
+
+#undef item_opts
+Item_Options item_opts(
+ const ITEM *item)
+ { return(*(Item_Options *)0); }
+
+/* ./m_item_top.c */
+
+#undef set_top_row
+int set_top_row(
+ MENU *menu,
+ int row)
+ { return(*(int *)0); }
+
+#undef top_row
+int top_row(
+ const MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_item_use.c */
+
+#undef set_item_userptr
+int set_item_userptr(
+ ITEM *item,
+ void *userptr)
+ { return(*(int *)0); }
+
+#undef item_userptr
+void *item_userptr(
+ const ITEM *item)
+ { return(*(void **)0); }
+
+/* ./m_item_val.c */
+
+#undef set_item_value
+int set_item_value(
+ ITEM *item,
+ NCURSES_BOOL value)
+ { return(*(int *)0); }
+
+#undef item_value
+NCURSES_BOOL item_value(
+ const ITEM *item)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./m_item_vis.c */
+
+#undef item_visible
+NCURSES_BOOL item_visible(
+ const ITEM *item)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./m_items.c */
+
+#undef set_menu_items
+int set_menu_items(
+ MENU *menu,
+ ITEM **items)
+ { return(*(int *)0); }
+
+#undef menu_items
+ITEM **menu_items(
+ const MENU *menu)
+ { return(*(ITEM ***)0); }
+
+#undef item_count
+int item_count(
+ const MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_new.c */
+
+#undef new_menu_sp
+MENU *new_menu_sp(
+ SCREEN *sp,
+ ITEM **items)
+ { return(*(MENU **)0); }
+
+#undef new_menu
+MENU *new_menu(
+ ITEM **items)
+ { return(*(MENU **)0); }
+
+#undef free_menu
+int free_menu(
+ MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_opts.c */
+
+#undef set_menu_opts
+int set_menu_opts(
+ MENU *menu,
+ Menu_Options opts)
+ { return(*(int *)0); }
+
+#undef menu_opts_off
+int menu_opts_off(
+ MENU *menu,
+ Menu_Options opts)
+ { return(*(int *)0); }
+
+#undef menu_opts_on
+int menu_opts_on(
+ MENU *menu,
+ Menu_Options opts)
+ { return(*(int *)0); }
+
+#undef menu_opts
+Menu_Options menu_opts(
+ const MENU *menu)
+ { return(*(Menu_Options *)0); }
+
+/* ./m_pad.c */
+
+#undef set_menu_pad
+int set_menu_pad(
+ MENU *menu,
+ int pad)
+ { return(*(int *)0); }
+
+#undef menu_pad
+int menu_pad(
+ const MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_pattern.c */
+
+#undef menu_pattern
+char *menu_pattern(
+ const MENU *menu)
+ { return(*(char **)0); }
+
+#undef set_menu_pattern
+int set_menu_pattern(
+ MENU *menu,
+ const char *p)
+ { return(*(int *)0); }
+
+/* ./m_post.c */
+
+#undef _nc_Post_Item
+void _nc_Post_Item(
+ const MENU *menu,
+ const ITEM *item)
+ { /* void */ }
+
+#undef _nc_Draw_Menu
+void _nc_Draw_Menu(
+ const MENU *menu)
+ { /* void */ }
+
+#undef post_menu
+int post_menu(
+ MENU *menu)
+ { return(*(int *)0); }
+
+#undef unpost_menu
+int unpost_menu(
+ MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_req_name.c */
+
+#undef menu_request_name
+const char *menu_request_name(
+ int request)
+ { return(*(const char **)0); }
+
+#undef menu_request_by_name
+int menu_request_by_name(
+ const char *str)
+ { return(*(int *)0); }
+
+/* ./m_scale.c */
+
+#undef scale_menu
+int scale_menu(
+ const MENU *menu,
+ int *rows,
+ int *cols)
+ { return(*(int *)0); }
+
+/* ./m_spacing.c */
+
+#undef set_menu_spacing
+int set_menu_spacing(
+ MENU *menu,
+ int s_desc,
+ int s_row,
+ int s_col)
+ { return(*(int *)0); }
+
+#undef menu_spacing
+int menu_spacing(
+ const MENU *menu,
+ int *s_desc,
+ int *s_row,
+ int *s_col)
+ { return(*(int *)0); }
+
+/* ./m_sub.c */
+
+#undef set_menu_sub
+int set_menu_sub(
+ MENU *menu,
+ WINDOW *win)
+ { return(*(int *)0); }
+
+#undef menu_sub
+WINDOW *menu_sub(
+ const MENU *menu)
+ { return(*(WINDOW **)0); }
+
+/* ./m_trace.c */
+
+#undef _nc_retrace_item
+ITEM *_nc_retrace_item(
+ ITEM *code)
+ { return(*(ITEM **)0); }
+
+#undef _nc_retrace_item_ptr
+ITEM **_nc_retrace_item_ptr(
+ ITEM **code)
+ { return(*(ITEM ***)0); }
+
+#undef _nc_retrace_item_opts
+Item_Options _nc_retrace_item_opts(
+ Item_Options code)
+ { return(*(Item_Options *)0); }
+
+#undef _nc_retrace_menu
+MENU *_nc_retrace_menu(
+ MENU *code)
+ { return(*(MENU **)0); }
+
+#undef _nc_retrace_menu_hook
+Menu_Hook _nc_retrace_menu_hook(
+ Menu_Hook code)
+ { return(*(Menu_Hook *)0); }
+
+#undef _nc_retrace_menu_opts
+Menu_Options _nc_retrace_menu_opts(
+ Menu_Options code)
+ { return(*(Menu_Options *)0); }
+
+/* ./m_userptr.c */
+
+#undef set_menu_userptr
+int set_menu_userptr(
+ MENU *menu,
+ void *userptr)
+ { return(*(int *)0); }
+
+#undef menu_userptr
+void *menu_userptr(
+ const MENU *menu)
+ { return(*(void **)0); }
+
+/* ./m_win.c */
+
+#undef set_menu_win
+int set_menu_win(
+ MENU *menu,
+ WINDOW *win)
+ { return(*(int *)0); }
+
+#undef menu_win
+WINDOW *menu_win(
+ const MENU *menu)
+ { return(*(WINDOW **)0); }
diff --git a/payloads/libpayload/curses/menu/llib-lmenut b/payloads/libpayload/curses/menu/llib-lmenut
new file mode 100644
index 0000000000..951719f41e
--- /dev/null
+++ b/payloads/libpayload/curses/menu/llib-lmenut
@@ -0,0 +1,551 @@
+/****************************************************************************
+ * Copyright (c) 2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2010 *
+ ****************************************************************************/
+/* LINTLIBRARY */
+
+/* ./m_attribs.c */
+
+#include <menu.priv.h>
+
+#undef set_menu_fore
+int set_menu_fore(
+ MENU *menu,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef menu_fore
+chtype menu_fore(
+ const MENU *menu)
+ { return(*(chtype *)0); }
+
+#undef set_menu_back
+int set_menu_back(
+ MENU *menu,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef menu_back
+chtype menu_back(
+ const MENU *menu)
+ { return(*(chtype *)0); }
+
+#undef set_menu_grey
+int set_menu_grey(
+ MENU *menu,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef menu_grey
+chtype menu_grey(
+ const MENU *menu)
+ { return(*(chtype *)0); }
+
+/* ./m_cursor.c */
+
+#undef _nc_menu_cursor_pos
+int _nc_menu_cursor_pos(
+ const MENU *menu,
+ const ITEM *item,
+ int *pY,
+ int *pX)
+ { return(*(int *)0); }
+
+#undef pos_menu_cursor
+int pos_menu_cursor(
+ const MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_driver.c */
+
+#undef _nc_Match_Next_Character_In_Item_Name
+int _nc_Match_Next_Character_In_Item_Name(
+ MENU *menu,
+ int ch,
+ ITEM **item)
+ { return(*(int *)0); }
+
+#undef menu_driver
+int menu_driver(
+ MENU *menu,
+ int c)
+ { return(*(int *)0); }
+
+/* ./m_format.c */
+
+#undef set_menu_format
+int set_menu_format(
+ MENU *menu,
+ int rows,
+ int cols)
+ { return(*(int *)0); }
+
+#undef menu_format
+void menu_format(
+ const MENU *menu,
+ int *rows,
+ int *cols)
+ { /* void */ }
+
+/* ./m_global.c */
+
+#undef _nc_Default_Menu
+MENU _nc_Default_Menu;
+#undef _nc_Default_Item
+ITEM _nc_Default_Item;
+
+#undef _nc_Connect_Items
+NCURSES_BOOL _nc_Connect_Items(
+ MENU *menu,
+ ITEM **items)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef _nc_Disconnect_Items
+void _nc_Disconnect_Items(
+ MENU *menu)
+ { /* void */ }
+
+#undef _nc_Calculate_Text_Width
+int _nc_Calculate_Text_Width(
+ const TEXT *item)
+ { return(*(int *)0); }
+
+#undef _nc_Calculate_Item_Length_and_Width
+void _nc_Calculate_Item_Length_and_Width(
+ MENU *menu)
+ { /* void */ }
+
+#undef _nc_Link_Items
+void _nc_Link_Items(
+ MENU *menu)
+ { /* void */ }
+
+#undef _nc_Show_Menu
+void _nc_Show_Menu(
+ const MENU *menu)
+ { /* void */ }
+
+#undef _nc_New_TopRow_and_CurrentItem
+void _nc_New_TopRow_and_CurrentItem(
+ MENU *menu,
+ int new_toprow,
+ ITEM *new_current_item)
+ { /* void */ }
+
+/* ./m_hook.c */
+
+#undef set_menu_init
+int set_menu_init(
+ MENU *menu,
+ Menu_Hook func)
+ { return(*(int *)0); }
+
+#undef menu_init
+Menu_Hook menu_init(
+ const MENU *menu)
+ { return(*(Menu_Hook *)0); }
+
+#undef set_menu_term
+int set_menu_term(
+ MENU *menu,
+ Menu_Hook func)
+ { return(*(int *)0); }
+
+#undef menu_term
+Menu_Hook menu_term(
+ const MENU *menu)
+ { return(*(Menu_Hook *)0); }
+
+#undef set_item_init
+int set_item_init(
+ MENU *menu,
+ Menu_Hook func)
+ { return(*(int *)0); }
+
+#undef item_init
+Menu_Hook item_init(
+ const MENU *menu)
+ { return(*(Menu_Hook *)0); }
+
+#undef set_item_term
+int set_item_term(
+ MENU *menu,
+ Menu_Hook func)
+ { return(*(int *)0); }
+
+#undef item_term
+Menu_Hook item_term(
+ const MENU *menu)
+ { return(*(Menu_Hook *)0); }
+
+/* ./m_item_cur.c */
+
+#undef set_current_item
+int set_current_item(
+ MENU *menu,
+ ITEM *item)
+ { return(*(int *)0); }
+
+#undef current_item
+ITEM *current_item(
+ const MENU *menu)
+ { return(*(ITEM **)0); }
+
+#undef item_index
+int item_index(
+ const ITEM *item)
+ { return(*(int *)0); }
+
+/* ./m_item_nam.c */
+
+#undef item_name
+const char *item_name(
+ const ITEM *item)
+ { return(*(const char **)0); }
+
+#undef item_description
+const char *item_description(
+ const ITEM *item)
+ { return(*(const char **)0); }
+
+/* ./m_item_new.c */
+
+#undef new_item
+ITEM *new_item(
+ const char *name,
+ const char *description)
+ { return(*(ITEM **)0); }
+
+#undef free_item
+int free_item(
+ ITEM *item)
+ { return(*(int *)0); }
+
+#undef set_menu_mark
+int set_menu_mark(
+ MENU *menu,
+ const char *mark)
+ { return(*(int *)0); }
+
+#undef menu_mark
+const char *menu_mark(
+ const MENU *menu)
+ { return(*(const char **)0); }
+
+/* ./m_item_opt.c */
+
+#undef set_item_opts
+int set_item_opts(
+ ITEM *item,
+ Item_Options opts)
+ { return(*(int *)0); }
+
+#undef item_opts_off
+int item_opts_off(
+ ITEM *item,
+ Item_Options opts)
+ { return(*(int *)0); }
+
+#undef item_opts_on
+int item_opts_on(
+ ITEM *item,
+ Item_Options opts)
+ { return(*(int *)0); }
+
+#undef item_opts
+Item_Options item_opts(
+ const ITEM *item)
+ { return(*(Item_Options *)0); }
+
+/* ./m_item_top.c */
+
+#undef set_top_row
+int set_top_row(
+ MENU *menu,
+ int row)
+ { return(*(int *)0); }
+
+#undef top_row
+int top_row(
+ const MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_item_use.c */
+
+#undef set_item_userptr
+int set_item_userptr(
+ ITEM *item,
+ void *userptr)
+ { return(*(int *)0); }
+
+#undef item_userptr
+void *item_userptr(
+ const ITEM *item)
+ { return(*(void **)0); }
+
+/* ./m_item_val.c */
+
+#undef set_item_value
+int set_item_value(
+ ITEM *item,
+ NCURSES_BOOL value)
+ { return(*(int *)0); }
+
+#undef item_value
+NCURSES_BOOL item_value(
+ const ITEM *item)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./m_item_vis.c */
+
+#undef item_visible
+NCURSES_BOOL item_visible(
+ const ITEM *item)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./m_items.c */
+
+#undef set_menu_items
+int set_menu_items(
+ MENU *menu,
+ ITEM **items)
+ { return(*(int *)0); }
+
+#undef menu_items
+ITEM **menu_items(
+ const MENU *menu)
+ { return(*(ITEM ***)0); }
+
+#undef item_count
+int item_count(
+ const MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_new.c */
+
+#undef new_menu_sp
+MENU *new_menu_sp(
+ SCREEN *sp,
+ ITEM **items)
+ { return(*(MENU **)0); }
+
+#undef new_menu
+MENU *new_menu(
+ ITEM **items)
+ { return(*(MENU **)0); }
+
+#undef free_menu
+int free_menu(
+ MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_opts.c */
+
+#undef set_menu_opts
+int set_menu_opts(
+ MENU *menu,
+ Menu_Options opts)
+ { return(*(int *)0); }
+
+#undef menu_opts_off
+int menu_opts_off(
+ MENU *menu,
+ Menu_Options opts)
+ { return(*(int *)0); }
+
+#undef menu_opts_on
+int menu_opts_on(
+ MENU *menu,
+ Menu_Options opts)
+ { return(*(int *)0); }
+
+#undef menu_opts
+Menu_Options menu_opts(
+ const MENU *menu)
+ { return(*(Menu_Options *)0); }
+
+/* ./m_pad.c */
+
+#undef set_menu_pad
+int set_menu_pad(
+ MENU *menu,
+ int pad)
+ { return(*(int *)0); }
+
+#undef menu_pad
+int menu_pad(
+ const MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_pattern.c */
+
+#undef menu_pattern
+char *menu_pattern(
+ const MENU *menu)
+ { return(*(char **)0); }
+
+#undef set_menu_pattern
+int set_menu_pattern(
+ MENU *menu,
+ const char *p)
+ { return(*(int *)0); }
+
+/* ./m_post.c */
+
+#undef _nc_Post_Item
+void _nc_Post_Item(
+ const MENU *menu,
+ const ITEM *item)
+ { /* void */ }
+
+#undef _nc_Draw_Menu
+void _nc_Draw_Menu(
+ const MENU *menu)
+ { /* void */ }
+
+#undef post_menu
+int post_menu(
+ MENU *menu)
+ { return(*(int *)0); }
+
+#undef unpost_menu
+int unpost_menu(
+ MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_req_name.c */
+
+#undef menu_request_name
+const char *menu_request_name(
+ int request)
+ { return(*(const char **)0); }
+
+#undef menu_request_by_name
+int menu_request_by_name(
+ const char *str)
+ { return(*(int *)0); }
+
+/* ./m_scale.c */
+
+#undef scale_menu
+int scale_menu(
+ const MENU *menu,
+ int *rows,
+ int *cols)
+ { return(*(int *)0); }
+
+/* ./m_spacing.c */
+
+#undef set_menu_spacing
+int set_menu_spacing(
+ MENU *menu,
+ int s_desc,
+ int s_row,
+ int s_col)
+ { return(*(int *)0); }
+
+#undef menu_spacing
+int menu_spacing(
+ const MENU *menu,
+ int *s_desc,
+ int *s_row,
+ int *s_col)
+ { return(*(int *)0); }
+
+/* ./m_sub.c */
+
+#undef set_menu_sub
+int set_menu_sub(
+ MENU *menu,
+ WINDOW *win)
+ { return(*(int *)0); }
+
+#undef menu_sub
+WINDOW *menu_sub(
+ const MENU *menu)
+ { return(*(WINDOW **)0); }
+
+/* ./m_trace.c */
+
+#undef _nc_retrace_item
+ITEM *_nc_retrace_item(
+ ITEM *code)
+ { return(*(ITEM **)0); }
+
+#undef _nc_retrace_item_ptr
+ITEM **_nc_retrace_item_ptr(
+ ITEM **code)
+ { return(*(ITEM ***)0); }
+
+#undef _nc_retrace_item_opts
+Item_Options _nc_retrace_item_opts(
+ Item_Options code)
+ { return(*(Item_Options *)0); }
+
+#undef _nc_retrace_menu
+MENU *_nc_retrace_menu(
+ MENU *code)
+ { return(*(MENU **)0); }
+
+#undef _nc_retrace_menu_hook
+Menu_Hook _nc_retrace_menu_hook(
+ Menu_Hook code)
+ { return(*(Menu_Hook *)0); }
+
+#undef _nc_retrace_menu_opts
+Menu_Options _nc_retrace_menu_opts(
+ Menu_Options code)
+ { return(*(Menu_Options *)0); }
+
+/* ./m_userptr.c */
+
+#undef set_menu_userptr
+int set_menu_userptr(
+ MENU *menu,
+ void *userptr)
+ { return(*(int *)0); }
+
+#undef menu_userptr
+void *menu_userptr(
+ const MENU *menu)
+ { return(*(void **)0); }
+
+/* ./m_win.c */
+
+#undef set_menu_win
+int set_menu_win(
+ MENU *menu,
+ WINDOW *win)
+ { return(*(int *)0); }
+
+#undef menu_win
+WINDOW *menu_win(
+ const MENU *menu)
+ { return(*(WINDOW **)0); }
diff --git a/payloads/libpayload/curses/menu/llib-lmenutw b/payloads/libpayload/curses/menu/llib-lmenutw
new file mode 100644
index 0000000000..0cd559ebd2
--- /dev/null
+++ b/payloads/libpayload/curses/menu/llib-lmenutw
@@ -0,0 +1,553 @@
+/****************************************************************************
+ * Copyright (c) 2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2010 *
+ ****************************************************************************/
+/* LINTLIBRARY */
+
+/* ./m_attribs.c */
+
+#include <menu.priv.h>
+
+#undef set_menu_fore
+int set_menu_fore(
+ MENU *menu,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef menu_fore
+chtype menu_fore(
+ const MENU *menu)
+ { return(*(chtype *)0); }
+
+#undef set_menu_back
+int set_menu_back(
+ MENU *menu,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef menu_back
+chtype menu_back(
+ const MENU *menu)
+ { return(*(chtype *)0); }
+
+#undef set_menu_grey
+int set_menu_grey(
+ MENU *menu,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef menu_grey
+chtype menu_grey(
+ const MENU *menu)
+ { return(*(chtype *)0); }
+
+/* ./m_cursor.c */
+
+#undef _nc_menu_cursor_pos
+int _nc_menu_cursor_pos(
+ const MENU *menu,
+ const ITEM *item,
+ int *pY,
+ int *pX)
+ { return(*(int *)0); }
+
+#undef pos_menu_cursor
+int pos_menu_cursor(
+ const MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_driver.c */
+
+#undef _nc_Match_Next_Character_In_Item_Name
+int _nc_Match_Next_Character_In_Item_Name(
+ MENU *menu,
+ int ch,
+ ITEM **item)
+ { return(*(int *)0); }
+
+#undef menu_driver
+int menu_driver(
+ MENU *menu,
+ int c)
+ { return(*(int *)0); }
+
+/* ./m_format.c */
+
+#undef set_menu_format
+int set_menu_format(
+ MENU *menu,
+ int rows,
+ int cols)
+ { return(*(int *)0); }
+
+#undef menu_format
+void menu_format(
+ const MENU *menu,
+ int *rows,
+ int *cols)
+ { /* void */ }
+
+/* ./m_global.c */
+
+#undef _nc_Default_Menu
+MENU _nc_Default_Menu;
+#undef _nc_Default_Item
+ITEM _nc_Default_Item;
+
+#undef _nc_Connect_Items
+NCURSES_BOOL _nc_Connect_Items(
+ MENU *menu,
+ ITEM **items)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef _nc_Disconnect_Items
+void _nc_Disconnect_Items(
+ MENU *menu)
+ { /* void */ }
+
+#undef _nc_Calculate_Text_Width
+int _nc_Calculate_Text_Width(
+ const TEXT *item)
+ { return(*(int *)0); }
+
+#undef _nc_Calculate_Item_Length_and_Width
+void _nc_Calculate_Item_Length_and_Width(
+ MENU *menu)
+ { /* void */ }
+
+#undef _nc_Link_Items
+void _nc_Link_Items(
+ MENU *menu)
+ { /* void */ }
+
+#undef _nc_Show_Menu
+void _nc_Show_Menu(
+ const MENU *menu)
+ { /* void */ }
+
+#undef _nc_New_TopRow_and_CurrentItem
+void _nc_New_TopRow_and_CurrentItem(
+ MENU *menu,
+ int new_toprow,
+ ITEM *new_current_item)
+ { /* void */ }
+
+/* ./m_hook.c */
+
+#undef set_menu_init
+int set_menu_init(
+ MENU *menu,
+ Menu_Hook func)
+ { return(*(int *)0); }
+
+#undef menu_init
+Menu_Hook menu_init(
+ const MENU *menu)
+ { return(*(Menu_Hook *)0); }
+
+#undef set_menu_term
+int set_menu_term(
+ MENU *menu,
+ Menu_Hook func)
+ { return(*(int *)0); }
+
+#undef menu_term
+Menu_Hook menu_term(
+ const MENU *menu)
+ { return(*(Menu_Hook *)0); }
+
+#undef set_item_init
+int set_item_init(
+ MENU *menu,
+ Menu_Hook func)
+ { return(*(int *)0); }
+
+#undef item_init
+Menu_Hook item_init(
+ const MENU *menu)
+ { return(*(Menu_Hook *)0); }
+
+#undef set_item_term
+int set_item_term(
+ MENU *menu,
+ Menu_Hook func)
+ { return(*(int *)0); }
+
+#undef item_term
+Menu_Hook item_term(
+ const MENU *menu)
+ { return(*(Menu_Hook *)0); }
+
+/* ./m_item_cur.c */
+
+#undef set_current_item
+int set_current_item(
+ MENU *menu,
+ ITEM *item)
+ { return(*(int *)0); }
+
+#undef current_item
+ITEM *current_item(
+ const MENU *menu)
+ { return(*(ITEM **)0); }
+
+#undef item_index
+int item_index(
+ const ITEM *item)
+ { return(*(int *)0); }
+
+/* ./m_item_nam.c */
+
+#undef item_name
+const char *item_name(
+ const ITEM *item)
+ { return(*(const char **)0); }
+
+#undef item_description
+const char *item_description(
+ const ITEM *item)
+ { return(*(const char **)0); }
+
+/* ./m_item_new.c */
+
+#include <wctype.h>
+
+#undef new_item
+ITEM *new_item(
+ const char *name,
+ const char *description)
+ { return(*(ITEM **)0); }
+
+#undef free_item
+int free_item(
+ ITEM *item)
+ { return(*(int *)0); }
+
+#undef set_menu_mark
+int set_menu_mark(
+ MENU *menu,
+ const char *mark)
+ { return(*(int *)0); }
+
+#undef menu_mark
+const char *menu_mark(
+ const MENU *menu)
+ { return(*(const char **)0); }
+
+/* ./m_item_opt.c */
+
+#undef set_item_opts
+int set_item_opts(
+ ITEM *item,
+ Item_Options opts)
+ { return(*(int *)0); }
+
+#undef item_opts_off
+int item_opts_off(
+ ITEM *item,
+ Item_Options opts)
+ { return(*(int *)0); }
+
+#undef item_opts_on
+int item_opts_on(
+ ITEM *item,
+ Item_Options opts)
+ { return(*(int *)0); }
+
+#undef item_opts
+Item_Options item_opts(
+ const ITEM *item)
+ { return(*(Item_Options *)0); }
+
+/* ./m_item_top.c */
+
+#undef set_top_row
+int set_top_row(
+ MENU *menu,
+ int row)
+ { return(*(int *)0); }
+
+#undef top_row
+int top_row(
+ const MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_item_use.c */
+
+#undef set_item_userptr
+int set_item_userptr(
+ ITEM *item,
+ void *userptr)
+ { return(*(int *)0); }
+
+#undef item_userptr
+void *item_userptr(
+ const ITEM *item)
+ { return(*(void **)0); }
+
+/* ./m_item_val.c */
+
+#undef set_item_value
+int set_item_value(
+ ITEM *item,
+ NCURSES_BOOL value)
+ { return(*(int *)0); }
+
+#undef item_value
+NCURSES_BOOL item_value(
+ const ITEM *item)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./m_item_vis.c */
+
+#undef item_visible
+NCURSES_BOOL item_visible(
+ const ITEM *item)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./m_items.c */
+
+#undef set_menu_items
+int set_menu_items(
+ MENU *menu,
+ ITEM **items)
+ { return(*(int *)0); }
+
+#undef menu_items
+ITEM **menu_items(
+ const MENU *menu)
+ { return(*(ITEM ***)0); }
+
+#undef item_count
+int item_count(
+ const MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_new.c */
+
+#undef new_menu_sp
+MENU *new_menu_sp(
+ SCREEN *sp,
+ ITEM **items)
+ { return(*(MENU **)0); }
+
+#undef new_menu
+MENU *new_menu(
+ ITEM **items)
+ { return(*(MENU **)0); }
+
+#undef free_menu
+int free_menu(
+ MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_opts.c */
+
+#undef set_menu_opts
+int set_menu_opts(
+ MENU *menu,
+ Menu_Options opts)
+ { return(*(int *)0); }
+
+#undef menu_opts_off
+int menu_opts_off(
+ MENU *menu,
+ Menu_Options opts)
+ { return(*(int *)0); }
+
+#undef menu_opts_on
+int menu_opts_on(
+ MENU *menu,
+ Menu_Options opts)
+ { return(*(int *)0); }
+
+#undef menu_opts
+Menu_Options menu_opts(
+ const MENU *menu)
+ { return(*(Menu_Options *)0); }
+
+/* ./m_pad.c */
+
+#undef set_menu_pad
+int set_menu_pad(
+ MENU *menu,
+ int pad)
+ { return(*(int *)0); }
+
+#undef menu_pad
+int menu_pad(
+ const MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_pattern.c */
+
+#undef menu_pattern
+char *menu_pattern(
+ const MENU *menu)
+ { return(*(char **)0); }
+
+#undef set_menu_pattern
+int set_menu_pattern(
+ MENU *menu,
+ const char *p)
+ { return(*(int *)0); }
+
+/* ./m_post.c */
+
+#undef _nc_Post_Item
+void _nc_Post_Item(
+ const MENU *menu,
+ const ITEM *item)
+ { /* void */ }
+
+#undef _nc_Draw_Menu
+void _nc_Draw_Menu(
+ const MENU *menu)
+ { /* void */ }
+
+#undef post_menu
+int post_menu(
+ MENU *menu)
+ { return(*(int *)0); }
+
+#undef unpost_menu
+int unpost_menu(
+ MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_req_name.c */
+
+#undef menu_request_name
+const char *menu_request_name(
+ int request)
+ { return(*(const char **)0); }
+
+#undef menu_request_by_name
+int menu_request_by_name(
+ const char *str)
+ { return(*(int *)0); }
+
+/* ./m_scale.c */
+
+#undef scale_menu
+int scale_menu(
+ const MENU *menu,
+ int *rows,
+ int *cols)
+ { return(*(int *)0); }
+
+/* ./m_spacing.c */
+
+#undef set_menu_spacing
+int set_menu_spacing(
+ MENU *menu,
+ int s_desc,
+ int s_row,
+ int s_col)
+ { return(*(int *)0); }
+
+#undef menu_spacing
+int menu_spacing(
+ const MENU *menu,
+ int *s_desc,
+ int *s_row,
+ int *s_col)
+ { return(*(int *)0); }
+
+/* ./m_sub.c */
+
+#undef set_menu_sub
+int set_menu_sub(
+ MENU *menu,
+ WINDOW *win)
+ { return(*(int *)0); }
+
+#undef menu_sub
+WINDOW *menu_sub(
+ const MENU *menu)
+ { return(*(WINDOW **)0); }
+
+/* ./m_trace.c */
+
+#undef _nc_retrace_item
+ITEM *_nc_retrace_item(
+ ITEM *code)
+ { return(*(ITEM **)0); }
+
+#undef _nc_retrace_item_ptr
+ITEM **_nc_retrace_item_ptr(
+ ITEM **code)
+ { return(*(ITEM ***)0); }
+
+#undef _nc_retrace_item_opts
+Item_Options _nc_retrace_item_opts(
+ Item_Options code)
+ { return(*(Item_Options *)0); }
+
+#undef _nc_retrace_menu
+MENU *_nc_retrace_menu(
+ MENU *code)
+ { return(*(MENU **)0); }
+
+#undef _nc_retrace_menu_hook
+Menu_Hook _nc_retrace_menu_hook(
+ Menu_Hook code)
+ { return(*(Menu_Hook *)0); }
+
+#undef _nc_retrace_menu_opts
+Menu_Options _nc_retrace_menu_opts(
+ Menu_Options code)
+ { return(*(Menu_Options *)0); }
+
+/* ./m_userptr.c */
+
+#undef set_menu_userptr
+int set_menu_userptr(
+ MENU *menu,
+ void *userptr)
+ { return(*(int *)0); }
+
+#undef menu_userptr
+void *menu_userptr(
+ const MENU *menu)
+ { return(*(void **)0); }
+
+/* ./m_win.c */
+
+#undef set_menu_win
+int set_menu_win(
+ MENU *menu,
+ WINDOW *win)
+ { return(*(int *)0); }
+
+#undef menu_win
+WINDOW *menu_win(
+ const MENU *menu)
+ { return(*(WINDOW **)0); }
diff --git a/payloads/libpayload/curses/menu/llib-lmenuw b/payloads/libpayload/curses/menu/llib-lmenuw
new file mode 100644
index 0000000000..0998f9b0b8
--- /dev/null
+++ b/payloads/libpayload/curses/menu/llib-lmenuw
@@ -0,0 +1,553 @@
+/****************************************************************************
+ * Copyright (c) 2002-2005,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey 2002-2005,2010 *
+ ****************************************************************************/
+/* LINTLIBRARY */
+
+/* ./m_attribs.c */
+
+#include <menu.priv.h>
+
+#undef set_menu_fore
+int set_menu_fore(
+ MENU *menu,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef menu_fore
+chtype menu_fore(
+ const MENU *menu)
+ { return(*(chtype *)0); }
+
+#undef set_menu_back
+int set_menu_back(
+ MENU *menu,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef menu_back
+chtype menu_back(
+ const MENU *menu)
+ { return(*(chtype *)0); }
+
+#undef set_menu_grey
+int set_menu_grey(
+ MENU *menu,
+ chtype attr)
+ { return(*(int *)0); }
+
+#undef menu_grey
+chtype menu_grey(
+ const MENU *menu)
+ { return(*(chtype *)0); }
+
+/* ./m_cursor.c */
+
+#undef _nc_menu_cursor_pos
+int _nc_menu_cursor_pos(
+ const MENU *menu,
+ const ITEM *item,
+ int *pY,
+ int *pX)
+ { return(*(int *)0); }
+
+#undef pos_menu_cursor
+int pos_menu_cursor(
+ const MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_driver.c */
+
+#undef _nc_Match_Next_Character_In_Item_Name
+int _nc_Match_Next_Character_In_Item_Name(
+ MENU *menu,
+ int ch,
+ ITEM **item)
+ { return(*(int *)0); }
+
+#undef menu_driver
+int menu_driver(
+ MENU *menu,
+ int c)
+ { return(*(int *)0); }
+
+/* ./m_format.c */
+
+#undef set_menu_format
+int set_menu_format(
+ MENU *menu,
+ int rows,
+ int cols)
+ { return(*(int *)0); }
+
+#undef menu_format
+void menu_format(
+ const MENU *menu,
+ int *rows,
+ int *cols)
+ { /* void */ }
+
+/* ./m_global.c */
+
+#undef _nc_Default_Menu
+MENU _nc_Default_Menu;
+#undef _nc_Default_Item
+ITEM _nc_Default_Item;
+
+#undef _nc_Connect_Items
+NCURSES_BOOL _nc_Connect_Items(
+ MENU *menu,
+ ITEM **items)
+ { return(*(NCURSES_BOOL *)0); }
+
+#undef _nc_Disconnect_Items
+void _nc_Disconnect_Items(
+ MENU *menu)
+ { /* void */ }
+
+#undef _nc_Calculate_Text_Width
+int _nc_Calculate_Text_Width(
+ const TEXT *item)
+ { return(*(int *)0); }
+
+#undef _nc_Calculate_Item_Length_and_Width
+void _nc_Calculate_Item_Length_and_Width(
+ MENU *menu)
+ { /* void */ }
+
+#undef _nc_Link_Items
+void _nc_Link_Items(
+ MENU *menu)
+ { /* void */ }
+
+#undef _nc_Show_Menu
+void _nc_Show_Menu(
+ const MENU *menu)
+ { /* void */ }
+
+#undef _nc_New_TopRow_and_CurrentItem
+void _nc_New_TopRow_and_CurrentItem(
+ MENU *menu,
+ int new_toprow,
+ ITEM *new_current_item)
+ { /* void */ }
+
+/* ./m_hook.c */
+
+#undef set_menu_init
+int set_menu_init(
+ MENU *menu,
+ Menu_Hook func)
+ { return(*(int *)0); }
+
+#undef menu_init
+Menu_Hook menu_init(
+ const MENU *menu)
+ { return(*(Menu_Hook *)0); }
+
+#undef set_menu_term
+int set_menu_term(
+ MENU *menu,
+ Menu_Hook func)
+ { return(*(int *)0); }
+
+#undef menu_term
+Menu_Hook menu_term(
+ const MENU *menu)
+ { return(*(Menu_Hook *)0); }
+
+#undef set_item_init
+int set_item_init(
+ MENU *menu,
+ Menu_Hook func)
+ { return(*(int *)0); }
+
+#undef item_init
+Menu_Hook item_init(
+ const MENU *menu)
+ { return(*(Menu_Hook *)0); }
+
+#undef set_item_term
+int set_item_term(
+ MENU *menu,
+ Menu_Hook func)
+ { return(*(int *)0); }
+
+#undef item_term
+Menu_Hook item_term(
+ const MENU *menu)
+ { return(*(Menu_Hook *)0); }
+
+/* ./m_item_cur.c */
+
+#undef set_current_item
+int set_current_item(
+ MENU *menu,
+ ITEM *item)
+ { return(*(int *)0); }
+
+#undef current_item
+ITEM *current_item(
+ const MENU *menu)
+ { return(*(ITEM **)0); }
+
+#undef item_index
+int item_index(
+ const ITEM *item)
+ { return(*(int *)0); }
+
+/* ./m_item_nam.c */
+
+#undef item_name
+const char *item_name(
+ const ITEM *item)
+ { return(*(const char **)0); }
+
+#undef item_description
+const char *item_description(
+ const ITEM *item)
+ { return(*(const char **)0); }
+
+/* ./m_item_new.c */
+
+#include <wctype.h>
+
+#undef new_item
+ITEM *new_item(
+ const char *name,
+ const char *description)
+ { return(*(ITEM **)0); }
+
+#undef free_item
+int free_item(
+ ITEM *item)
+ { return(*(int *)0); }
+
+#undef set_menu_mark
+int set_menu_mark(
+ MENU *menu,
+ const char *mark)
+ { return(*(int *)0); }
+
+#undef menu_mark
+const char *menu_mark(
+ const MENU *menu)
+ { return(*(const char **)0); }
+
+/* ./m_item_opt.c */
+
+#undef set_item_opts
+int set_item_opts(
+ ITEM *item,
+ Item_Options opts)
+ { return(*(int *)0); }
+
+#undef item_opts_off
+int item_opts_off(
+ ITEM *item,
+ Item_Options opts)
+ { return(*(int *)0); }
+
+#undef item_opts_on
+int item_opts_on(
+ ITEM *item,
+ Item_Options opts)
+ { return(*(int *)0); }
+
+#undef item_opts
+Item_Options item_opts(
+ const ITEM *item)
+ { return(*(Item_Options *)0); }
+
+/* ./m_item_top.c */
+
+#undef set_top_row
+int set_top_row(
+ MENU *menu,
+ int row)
+ { return(*(int *)0); }
+
+#undef top_row
+int top_row(
+ const MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_item_use.c */
+
+#undef set_item_userptr
+int set_item_userptr(
+ ITEM *item,
+ void *userptr)
+ { return(*(int *)0); }
+
+#undef item_userptr
+void *item_userptr(
+ const ITEM *item)
+ { return(*(void **)0); }
+
+/* ./m_item_val.c */
+
+#undef set_item_value
+int set_item_value(
+ ITEM *item,
+ NCURSES_BOOL value)
+ { return(*(int *)0); }
+
+#undef item_value
+NCURSES_BOOL item_value(
+ const ITEM *item)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./m_item_vis.c */
+
+#undef item_visible
+NCURSES_BOOL item_visible(
+ const ITEM *item)
+ { return(*(NCURSES_BOOL *)0); }
+
+/* ./m_items.c */
+
+#undef set_menu_items
+int set_menu_items(
+ MENU *menu,
+ ITEM **items)
+ { return(*(int *)0); }
+
+#undef menu_items
+ITEM **menu_items(
+ const MENU *menu)
+ { return(*(ITEM ***)0); }
+
+#undef item_count
+int item_count(
+ const MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_new.c */
+
+#undef new_menu_sp
+MENU *new_menu_sp(
+ SCREEN *sp,
+ ITEM **items)
+ { return(*(MENU **)0); }
+
+#undef new_menu
+MENU *new_menu(
+ ITEM **items)
+ { return(*(MENU **)0); }
+
+#undef free_menu
+int free_menu(
+ MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_opts.c */
+
+#undef set_menu_opts
+int set_menu_opts(
+ MENU *menu,
+ Menu_Options opts)
+ { return(*(int *)0); }
+
+#undef menu_opts_off
+int menu_opts_off(
+ MENU *menu,
+ Menu_Options opts)
+ { return(*(int *)0); }
+
+#undef menu_opts_on
+int menu_opts_on(
+ MENU *menu,
+ Menu_Options opts)
+ { return(*(int *)0); }
+
+#undef menu_opts
+Menu_Options menu_opts(
+ const MENU *menu)
+ { return(*(Menu_Options *)0); }
+
+/* ./m_pad.c */
+
+#undef set_menu_pad
+int set_menu_pad(
+ MENU *menu,
+ int pad)
+ { return(*(int *)0); }
+
+#undef menu_pad
+int menu_pad(
+ const MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_pattern.c */
+
+#undef menu_pattern
+char *menu_pattern(
+ const MENU *menu)
+ { return(*(char **)0); }
+
+#undef set_menu_pattern
+int set_menu_pattern(
+ MENU *menu,
+ const char *p)
+ { return(*(int *)0); }
+
+/* ./m_post.c */
+
+#undef _nc_Post_Item
+void _nc_Post_Item(
+ const MENU *menu,
+ const ITEM *item)
+ { /* void */ }
+
+#undef _nc_Draw_Menu
+void _nc_Draw_Menu(
+ const MENU *menu)
+ { /* void */ }
+
+#undef post_menu
+int post_menu(
+ MENU *menu)
+ { return(*(int *)0); }
+
+#undef unpost_menu
+int unpost_menu(
+ MENU *menu)
+ { return(*(int *)0); }
+
+/* ./m_req_name.c */
+
+#undef menu_request_name
+const char *menu_request_name(
+ int request)
+ { return(*(const char **)0); }
+
+#undef menu_request_by_name
+int menu_request_by_name(
+ const char *str)
+ { return(*(int *)0); }
+
+/* ./m_scale.c */
+
+#undef scale_menu
+int scale_menu(
+ const MENU *menu,
+ int *rows,
+ int *cols)
+ { return(*(int *)0); }
+
+/* ./m_spacing.c */
+
+#undef set_menu_spacing
+int set_menu_spacing(
+ MENU *menu,
+ int s_desc,
+ int s_row,
+ int s_col)
+ { return(*(int *)0); }
+
+#undef menu_spacing
+int menu_spacing(
+ const MENU *menu,
+ int *s_desc,
+ int *s_row,
+ int *s_col)
+ { return(*(int *)0); }
+
+/* ./m_sub.c */
+
+#undef set_menu_sub
+int set_menu_sub(
+ MENU *menu,
+ WINDOW *win)
+ { return(*(int *)0); }
+
+#undef menu_sub
+WINDOW *menu_sub(
+ const MENU *menu)
+ { return(*(WINDOW **)0); }
+
+/* ./m_trace.c */
+
+#undef _nc_retrace_item
+ITEM *_nc_retrace_item(
+ ITEM *code)
+ { return(*(ITEM **)0); }
+
+#undef _nc_retrace_item_ptr
+ITEM **_nc_retrace_item_ptr(
+ ITEM **code)
+ { return(*(ITEM ***)0); }
+
+#undef _nc_retrace_item_opts
+Item_Options _nc_retrace_item_opts(
+ Item_Options code)
+ { return(*(Item_Options *)0); }
+
+#undef _nc_retrace_menu
+MENU *_nc_retrace_menu(
+ MENU *code)
+ { return(*(MENU **)0); }
+
+#undef _nc_retrace_menu_hook
+Menu_Hook _nc_retrace_menu_hook(
+ Menu_Hook code)
+ { return(*(Menu_Hook *)0); }
+
+#undef _nc_retrace_menu_opts
+Menu_Options _nc_retrace_menu_opts(
+ Menu_Options code)
+ { return(*(Menu_Options *)0); }
+
+/* ./m_userptr.c */
+
+#undef set_menu_userptr
+int set_menu_userptr(
+ MENU *menu,
+ void *userptr)
+ { return(*(int *)0); }
+
+#undef menu_userptr
+void *menu_userptr(
+ const MENU *menu)
+ { return(*(void **)0); }
+
+/* ./m_win.c */
+
+#undef set_menu_win
+int set_menu_win(
+ MENU *menu,
+ WINDOW *win)
+ { return(*(int *)0); }
+
+#undef menu_win
+WINDOW *menu_win(
+ const MENU *menu)
+ { return(*(WINDOW **)0); }
diff --git a/payloads/libpayload/curses/menu/m_attribs.c b/payloads/libpayload/curses/menu/m_attribs.c
new file mode 100644
index 0000000000..c41d558ec9
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_attribs.c
@@ -0,0 +1,144 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_attribs *
+* Control menus display attributes *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_attribs.c,v 1.16 2010/01/23 21:16:54 tom Exp $")
+
+/* Macro to redraw menu if it is posted and changed */
+#define Refresh_Menu(menu) \
+ if ( (menu) && ((menu)->status & _POSTED) )\
+ {\
+ _nc_Draw_Menu( menu );\
+ _nc_Show_Menu( menu );\
+ }
+
+/* "Template" macro to generate a function to set a menus attribute */
+#define GEN_MENU_ATTR_SET_FCT( name ) \
+NCURSES_IMPEXP int NCURSES_API set_menu_ ## name (MENU* menu, chtype attr) \
+{\
+ T((T_CALLED("set_menu_" #name "(%p,%s)"), menu, _traceattr(attr))); \
+ if (!(attr==A_NORMAL || (attr & A_ATTRIBUTES)==attr))\
+ RETURN(E_BAD_ARGUMENT);\
+ if (menu && ( menu -> name != attr))\
+ {\
+ (menu -> name) = attr;\
+ Refresh_Menu(menu);\
+ }\
+ Normalize_Menu( menu ) -> name = attr;\
+ RETURN(E_OK);\
+}
+
+/* "Template" macro to generate a function to get a menu's attribute */
+#define GEN_MENU_ATTR_GET_FCT( name ) \
+NCURSES_IMPEXP chtype NCURSES_API menu_ ## name (const MENU * menu)\
+{\
+ T((T_CALLED("menu_" #name "(%p)"), (const void *) menu));\
+ returnAttr(Normalize_Menu( menu ) -> name);\
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_fore(MENU *menu, chtype attr)
+|
+| Description : Set the attribute for selectable items. In single-
+| valued menus this is used to highlight the current
+| item ((i.e. where the cursor is), in multi-valued
+| menus this is used to highlight the selected items.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - an invalid value has been passed
++--------------------------------------------------------------------------*/
+GEN_MENU_ATTR_SET_FCT(fore)
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : chtype menu_fore(const MENU* menu)
+|
+| Description : Return the attribute used for selectable items that
+| are current (single-valued menu) or selected (multi-
+| valued menu).
+|
+| Return Values : Attribute value
++--------------------------------------------------------------------------*/
+GEN_MENU_ATTR_GET_FCT(fore)
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_back(MENU *menu, chtype attr)
+|
+| Description : Set the attribute for selectable but not yet selected
+| items.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - an invalid value has been passed
++--------------------------------------------------------------------------*/
+GEN_MENU_ATTR_SET_FCT(back)
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : chtype menu_back(const MENU *menu)
+|
+| Description : Return the attribute used for selectable but not yet
+| selected items.
+|
+| Return Values : Attribute value
++--------------------------------------------------------------------------*/
+GEN_MENU_ATTR_GET_FCT(back)
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_grey(MENU *menu, chtype attr)
+|
+| Description : Set the attribute for unselectable items.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - an invalid value has been passed
++--------------------------------------------------------------------------*/
+GEN_MENU_ATTR_SET_FCT(grey)
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : chtype menu_grey(const MENU *menu)
+|
+| Description : Return the attribute used for non-selectable items
+|
+| Return Values : Attribute value
++--------------------------------------------------------------------------*/
+GEN_MENU_ATTR_GET_FCT(grey)
+
+/* m_attribs.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_cursor.c b/payloads/libpayload/curses/menu/m_cursor.c
new file mode 100644
index 0000000000..9891de4a94
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_cursor.c
@@ -0,0 +1,112 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_cursor *
+* Correctly position a menu's cursor *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_cursor.c,v 1.22 2010/01/23 21:20:10 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : _nc_menu_cursor_pos
+|
+| Description : Return position of logical cursor to current item
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid menu
+| E_NOT_POSTED - Menu is not posted
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+_nc_menu_cursor_pos(const MENU * menu, const ITEM * item, int *pY, int *pX)
+{
+ if (!menu || !pX || !pY)
+ return (E_BAD_ARGUMENT);
+ else
+ {
+ if ((ITEM *) 0 == item)
+ item = menu->curitem;
+ assert(item != (ITEM *) 0);
+
+ if (!(menu->status & _POSTED))
+ return (E_NOT_POSTED);
+
+ *pX = item->x * (menu->spc_cols + menu->itemlen);
+ *pY = (item->y - menu->toprow) * menu->spc_rows;
+ }
+ return (E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : pos_menu_cursor
+|
+| Description : Position logical cursor to current item in menu
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid menu
+| E_NOT_POSTED - Menu is not posted
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+pos_menu_cursor(const MENU * menu)
+{
+ WINDOW *win, *sub;
+ int x = 0, y = 0;
+ int err = _nc_menu_cursor_pos(menu, (ITEM *) 0, &y, &x);
+
+ T((T_CALLED("pos_menu_cursor(%p)"), (const void *)menu));
+
+ if (E_OK == err)
+ {
+ win = Get_Menu_UserWin(menu);
+ sub = menu->usersub ? menu->usersub : win;
+ assert(win && sub);
+
+ if ((menu->opt & O_SHOWMATCH) && (menu->pindex > 0))
+ x += (menu->pindex + menu->marklen - 1);
+
+ wmove(sub, y, x);
+
+ if (win != sub)
+ {
+ wcursyncup(sub);
+ wsyncup(sub);
+ untouchwin(sub);
+ }
+ }
+ RETURN(err);
+}
+
+/* m_cursor.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_driver.c b/payloads/libpayload/curses/menu/m_driver.c
new file mode 100644
index 0000000000..deeff4710c
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_driver.c
@@ -0,0 +1,556 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_driver *
+* Central dispatching routine *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_driver.c,v 1.29 2010/01/23 21:20:10 tom Exp $")
+
+/* Macros */
+
+/* Remove the last character from the match pattern buffer */
+#define Remove_Character_From_Pattern(menu) \
+ (menu)->pattern[--((menu)->pindex)] = '\0'
+
+/* Add a new character to the match pattern buffer */
+#define Add_Character_To_Pattern(menu,ch) \
+ { (menu)->pattern[((menu)->pindex)++] = (ch);\
+ (menu)->pattern[(menu)->pindex] = '\0'; }
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : static bool Is_Sub_String(
+| bool IgnoreCaseFlag,
+| const char *part,
+| const char *string)
+|
+| Description : Checks whether or not part is a substring of string.
+|
+| Return Values : TRUE - if it is a substring
+| FALSE - if it is not a substring
++--------------------------------------------------------------------------*/
+static bool
+Is_Sub_String(
+ bool IgnoreCaseFlag,
+ const char *part,
+ const char *string
+)
+{
+ assert(part && string);
+ if (IgnoreCaseFlag)
+ {
+ while (*string && *part)
+ {
+ if (toupper(UChar(*string++)) != toupper(UChar(*part)))
+ break;
+ part++;
+ }
+ }
+ else
+ {
+ while (*string && *part)
+ if (*part != *string++)
+ break;
+ part++;
+ }
+ return ((*part) ? FALSE : TRUE);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int _nc_Match_Next_Character_In_Item_Name(
+| MENU *menu,
+| int ch,
+| ITEM **item)
+|
+| Description : This internal routine is called for a menu positioned
+| at an item with three different classes of characters:
+| - a printable character; the character is added to
+| the current pattern and the next item matching
+| this pattern is searched.
+| - NUL; the pattern stays as it is and the next item
+| matching the pattern is searched
+| - BS; the pattern stays as it is and the previous
+| item matching the pattern is searched
+|
+| The item parameter contains on call a pointer to
+| the item where the search starts. On return - if
+| a match was found - it contains a pointer to the
+| matching item.
+|
+| Return Values : E_OK - an item matching the pattern was found
+| E_NO_MATCH - nothing found
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+_nc_Match_Next_Character_In_Item_Name
+(MENU * menu, int ch, ITEM ** item)
+{
+ bool found = FALSE, passed = FALSE;
+ int idx, last;
+
+ T((T_CALLED("_nc_Match_Next_Character(%p,%d,%p)"),
+ (void *)menu, ch, (void *)item));
+
+ assert(menu && item && *item);
+ idx = (*item)->index;
+
+ if (ch && ch != BS)
+ {
+ /* if we become to long, we need no further checking : there can't be
+ a match ! */
+ if ((menu->pindex + 1) > menu->namelen)
+ RETURN(E_NO_MATCH);
+
+ Add_Character_To_Pattern(menu, ch);
+ /* we artificially position one item back, because in the do...while
+ loop we start with the next item. This means, that with a new
+ pattern search we always start the scan with the actual item. If
+ we do a NEXT_PATTERN oder PREV_PATTERN search, we start with the
+ one after or before the actual item. */
+ if (--idx < 0)
+ idx = menu->nitems - 1;
+ }
+
+ last = idx; /* this closes the cycle */
+
+ do
+ {
+ if (ch == BS)
+ { /* we have to go backward */
+ if (--idx < 0)
+ idx = menu->nitems - 1;
+ }
+ else
+ { /* otherwise we always go forward */
+ if (++idx >= menu->nitems)
+ idx = 0;
+ }
+ if (Is_Sub_String((bool)((menu->opt & O_IGNORECASE) != 0),
+ menu->pattern,
+ menu->items[idx]->name.str)
+ )
+ found = TRUE;
+ else
+ passed = TRUE;
+ }
+ while (!found && (idx != last));
+
+ if (found)
+ {
+ if (!((idx == (*item)->index) && passed))
+ {
+ *item = menu->items[idx];
+ RETURN(E_OK);
+ }
+ /* This point is reached, if we fully cycled through the item list
+ and the only match we found is the starting item. With a NEXT_PATTERN
+ or PREV_PATTERN scan this means, that there was no additional match.
+ If we searched with an expanded new pattern, we should never reach
+ this point, because if the expanded pattern matches also the actual
+ item we will find it in the first attempt (passed==FALSE) and we
+ will never cycle through the whole item array.
+ */
+ assert(ch == 0 || ch == BS);
+ }
+ else
+ {
+ if (ch && ch != BS && menu->pindex > 0)
+ {
+ /* if we had no match with a new pattern, we have to restore it */
+ Remove_Character_From_Pattern(menu);
+ }
+ }
+ RETURN(E_NO_MATCH);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int menu_driver(MENU* menu, int c)
+|
+| Description : Central dispatcher for the menu. Translates the logical
+| request 'c' into a menu action.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid menu pointer
+| E_BAD_STATE - menu is in user hook routine
+| E_NOT_POSTED - menu is not posted
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+menu_driver(MENU * menu, int c)
+{
+#define NAVIGATE(dir) \
+ if (!item->dir)\
+ result = E_REQUEST_DENIED;\
+ else\
+ item = item->dir
+
+ int result = E_OK;
+ ITEM *item;
+ int my_top_row, rdiff;
+
+ T((T_CALLED("menu_driver(%p,%d)"), (void *)menu, c));
+
+ if (!menu)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (menu->status & _IN_DRIVER)
+ RETURN(E_BAD_STATE);
+ if (!(menu->status & _POSTED))
+ RETURN(E_NOT_POSTED);
+
+ item = menu->curitem;
+
+ my_top_row = menu->toprow;
+ assert(item);
+
+ if ((c > KEY_MAX) && (c <= MAX_MENU_COMMAND))
+ {
+ if (!((c == REQ_BACK_PATTERN)
+ || (c == REQ_NEXT_MATCH) || (c == REQ_PREV_MATCH)))
+ {
+ assert(menu->pattern);
+ Reset_Pattern(menu);
+ }
+
+ switch (c)
+ {
+ case REQ_LEFT_ITEM:
+ /*=================*/
+ NAVIGATE(left);
+ break;
+
+ case REQ_RIGHT_ITEM:
+ /*==================*/
+ NAVIGATE(right);
+ break;
+
+ case REQ_UP_ITEM:
+ /*===============*/
+ NAVIGATE(up);
+ break;
+
+ case REQ_DOWN_ITEM:
+ /*=================*/
+ NAVIGATE(down);
+ break;
+
+ case REQ_SCR_ULINE:
+ /*=================*/
+ if (my_top_row == 0 || !(item->up))
+ result = E_REQUEST_DENIED;
+ else
+ {
+ --my_top_row;
+ item = item->up;
+ }
+ break;
+
+ case REQ_SCR_DLINE:
+ /*=================*/
+ if ((my_top_row + menu->arows >= menu->rows) || !(item->down))
+ {
+ /* only if the menu has less items than rows, we can deny the
+ request. Otherwise the epilogue of this routine adjusts the
+ top row if necessary */
+ result = E_REQUEST_DENIED;
+ }
+ else
+ {
+ my_top_row++;
+ item = item->down;
+ }
+ break;
+
+ case REQ_SCR_DPAGE:
+ /*=================*/
+ rdiff = menu->rows - (menu->arows + my_top_row);
+ if (rdiff > menu->arows)
+ rdiff = menu->arows;
+ if (rdiff <= 0)
+ result = E_REQUEST_DENIED;
+ else
+ {
+ my_top_row += rdiff;
+ while (rdiff-- > 0 && item != 0 && item->down != 0)
+ item = item->down;
+ }
+ break;
+
+ case REQ_SCR_UPAGE:
+ /*=================*/
+ rdiff = (menu->arows < my_top_row) ? menu->arows : my_top_row;
+ if (rdiff <= 0)
+ result = E_REQUEST_DENIED;
+ else
+ {
+ my_top_row -= rdiff;
+ while (rdiff-- > 0 && item != 0 && item->up != 0)
+ item = item->up;
+ }
+ break;
+
+ case REQ_FIRST_ITEM:
+ /*==================*/
+ item = menu->items[0];
+ break;
+
+ case REQ_LAST_ITEM:
+ /*=================*/
+ item = menu->items[menu->nitems - 1];
+ break;
+
+ case REQ_NEXT_ITEM:
+ /*=================*/
+ if ((item->index + 1) >= menu->nitems)
+ {
+ if (menu->opt & O_NONCYCLIC)
+ result = E_REQUEST_DENIED;
+ else
+ item = menu->items[0];
+ }
+ else
+ item = menu->items[item->index + 1];
+ break;
+
+ case REQ_PREV_ITEM:
+ /*=================*/
+ if (item->index <= 0)
+ {
+ if (menu->opt & O_NONCYCLIC)
+ result = E_REQUEST_DENIED;
+ else
+ item = menu->items[menu->nitems - 1];
+ }
+ else
+ item = menu->items[item->index - 1];
+ break;
+
+ case REQ_TOGGLE_ITEM:
+ /*===================*/
+ if (menu->opt & O_ONEVALUE)
+ {
+ result = E_REQUEST_DENIED;
+ }
+ else
+ {
+ if (menu->curitem->opt & O_SELECTABLE)
+ {
+ menu->curitem->value = !menu->curitem->value;
+ Move_And_Post_Item(menu, menu->curitem);
+ _nc_Show_Menu(menu);
+ }
+ else
+ result = E_NOT_SELECTABLE;
+ }
+ break;
+
+ case REQ_CLEAR_PATTERN:
+ /*=====================*/
+ /* already cleared in prologue */
+ break;
+
+ case REQ_BACK_PATTERN:
+ /*====================*/
+ if (menu->pindex > 0)
+ {
+ assert(menu->pattern);
+ Remove_Character_From_Pattern(menu);
+ pos_menu_cursor(menu);
+ }
+ else
+ result = E_REQUEST_DENIED;
+ break;
+
+ case REQ_NEXT_MATCH:
+ /*==================*/
+ assert(menu->pattern);
+ if (menu->pattern[0])
+ result = _nc_Match_Next_Character_In_Item_Name(menu, 0, &item);
+ else
+ {
+ if ((item->index + 1) < menu->nitems)
+ item = menu->items[item->index + 1];
+ else
+ {
+ if (menu->opt & O_NONCYCLIC)
+ result = E_REQUEST_DENIED;
+ else
+ item = menu->items[0];
+ }
+ }
+ break;
+
+ case REQ_PREV_MATCH:
+ /*==================*/
+ assert(menu->pattern);
+ if (menu->pattern[0])
+ result = _nc_Match_Next_Character_In_Item_Name(menu, BS, &item);
+ else
+ {
+ if (item->index)
+ item = menu->items[item->index - 1];
+ else
+ {
+ if (menu->opt & O_NONCYCLIC)
+ result = E_REQUEST_DENIED;
+ else
+ item = menu->items[menu->nitems - 1];
+ }
+ }
+ break;
+
+ default:
+ /*======*/
+ result = E_UNKNOWN_COMMAND;
+ break;
+ }
+ }
+ else
+ { /* not a command */
+ if (!(c & ~((int)MAX_REGULAR_CHARACTER)) && isprint(UChar(c)))
+ result = _nc_Match_Next_Character_In_Item_Name(menu, c, &item);
+#ifdef NCURSES_MOUSE_VERSION
+ else if (KEY_MOUSE == c)
+ {
+ MEVENT event;
+ WINDOW *uwin = Get_Menu_UserWin(menu);
+
+ getmouse(&event);
+ if ((event.bstate & (BUTTON1_CLICKED |
+ BUTTON1_DOUBLE_CLICKED |
+ BUTTON1_TRIPLE_CLICKED))
+ && wenclose(uwin, event.y, event.x))
+ { /* we react only if the click was in the userwin, that means
+ * inside the menu display area or at the decoration window.
+ */
+ WINDOW *sub = Get_Menu_Window(menu);
+ int ry = event.y, rx = event.x; /* screen coordinates */
+
+ result = E_REQUEST_DENIED;
+ if (mouse_trafo(&ry, &rx, FALSE))
+ { /* rx, ry are now "curses" coordinates */
+ if (ry < sub->_begy)
+ { /* we clicked above the display region; this is
+ * interpreted as "scroll up" request
+ */
+ if (event.bstate & BUTTON1_CLICKED)
+ result = menu_driver(menu, REQ_SCR_ULINE);
+ else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ result = menu_driver(menu, REQ_SCR_UPAGE);
+ else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+ result = menu_driver(menu, REQ_FIRST_ITEM);
+ RETURN(result);
+ }
+ else if (ry > sub->_begy + sub->_maxy)
+ { /* we clicked below the display region; this is
+ * interpreted as "scroll down" request
+ */
+ if (event.bstate & BUTTON1_CLICKED)
+ result = menu_driver(menu, REQ_SCR_DLINE);
+ else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ result = menu_driver(menu, REQ_SCR_DPAGE);
+ else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+ result = menu_driver(menu, REQ_LAST_ITEM);
+ RETURN(result);
+ }
+ else if (wenclose(sub, event.y, event.x))
+ { /* Inside the area we try to find the hit item */
+ int i, x, y, err;
+
+ ry = event.y;
+ rx = event.x;
+ if (wmouse_trafo(sub, &ry, &rx, FALSE))
+ {
+ for (i = 0; i < menu->nitems; i++)
+ {
+ err = _nc_menu_cursor_pos(menu, menu->items[i],
+ &y, &x);
+ if (E_OK == err)
+ {
+ if ((ry == y) &&
+ (rx >= x) &&
+ (rx < x + menu->itemlen))
+ {
+ item = menu->items[i];
+ result = E_OK;
+ break;
+ }
+ }
+ }
+ if (E_OK == result)
+ { /* We found an item, now we can handle the click.
+ * A single click just positions the menu cursor
+ * to the clicked item. A double click toggles
+ * the item.
+ */
+ if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ {
+ _nc_New_TopRow_and_CurrentItem(menu,
+ my_top_row,
+ item);
+ menu_driver(menu, REQ_TOGGLE_ITEM);
+ result = E_UNKNOWN_COMMAND;
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ result = E_REQUEST_DENIED;
+ }
+#endif /* NCURSES_MOUSE_VERSION */
+ else
+ result = E_UNKNOWN_COMMAND;
+ }
+
+ if (E_OK == result)
+ {
+ /* Adjust the top row if it turns out that the current item unfortunately
+ doesn't appear in the menu window */
+ if (item->y < my_top_row)
+ my_top_row = item->y;
+ else if (item->y >= (my_top_row + menu->arows))
+ my_top_row = item->y - menu->arows + 1;
+
+ _nc_New_TopRow_and_CurrentItem(menu, my_top_row, item);
+
+ }
+
+ RETURN(result);
+}
+
+/* m_driver.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_format.c b/payloads/libpayload/curses/menu/m_format.c
new file mode 100644
index 0000000000..8e68a036ee
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_format.c
@@ -0,0 +1,131 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_format *
+* Set and get maximum numbers of rows and columns in menus *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_format.c,v 1.16 2010/01/23 21:20:10 tom Exp $")
+
+#define minimum(a,b) ((a)<(b) ? (a): (b))
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_format(MENU *menu, int rows, int cols)
+|
+| Description : Sets the maximum number of rows and columns of items
+| that may be displayed at one time on a menu. If the
+| menu contains more items than can be displayed at
+| once, the menu will be scrollable.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid values passed
+| E_NOT_CONNECTED - there are no items connected
+| E_POSTED - the menu is already posted
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_menu_format(MENU * menu, int rows, int cols)
+{
+ int total_rows, total_cols;
+
+ T((T_CALLED("set_menu_format(%p,%d,%d)"), (void *)menu, rows, cols));
+
+ if (rows < 0 || cols < 0)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (menu)
+ {
+ if (menu->status & _POSTED)
+ RETURN(E_POSTED);
+
+ if (!(menu->items))
+ RETURN(E_NOT_CONNECTED);
+
+ if (rows == 0)
+ rows = menu->frows;
+ if (cols == 0)
+ cols = menu->fcols;
+
+ if (menu->pattern)
+ Reset_Pattern(menu);
+
+ menu->frows = rows;
+ menu->fcols = cols;
+
+ assert(rows > 0 && cols > 0);
+ total_rows = (menu->nitems - 1) / cols + 1;
+ total_cols = (menu->opt & O_ROWMAJOR) ?
+ minimum(menu->nitems, cols) :
+ (menu->nitems - 1) / total_rows + 1;
+
+ menu->rows = total_rows;
+ menu->cols = total_cols;
+ menu->arows = minimum(total_rows, rows);
+ menu->toprow = 0;
+ menu->curitem = *(menu->items);
+ assert(menu->curitem);
+ menu->status |= _LINK_NEEDED;
+ _nc_Calculate_Item_Length_and_Width(menu);
+ }
+ else
+ {
+ if (rows > 0)
+ _nc_Default_Menu.frows = rows;
+ if (cols > 0)
+ _nc_Default_Menu.fcols = cols;
+ }
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void menu_format(const MENU *menu, int *rows, int *cols)
+|
+| Description : Returns the maximum number of rows and columns that may
+| be displayed at one time on menu.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(void)
+menu_format(const MENU * menu, int *rows, int *cols)
+{
+ if (rows)
+ *rows = Normalize_Menu(menu)->frows;
+ if (cols)
+ *cols = Normalize_Menu(menu)->fcols;
+}
+
+/* m_format.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_global.c b/payloads/libpayload/curses/menu/m_global.c
new file mode 100644
index 0000000000..90f6f25925
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_global.c
@@ -0,0 +1,598 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_global *
+* Globally used internal routines and the default menu and item structures *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_global.c,v 1.25 2010/01/23 21:20:10 tom Exp $")
+
+static char mark[] = "-";
+/* *INDENT-OFF* */
+NCURSES_EXPORT_VAR(MENU) _nc_Default_Menu = {
+ 16, /* Nr. of chars high */
+ 1, /* Nr. of chars wide */
+ 16, /* Nr. of items high */
+ 1, /* Nr. of items wide */
+ 16, /* Nr. of formatted items high */
+ 1, /* Nr. of formatted items wide */
+ 16, /* Nr. of items high (actual) */
+ 0, /* length of widest name */
+ 0, /* length of widest description */
+ 1, /* length of mark */
+ 1, /* length of one item */
+ 1, /* Spacing for descriptor */
+ 1, /* Spacing for columns */
+ 1, /* Spacing for rows */
+ (char *)0, /* buffer used to store match chars */
+ 0, /* Index into pattern buffer */
+ (WINDOW *)0, /* Window containing entire menu */
+ (WINDOW *)0, /* Portion of menu displayed */
+ (WINDOW *)0, /* User's window */
+ (WINDOW *)0, /* User's subwindow */
+ (ITEM **)0, /* List of items */
+ 0, /* Total Nr. of items in menu */
+ (ITEM *)0, /* Current item */
+ 0, /* Top row of menu */
+ (chtype)A_REVERSE, /* Attribute for selection */
+ (chtype)A_NORMAL, /* Attribute for nonselection */
+ (chtype)A_UNDERLINE, /* Attribute for inactive */
+ ' ', /* Pad character */
+ (Menu_Hook)0, /* Menu init */
+ (Menu_Hook)0, /* Menu term */
+ (Menu_Hook)0, /* Item init */
+ (Menu_Hook)0, /* Item term */
+ (void *)0, /* userptr */
+ mark, /* mark */
+ ALL_MENU_OPTS, /* options */
+ 0 /* status */
+};
+
+NCURSES_EXPORT_VAR(ITEM) _nc_Default_Item = {
+ { (char *)0, 0 }, /* name */
+ { (char *)0, 0 }, /* description */
+ (MENU *)0, /* Pointer to parent menu */
+ (char *)0, /* Userpointer */
+ ALL_ITEM_OPTS, /* options */
+ 0, /* Item Nr. */
+ 0, /* y */
+ 0, /* x */
+ FALSE, /* value */
+ (ITEM *)0, /* left */
+ (ITEM *)0, /* right */
+ (ITEM *)0, /* up */
+ (ITEM *)0 /* down */
+ };
+/* *INDENT-ON* */
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : static void ComputeMaximum_NameDesc_Lenths(MENU *menu)
+|
+| Description : Calculates the maximum name and description lengths
+| of the items connected to the menu
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static void
+ComputeMaximum_NameDesc_Lengths(MENU * menu)
+{
+ unsigned MaximumNameLength = 0;
+ unsigned MaximumDescriptionLength = 0;
+ ITEM **items;
+ unsigned check;
+
+ assert(menu && menu->items);
+ for (items = menu->items; *items; items++)
+ {
+ check = _nc_Calculate_Text_Width(&((*items)->name));
+ if (check > MaximumNameLength)
+ MaximumNameLength = check;
+
+ check = _nc_Calculate_Text_Width(&((*items)->description));
+ if (check > MaximumDescriptionLength)
+ MaximumDescriptionLength = check;
+ }
+
+ menu->namelen = MaximumNameLength;
+ menu->desclen = MaximumDescriptionLength;
+ T(("ComputeMaximum_NameDesc_Lengths %d,%d", menu->namelen, menu->desclen));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : static void ResetConnectionInfo(MENU *, ITEM **)
+|
+| Description : Reset all informations in the menu and the items in
+| the item array that indicates a connection
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+NCURSES_INLINE static void
+ResetConnectionInfo(MENU * menu, ITEM ** items)
+{
+ ITEM **item;
+
+ assert(menu && items);
+ for (item = items; *item; item++)
+ {
+ (*item)->index = 0;
+ (*item)->imenu = (MENU *) 0;
+ }
+ if (menu->pattern)
+ free(menu->pattern);
+ menu->pattern = (char *)0;
+ menu->pindex = 0;
+ menu->items = (ITEM **) 0;
+ menu->nitems = 0;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : bool _nc_Connect_Items(MENU *menu, ITEM **items)
+|
+| Description : Connect the items in the item array to the menu.
+| Decorate all the items with a number and a backward
+| pointer to the menu.
+|
+| Return Values : TRUE - successful connection
+| FALSE - connection failed
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(bool)
+_nc_Connect_Items(MENU * menu, ITEM ** items)
+{
+ ITEM **item;
+ unsigned int ItemCount = 0;
+
+ if (menu && items)
+ {
+ for (item = items; *item; item++)
+ {
+ if ((*item)->imenu)
+ {
+ /* if a item is already connected, reject connection */
+ break;
+ }
+ }
+ if (!(*item))
+ /* we reached the end, so there was no connected item */
+ {
+ for (item = items; *item; item++)
+ {
+ if (menu->opt & O_ONEVALUE)
+ {
+ (*item)->value = FALSE;
+ }
+ (*item)->index = ItemCount++;
+ (*item)->imenu = menu;
+ }
+ }
+ }
+ else
+ return (FALSE);
+
+ if (ItemCount != 0)
+ {
+ menu->items = items;
+ menu->nitems = ItemCount;
+ ComputeMaximum_NameDesc_Lengths(menu);
+ if ((menu->pattern = typeMalloc(char, (unsigned)(1 + menu->namelen))))
+ {
+ Reset_Pattern(menu);
+ set_menu_format(menu, menu->frows, menu->fcols);
+ menu->curitem = *items;
+ menu->toprow = 0;
+ return (TRUE);
+ }
+ }
+
+ /* If we fall through to this point, we have to reset all items connection
+ and inform about a reject connection */
+ ResetConnectionInfo(menu, items);
+ return (FALSE);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void _nc_Disconnect_Items(MENU *menu)
+|
+| Description : Disconnect the menus item array from the menu
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(void)
+_nc_Disconnect_Items(MENU * menu)
+{
+ if (menu && menu->items)
+ ResetConnectionInfo(menu, menu->items);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int _nc_Calculate_Text_Width(const TEXT * item)
+|
+| Description : Calculate the number of columns for a TEXT.
+|
+| Return Values : the width
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+_nc_Calculate_Text_Width(const TEXT * item /*FIXME: limit length */ )
+{
+#if USE_WIDEC_SUPPORT
+ int result = item->length;
+
+ T((T_CALLED("_nc_menu_text_width(%p)"), (const void *)item));
+ if (result != 0 && item->str != 0)
+ {
+ int count = mbstowcs(0, item->str, 0);
+ wchar_t *temp = 0;
+
+ if (count > 0
+ && (temp = typeMalloc(wchar_t, 2 + count)) != 0)
+ {
+ int n;
+
+ result = 0;
+ mbstowcs(temp, item->str, (unsigned)count);
+ for (n = 0; n < count; ++n)
+ {
+ int test = wcwidth(temp[n]);
+
+ if (test <= 0)
+ test = 1;
+ result += test;
+ }
+ free(temp);
+ }
+ }
+ returnCode(result);
+#else
+ return item->length;
+#endif
+}
+
+/*
+ * Calculate the actual width of a menu entry for wide-characters.
+ */
+#if USE_WIDEC_SUPPORT
+static int
+calculate_actual_width(MENU * menu, bool name)
+{
+ int width = 0;
+ int check = 0;
+ ITEM **items;
+
+ assert(menu && menu->items);
+
+ if (menu->items != 0)
+ {
+ for (items = menu->items; *items; items++)
+ {
+ if (name)
+ {
+ check = _nc_Calculate_Text_Width(&((*items)->name));
+ }
+ else
+ {
+ check = _nc_Calculate_Text_Width(&((*items)->description));
+ }
+ if (check > width)
+ width = check;
+ }
+ }
+ else
+ {
+ width = (name ? menu->namelen : menu->desclen);
+ }
+
+ T(("calculate_actual_width %s = %d/%d",
+ name ? "name" : "desc",
+ width,
+ name ? menu->namelen : menu->desclen));
+ return width;
+}
+#else
+#define calculate_actual_width(menu, name) (name ? menu->namelen : menu->desclen)
+#endif
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void _nc_Calculate_Item_Length_and_Width(MENU *menu)
+|
+| Description : Calculate the length of an item and the width of the
+| whole menu.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(void)
+_nc_Calculate_Item_Length_and_Width(MENU * menu)
+{
+ int l;
+
+ assert(menu);
+
+ menu->height = 1 + menu->spc_rows * (menu->arows - 1);
+
+ l = calculate_actual_width(menu, TRUE);
+ l += menu->marklen;
+
+ if ((menu->opt & O_SHOWDESC) && (menu->desclen > 0))
+ {
+ l += calculate_actual_width(menu, FALSE);
+ l += menu->spc_desc;
+ }
+
+ menu->itemlen = l;
+ l *= menu->cols;
+ l += (menu->cols - 1) * menu->spc_cols; /* for the padding between the columns */
+ menu->width = l;
+
+ T(("_nc_CalculateItem_Length_and_Width columns %d, item %d, width %d",
+ menu->cols,
+ menu->itemlen,
+ menu->width));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void _nc_Link_Item(MENU *menu)
+|
+| Description : Statically calculate for every item its four neighbors.
+| This depends on the orientation of the menu. This
+| static approach simplifies navigation in the menu a lot.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(void)
+_nc_Link_Items(MENU * menu)
+{
+ if (menu && menu->items && *(menu->items))
+ {
+ int i, j;
+ ITEM *item;
+ int Number_Of_Items = menu->nitems;
+ int col = 0, row = 0;
+ int Last_in_Row;
+ int Last_in_Column;
+ bool cycle = (menu->opt & O_NONCYCLIC) ? FALSE : TRUE;
+
+ menu->status &= ~_LINK_NEEDED;
+
+ if (menu->opt & O_ROWMAJOR)
+ {
+ int Number_Of_Columns = menu->cols;
+
+ for (i = 0; i < Number_Of_Items; i++)
+ {
+ item = menu->items[i];
+
+ Last_in_Row = row * Number_Of_Columns + (Number_Of_Columns - 1);
+
+ item->left = (col) ?
+ /* if we are not in the leftmost column, we can use the
+ predecessor in the items array */
+ menu->items[i - 1] :
+ (cycle ? menu->items[(Last_in_Row >= Number_Of_Items) ?
+ Number_Of_Items - 1 :
+ Last_in_Row] :
+ (ITEM *) 0);
+
+ item->right = ((col < (Number_Of_Columns - 1)) &&
+ ((i + 1) < Number_Of_Items)
+ )?
+ menu->items[i + 1] :
+ (cycle ? menu->items[row * Number_Of_Columns] :
+ (ITEM *) 0
+ );
+
+ Last_in_Column = (menu->rows - 1) * Number_Of_Columns + col;
+
+ item->up = (row) ? menu->items[i - Number_Of_Columns] :
+ (cycle ? menu->items[(Last_in_Column >= Number_Of_Items) ?
+ Number_Of_Items - 1 :
+ Last_in_Column] :
+ (ITEM *) 0);
+
+ item->down = ((i + Number_Of_Columns) < Number_Of_Items)
+ ?
+ menu->items[i + Number_Of_Columns] :
+ (cycle ? menu->items[(row + 1) < menu->rows ?
+ Number_Of_Items - 1 : col] :
+ (ITEM *) 0);
+ item->x = col;
+ item->y = row;
+ if (++col == Number_Of_Columns)
+ {
+ row++;
+ col = 0;
+ }
+ }
+ }
+ else
+ {
+ int Number_Of_Rows = menu->rows;
+
+ for (j = 0; j < Number_Of_Items; j++)
+ {
+ item = menu->items[i = (col * Number_Of_Rows + row)];
+
+ Last_in_Column = (menu->cols - 1) * Number_Of_Rows + row;
+
+ item->left = (col) ?
+ menu->items[i - Number_Of_Rows] :
+ (cycle ? (Last_in_Column >= Number_Of_Items) ?
+ menu->items[Last_in_Column - Number_Of_Rows] :
+ menu->items[Last_in_Column] :
+ (ITEM *) 0);
+
+ item->right = ((i + Number_Of_Rows) < Number_Of_Items)
+ ?
+ menu->items[i + Number_Of_Rows] :
+ (cycle ? menu->items[row] : (ITEM *) 0);
+
+ Last_in_Row = col * Number_Of_Rows + (Number_Of_Rows - 1);
+
+ item->up = (row) ?
+ menu->items[i - 1] :
+ (cycle ?
+ menu->items[(Last_in_Row >= Number_Of_Items) ?
+ Number_Of_Items - 1 :
+ Last_in_Row] :
+ (ITEM *) 0);
+
+ item->down = (row < (Number_Of_Rows - 1))
+ ?
+ (menu->items[((i + 1) < Number_Of_Items) ?
+ i + 1 :
+ (col - 1) * Number_Of_Rows + row + 1]) :
+ (cycle ?
+ menu->items[col * Number_Of_Rows] :
+ (ITEM *) 0
+ );
+
+ item->x = col;
+ item->y = row;
+ if ((++row) == Number_Of_Rows)
+ {
+ col++;
+ row = 0;
+ }
+ }
+ }
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void _nc_Show_Menu(const MENU* menu)
+|
+| Description : Update the window that is associated with the menu
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(void)
+_nc_Show_Menu(const MENU * menu)
+{
+ WINDOW *win;
+ int maxy, maxx;
+
+ assert(menu);
+ if ((menu->status & _POSTED) && !(menu->status & _IN_DRIVER))
+ {
+ /* adjust the internal subwindow to start on the current top */
+ assert(menu->sub);
+ mvderwin(menu->sub, menu->spc_rows * menu->toprow, 0);
+ win = Get_Menu_Window(menu);
+
+ maxy = getmaxy(win);
+ maxx = getmaxx(win);
+
+ if (menu->height < maxy)
+ maxy = menu->height;
+ if (menu->width < maxx)
+ maxx = menu->width;
+
+ copywin(menu->sub, win, 0, 0, 0, 0, maxy - 1, maxx - 1, 0);
+ pos_menu_cursor(menu);
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void _nc_New_TopRow_and_CurrentItem(
+| MENU *menu,
+| int new_toprow,
+| ITEM *new_current_item)
+|
+| Description : Redisplay the menu so that the given row becomes the
+| top row and the given item becomes the new current
+| item.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(void)
+_nc_New_TopRow_and_CurrentItem(
+ MENU * menu,
+ int new_toprow,
+ ITEM * new_current_item)
+{
+ ITEM *cur_item;
+ bool mterm_called = FALSE;
+ bool iterm_called = FALSE;
+
+ assert(menu);
+ if (menu->status & _POSTED)
+ {
+ if (new_current_item != menu->curitem)
+ {
+ Call_Hook(menu, itemterm);
+ iterm_called = TRUE;
+ }
+ if (new_toprow != menu->toprow)
+ {
+ Call_Hook(menu, menuterm);
+ mterm_called = TRUE;
+ }
+
+ cur_item = menu->curitem;
+ assert(cur_item);
+ menu->toprow = new_toprow;
+ menu->curitem = new_current_item;
+
+ if (mterm_called)
+ {
+ Call_Hook(menu, menuinit);
+ }
+ if (iterm_called)
+ {
+ /* this means, move from the old current_item to the new one... */
+ Move_To_Current_Item(menu, cur_item);
+ Call_Hook(menu, iteminit);
+ }
+ if (mterm_called || iterm_called)
+ {
+ _nc_Show_Menu(menu);
+ }
+ else
+ pos_menu_cursor(menu);
+ }
+ else
+ { /* if we are not posted, this is quite simple */
+ menu->toprow = new_toprow;
+ menu->curitem = new_current_item;
+ }
+}
+
+/* m_global.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_hook.c b/payloads/libpayload/curses/menu/m_hook.c
new file mode 100644
index 0000000000..6125d052e7
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_hook.c
@@ -0,0 +1,151 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_hook *
+* Assign application specific routines for automatic invocation by menus *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_hook.c,v 1.15 2010/01/23 21:16:54 tom Exp $")
+
+/* "Template" macro to generate function to set application specific hook */
+#define GEN_HOOK_SET_FUNCTION( typ, name ) \
+NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (MENU *menu, Menu_Hook func )\
+{\
+ T((T_CALLED("set_" #typ "_" #name "(%p,%p)"), menu, func));\
+ (Normalize_Menu(menu) -> typ ## name = func );\
+ RETURN(E_OK);\
+}
+
+/* "Template" macro to generate function to get application specific hook */
+#define GEN_HOOK_GET_FUNCTION( typ, name ) \
+NCURSES_IMPEXP Menu_Hook NCURSES_API typ ## _ ## name ( const MENU *menu )\
+{\
+ T((T_CALLED(#typ "_" #name "(%p)"), (const void *) menu));\
+ returnMenuHook(Normalize_Menu(menu) -> typ ## name);\
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_init(MENU *menu, void (*f)(MENU *))
+|
+| Description : Set user-exit which is called when menu is posted
+| or just after the top row changes.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+GEN_HOOK_SET_FUNCTION(menu, init)
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void (*)(MENU *) menu_init(const MENU *menu)
+|
+| Description : Return address of user-exit function which is called
+| when a menu is posted or just after the top row
+| changes.
+|
+| Return Values : Menu init function address or NULL
++--------------------------------------------------------------------------*/
+GEN_HOOK_GET_FUNCTION(menu, init)
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_term (MENU *menu, void (*f)(MENU *))
+|
+| Description : Set user-exit which is called when menu is unposted
+| or just before the top row changes.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+GEN_HOOK_SET_FUNCTION(menu, term)
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void (*)(MENU *) menu_term(const MENU *menu)
+|
+| Description : Return address of user-exit function which is called
+| when a menu is unposted or just before the top row
+| changes.
+|
+| Return Values : Menu finalization function address or NULL
++--------------------------------------------------------------------------*/
+GEN_HOOK_GET_FUNCTION(menu, term)
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_item_init (MENU *menu, void (*f)(MENU *))
+|
+| Description : Set user-exit which is called when menu is posted
+| or just after the current item changes.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+GEN_HOOK_SET_FUNCTION(item, init)
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void (*)(MENU *) item_init (const MENU *menu)
+|
+| Description : Return address of user-exit function which is called
+| when a menu is posted or just after the current item
+| changes.
+|
+| Return Values : Item init function address or NULL
++--------------------------------------------------------------------------*/
+GEN_HOOK_GET_FUNCTION(item, init)
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_item_term (MENU *menu, void (*f)(MENU *))
+|
+| Description : Set user-exit which is called when menu is unposted
+| or just before the current item changes.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+GEN_HOOK_SET_FUNCTION(item, term)
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void (*)(MENU *) item_init (const MENU *menu)
+|
+| Description : Return address of user-exit function which is called
+| when a menu is unposted or just before the current item
+| changes.
+|
+| Return Values : Item finalization function address or NULL
++--------------------------------------------------------------------------*/
+GEN_HOOK_GET_FUNCTION(item, term)
+
+/* m_hook.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_item_cur.c b/payloads/libpayload/curses/menu/m_item_cur.c
new file mode 100644
index 0000000000..18b1a2726a
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_item_cur.c
@@ -0,0 +1,113 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_item_cur *
+* Set and get current menus item *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_item_cur.c,v 1.18 2010/01/23 21:20:10 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_current_item(MENU *menu, const ITEM *item)
+|
+| Description : Make the item the current item
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_current_item(MENU * menu, ITEM * item)
+{
+ T((T_CALLED("set_current_item(%p,%p)"), (void *)menu, (void *)item));
+
+ if (menu && item && (item->imenu == menu))
+ {
+ if (menu->status & _IN_DRIVER)
+ RETURN(E_BAD_STATE);
+
+ assert(menu->curitem);
+ if (item != menu->curitem)
+ {
+ if (menu->status & _LINK_NEEDED)
+ {
+ /*
+ * Items are available, but they are not linked together.
+ * So we have to link here.
+ */
+ _nc_Link_Items(menu);
+ }
+ assert(menu->pattern);
+ Reset_Pattern(menu);
+ /* adjust the window to make item visible and update the menu */
+ Adjust_Current_Item(menu, menu->toprow, item);
+ }
+ }
+ else
+ RETURN(E_BAD_ARGUMENT);
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : ITEM *current_item(const MENU *menu)
+|
+| Description : Return the menus current item
+|
+| Return Values : Item pointer or NULL if failure
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(ITEM *)
+current_item(const MENU * menu)
+{
+ T((T_CALLED("current_item(%p)"), (const void *)menu));
+ returnItem((menu && menu->items) ? menu->curitem : (ITEM *) 0);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int item_index(const ITEM *)
+|
+| Description : Return the logical index of this item.
+|
+| Return Values : The index or ERR if this is an invalid item pointer
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+item_index(const ITEM * item)
+{
+ T((T_CALLED("item_index(%p)"), (const void *)item));
+ returnCode((item && item->imenu) ? item->index : ERR);
+}
+
+/* m_item_cur.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_item_nam.c b/payloads/libpayload/curses/menu/m_item_nam.c
new file mode 100644
index 0000000000..3ed1d37668
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_item_nam.c
@@ -0,0 +1,72 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_item_nam *
+* Get menus item name and description *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_item_nam.c,v 1.15 2010/01/23 21:20:10 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : char *item_name(const ITEM *item)
+|
+| Description : Return name of menu item
+|
+| Return Values : See above; returns NULL if item is invalid
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(const char *)
+item_name(const ITEM * item)
+{
+ T((T_CALLED("item_name(%p)"), (const void *)item));
+ returnCPtr((item) ? item->name.str : (char *)0);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : char *item_description(const ITEM *item)
+|
+| Description : Returns description of item
+|
+| Return Values : See above; Returns NULL if item is invalid
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(const char *)
+item_description(const ITEM * item)
+{
+ T((T_CALLED("item_description(%p)"), (const void *)item));
+ returnCPtr((item) ? item->description.str : (char *)0);
+}
+
+/* m_item_nam.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_item_new.c b/payloads/libpayload/curses/menu/m_item_new.c
new file mode 100644
index 0000000000..1debc2b344
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_item_new.c
@@ -0,0 +1,275 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_item_new *
+* Create and destroy menu items *
+* Set and get marker string for menu *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+#if USE_WIDEC_SUPPORT
+#if HAVE_WCTYPE_H
+#include <wctype.h>
+#endif
+#endif
+
+MODULE_ID("$Id: m_item_new.c,v 1.30 2010/01/23 21:20:11 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : bool Is_Printable_String(const char *s)
+|
+| Description : Checks whether or not the string contains only printable
+| characters.
+|
+| Return Values : TRUE - if string is printable
+| FALSE - if string contains non-printable characters
++--------------------------------------------------------------------------*/
+static bool
+Is_Printable_String(const char *s)
+{
+ int result = TRUE;
+
+#if USE_WIDEC_SUPPORT
+ int count = mbstowcs(0, s, 0);
+ wchar_t *temp = 0;
+
+ assert(s);
+
+ if (count > 0
+ && (temp = typeCalloc(wchar_t, (2 + (unsigned)count))) != 0)
+ {
+ int n;
+
+ mbstowcs(temp, s, (unsigned)count);
+ for (n = 0; n < count; ++n)
+ if (!iswprint((wint_t) temp[n]))
+ {
+ result = FALSE;
+ break;
+ }
+ free(temp);
+ }
+#else
+ assert(s);
+ while (*s)
+ {
+ if (!isprint(UChar(*s)))
+ {
+ result = FALSE;
+ break;
+ }
+ s++;
+ }
+#endif
+ return result;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : ITEM *new_item(char *name, char *description)
+|
+| Description : Create a new item with name and description. Return
+| a pointer to this new item.
+| N.B.: an item must(!) have a name.
+|
+| Return Values : The item pointer or NULL if creation failed.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(ITEM *)
+new_item(const char *name, const char *description)
+{
+ ITEM *item;
+
+ T((T_CALLED("new_item(\"%s\", \"%s\")"),
+ name ? name : "",
+ description ? description : ""));
+
+ if (!name || (*name == '\0') || !Is_Printable_String(name))
+ {
+ item = (ITEM *) 0;
+ SET_ERROR(E_BAD_ARGUMENT);
+ }
+ else
+ {
+ item = typeCalloc(ITEM, 1);
+ if (item)
+ {
+ *item = _nc_Default_Item; /* hope we have struct assignment */
+
+ item->name.length = strlen(name);
+ item->name.str = name;
+
+ if (description && (*description != '\0') &&
+ Is_Printable_String(description))
+ {
+ item->description.length = strlen(description);
+ item->description.str = description;
+ }
+ else
+ {
+ item->description.length = 0;
+ item->description.str = (char *)0;
+ }
+ }
+ else
+ SET_ERROR(E_SYSTEM_ERROR);
+ }
+ returnItem(item);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int free_item(ITEM *item)
+|
+| Description : Free the allocated storage for this item.
+| N.B.: a connected item can't be freed.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid value has been passed
+| E_CONNECTED - item is still connected to a menu
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+free_item(ITEM * item)
+{
+ T((T_CALLED("free_item(%p)"), (void *)item));
+
+ if (!item)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (item->imenu)
+ RETURN(E_CONNECTED);
+
+ free(item);
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_mark( MENU *menu, const char *mark )
+|
+| Description : Set the mark string used to indicate the current
+| item (single-valued menu) or the selected items
+| (multi-valued menu).
+| The mark argument may be NULL, in which case no
+| marker is used.
+| This might be a little bit tricky, because this may
+| affect the geometry of the menu, which we don't allow
+| if it is already posted.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - an invalid value has been passed
+| E_SYSTEM_ERROR - no memory to store mark
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_menu_mark(MENU * menu, const char *mark)
+{
+ unsigned l;
+
+ T((T_CALLED("set_menu_mark(%p,%s)"), (void *)menu, _nc_visbuf(mark)));
+
+ if (mark && (*mark != '\0') && Is_Printable_String(mark))
+ l = strlen(mark);
+ else
+ l = 0;
+
+ if (menu)
+ {
+ char *old_mark = menu->mark;
+ unsigned short old_status = menu->status;
+
+ if (menu->status & _POSTED)
+ {
+ /* If the menu is already posted, the geometry is fixed. Then
+ we can only accept a mark with exactly the same length */
+ if (menu->marklen != (int)l)
+ RETURN(E_BAD_ARGUMENT);
+ }
+ menu->marklen = l;
+ if (l)
+ {
+ menu->mark = strdup(mark);
+ if (menu->mark)
+ {
+ strcpy(menu->mark, mark);
+ if (menu != &_nc_Default_Menu)
+ menu->status |= _MARK_ALLOCATED;
+ }
+ else
+ {
+ menu->mark = old_mark;
+ menu->marklen = (old_mark != 0) ? strlen(old_mark) : 0;
+ RETURN(E_SYSTEM_ERROR);
+ }
+ }
+ else
+ menu->mark = (char *)0;
+
+ if ((old_status & _MARK_ALLOCATED) && old_mark)
+ free(old_mark);
+
+ if (menu->status & _POSTED)
+ {
+ _nc_Draw_Menu(menu);
+ _nc_Show_Menu(menu);
+ }
+ else
+ {
+ /* Recalculate the geometry */
+ _nc_Calculate_Item_Length_and_Width(menu);
+ }
+ }
+ else
+ {
+ returnCode(set_menu_mark(&_nc_Default_Menu, mark));
+ }
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : char *menu_mark(const MENU *menu)
+|
+| Description : Return a pointer to the marker string
+|
+| Return Values : The marker string pointer or NULL if no marker defined
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(const char *)
+menu_mark(const MENU * menu)
+{
+ T((T_CALLED("menu_mark(%p)"), (const void *)menu));
+ returnPtr(Normalize_Menu(menu)->mark);
+}
+
+/* m_item_new.c */
diff --git a/payloads/libpayload/curses/menu/m_item_opt.c b/payloads/libpayload/curses/menu/m_item_opt.c
new file mode 100644
index 0000000000..91385da121
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_item_opt.c
@@ -0,0 +1,159 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_item_opt *
+* Menus item option routines *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_item_opt.c,v 1.18 2010/01/23 21:20:10 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_item_opts(ITEM *item, Item_Options opts)
+|
+| Description : Set the options of the item. If there are relevant
+| changes, the item is connected and the menu is posted,
+| the menu will be redisplayed.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid item options
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_item_opts(ITEM * item, Item_Options opts)
+{
+ T((T_CALLED("set_menu_opts(%p,%d)"), (void *)item, opts));
+
+ opts &= ALL_ITEM_OPTS;
+
+ if (opts & ~ALL_ITEM_OPTS)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (item)
+ {
+ if (item->opt != opts)
+ {
+ MENU *menu = item->imenu;
+
+ item->opt = opts;
+
+ if ((!(opts & O_SELECTABLE)) && item->value)
+ item->value = FALSE;
+
+ if (menu && (menu->status & _POSTED))
+ {
+ Move_And_Post_Item(menu, item);
+ _nc_Show_Menu(menu);
+ }
+ }
+ }
+ else
+ _nc_Default_Item.opt = opts;
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int item_opts_off(ITEM *item, Item_Options opts)
+|
+| Description : Switch of the options for this item.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid options
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+item_opts_off(ITEM * item, Item_Options opts)
+{
+ ITEM *citem = item; /* use a copy because set_item_opts must detect
+
+ NULL item itself to adjust its behavior */
+
+ T((T_CALLED("item_opts_off(%p,%d)"), (void *)item, opts));
+
+ if (opts & ~ALL_ITEM_OPTS)
+ RETURN(E_BAD_ARGUMENT);
+ else
+ {
+ Normalize_Item(citem);
+ opts = citem->opt & ~(opts & ALL_ITEM_OPTS);
+ returnCode(set_item_opts(item, opts));
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int item_opts_on(ITEM *item, Item_Options opts)
+|
+| Description : Switch on the options for this item.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid options
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+item_opts_on(ITEM * item, Item_Options opts)
+{
+ ITEM *citem = item; /* use a copy because set_item_opts must detect
+
+ NULL item itself to adjust its behavior */
+
+ T((T_CALLED("item_opts_on(%p,%d)"), (void *)item, opts));
+
+ opts &= ALL_ITEM_OPTS;
+ if (opts & ~ALL_ITEM_OPTS)
+ RETURN(E_BAD_ARGUMENT);
+ else
+ {
+ Normalize_Item(citem);
+ opts = citem->opt | opts;
+ returnCode(set_item_opts(item, opts));
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : Item_Options item_opts(const ITEM *item)
+|
+| Description : Switch of the options for this item.
+|
+| Return Values : Items options
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(Item_Options)
+item_opts(const ITEM * item)
+{
+ T((T_CALLED("item_opts(%p)"), (const void *)item));
+ returnItemOpts(ALL_ITEM_OPTS & Normalize_Item(item)->opt);
+}
+
+/* m_item_opt.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_item_top.c b/payloads/libpayload/curses/menu/m_item_top.c
new file mode 100644
index 0000000000..752e20d9ed
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_item_top.c
@@ -0,0 +1,107 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_item_top *
+* Set and get top menus item *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_item_top.c,v 1.11 2010/01/23 21:20:10 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_top_row(MENU *menu, int row)
+|
+| Description : Makes the specified row the top row in the menu
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - not a menu pointer or invalid row
+| E_NOT_CONNECTED - there are no items for the menu
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_top_row(MENU * menu, int row)
+{
+ ITEM *item;
+
+ T((T_CALLED("set_top_row(%p,%d)"), (void *)menu, row));
+
+ if (menu)
+ {
+ if (menu->status & _IN_DRIVER)
+ RETURN(E_BAD_STATE);
+ if (menu->items == (ITEM **) 0)
+ RETURN(E_NOT_CONNECTED);
+
+ if ((row < 0) || (row > (menu->rows - menu->arows)))
+ RETURN(E_BAD_ARGUMENT);
+ }
+ else
+ RETURN(E_BAD_ARGUMENT);
+
+ if (row != menu->toprow)
+ {
+ if (menu->status & _LINK_NEEDED)
+ _nc_Link_Items(menu);
+
+ item = menu->items[(menu->opt & O_ROWMAJOR) ? (row * menu->cols) : row];
+ assert(menu->pattern);
+ Reset_Pattern(menu);
+ _nc_New_TopRow_and_CurrentItem(menu, row, item);
+ }
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int top_row(const MENU *)
+|
+| Description : Return the top row of the menu
+|
+| Return Values : The row number or ERR if there is no row
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+top_row(const MENU * menu)
+{
+ T((T_CALLED("top_row(%p)"), (const void *)menu));
+ if (menu && menu->items && *(menu->items))
+ {
+ assert((menu->toprow >= 0) && (menu->toprow < menu->rows));
+ returnCode(menu->toprow);
+ }
+ else
+ returnCode(ERR);
+}
+
+/* m_item_top.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_item_use.c b/payloads/libpayload/curses/menu/m_item_use.c
new file mode 100644
index 0000000000..8cf294bc29
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_item_use.c
@@ -0,0 +1,76 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_item_use *
+* Associate application data with menu items *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_item_use.c,v 1.17 2010/01/23 21:20:10 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_item_userptr(ITEM *item, void *userptr)
+|
+| Description : Set the pointer that is reserved in any item to store
+| application relevant informations.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_item_userptr(ITEM * item, void *userptr)
+{
+ T((T_CALLED("set_item_userptr(%p,%p)"), (void *)item, (void *)userptr));
+ Normalize_Item(item)->userptr = userptr;
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void *item_userptr(const ITEM *item)
+|
+| Description : Return the pointer that is reserved in any item to store
+| application relevant informations.
+|
+| Return Values : Value of the pointer. If no such pointer has been set,
+| NULL is returned.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(void *)
+item_userptr(const ITEM * item)
+{
+ T((T_CALLED("item_userptr(%p)"), (const void *)item));
+ returnVoidPtr(Normalize_Item(item)->userptr);
+}
+
+/* m_item_use.c */
diff --git a/payloads/libpayload/curses/menu/m_item_val.c b/payloads/libpayload/curses/menu/m_item_val.c
new file mode 100644
index 0000000000..337dbfcc68
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_item_val.c
@@ -0,0 +1,104 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_item_val *
+* Set and get menus item values *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_item_val.c,v 1.15 2010/01/23 21:20:10 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_item_value(ITEM *item, int value)
+|
+| Description : Programmatically set the item's selection value. This is
+| only allowed if the item is selectable at all and if
+| it is not connected to a single-valued menu.
+| If the item is connected to a posted menu, the menu
+| will be redisplayed.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - not selectable or single valued menu
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_item_value(ITEM * item, bool value)
+{
+ MENU *menu;
+
+ T((T_CALLED("set_item_value(%p,%d)"), (void *)item, value));
+ if (item)
+ {
+ menu = item->imenu;
+
+ if ((!(item->opt & O_SELECTABLE)) ||
+ (menu && (menu->opt & O_ONEVALUE)))
+ RETURN(E_REQUEST_DENIED);
+
+ if (item->value ^ value)
+ {
+ item->value = value ? TRUE : FALSE;
+ if (menu)
+ {
+ if (menu->status & _POSTED)
+ {
+ Move_And_Post_Item(menu, item);
+ _nc_Show_Menu(menu);
+ }
+ }
+ }
+ }
+ else
+ _nc_Default_Item.value = value;
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : bool item_value(const ITEM *item)
+|
+| Description : Return the selection value of the item
+|
+| Return Values : TRUE - if item is selected
+| FALSE - if item is not selected
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(bool)
+item_value(const ITEM * item)
+{
+ T((T_CALLED("item_value(%p)"), (const void *)item));
+ returnBool((Normalize_Item(item)->value) ? TRUE : FALSE);
+}
+
+/* m_item_val.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_item_vis.c b/payloads/libpayload/curses/menu/m_item_vis.c
new file mode 100644
index 0000000000..ff84740543
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_item_vis.c
@@ -0,0 +1,68 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_item_vis *
+* Tell if menu item is visible *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_item_vis.c,v 1.16 2010/01/23 21:20:10 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : bool item_visible(const ITEM *item)
+|
+| Description : A item is visible if it currently appears in the
+| subwindow of a posted menu.
+|
+| Return Values : TRUE if visible
+| FALSE if invisible
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(bool)
+item_visible(const ITEM * item)
+{
+ MENU *menu;
+
+ T((T_CALLED("item_visible(%p)"), (const void *)item));
+ if (item &&
+ (menu = item->imenu) &&
+ (menu->status & _POSTED) &&
+ ((menu->toprow + menu->arows) > (item->y)) &&
+ (item->y >= menu->toprow))
+ returnBool(TRUE);
+ else
+ returnBool(FALSE);
+}
+
+/* m_item_vis.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_items.c b/payloads/libpayload/curses/menu/m_items.c
new file mode 100644
index 0000000000..539768551d
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_items.c
@@ -0,0 +1,110 @@
+/****************************************************************************
+ * Copyright (c) 1998-2005,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_items *
+* Connect and disconnect items to and from menus *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_items.c,v 1.17 2010/01/23 21:20:10 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_items(MENU *menu, ITEM **items)
+|
+| Description : Sets the item pointer array connected to menu.
+|
+| Return Values : E_OK - success
+| E_POSTED - menu is already posted
+| E_CONNECTED - one or more items are already connected
+| to another menu.
+| E_BAD_ARGUMENT - An incorrect menu or item array was
+| passed to the function
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_menu_items(MENU * menu, ITEM ** items)
+{
+ T((T_CALLED("set_menu_items(%p,%p)"), (void *)menu, (void *)items));
+
+ if (!menu || (items && !(*items)))
+ RETURN(E_BAD_ARGUMENT);
+
+ if (menu->status & _POSTED)
+ RETURN(E_POSTED);
+
+ if (menu->items)
+ _nc_Disconnect_Items(menu);
+
+ if (items)
+ {
+ if (!_nc_Connect_Items(menu, items))
+ RETURN(E_CONNECTED);
+ }
+
+ menu->items = items;
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : ITEM **menu_items(const MENU *menu)
+|
+| Description : Returns a pointer to the item pointer array of the menu
+|
+| Return Values : NULL on error
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(ITEM **)
+menu_items(const MENU * menu)
+{
+ T((T_CALLED("menu_items(%p)"), (const void *)menu));
+ returnItemPtr(menu ? menu->items : (ITEM **) 0);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int item_count(const MENU *menu)
+|
+| Description : Get the number of items connected to the menu. If the
+| menu pointer is NULL we return -1.
+|
+| Return Values : Number of items or -1 to indicate error.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+item_count(const MENU * menu)
+{
+ T((T_CALLED("item_count(%p)"), (const void *)menu));
+ returnCode(menu ? menu->nitems : -1);
+}
+
+/* m_items.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_new.c b/payloads/libpayload/curses/menu/m_new.c
new file mode 100644
index 0000000000..79f9292a7b
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_new.c
@@ -0,0 +1,142 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_new *
+* Creation and destruction of new menus *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_new.c,v 1.21 2010/01/23 21:20:11 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : MENU* _nc_new_menu(SCREEN*, ITEM **items)
+|
+| Description : Creates a new menu connected to the item pointer
+| array items and returns a pointer to the new menu.
+| The new menu is initialized with the values from the
+| default menu.
+|
+| Return Values : NULL on error
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(MENU *)
+NCURSES_SP_NAME(new_menu) (NCURSES_SP_DCLx ITEM ** items)
+{
+ int err = E_SYSTEM_ERROR;
+ MENU *menu = typeCalloc(MENU, 1);
+
+ T((T_CALLED("new_menu(%p,%p)"), (void *)SP_PARM, (void *)items));
+ if (menu)
+ {
+ *menu = _nc_Default_Menu;
+ menu->status = 0;
+ menu->rows = menu->frows;
+ menu->cols = menu->fcols;
+#if NCURSES_SP_FUNCS
+ /* This ensures userwin and usersub are always non-null,
+ so we can derive always the SCREEN that this menu is
+ running on. */
+ menu->userwin = SP_PARM->_stdscr;
+ menu->usersub = SP_PARM->_stdscr;
+#endif
+ if (items && *items)
+ {
+ if (!_nc_Connect_Items(menu, items))
+ {
+ err = E_NOT_CONNECTED;
+ free(menu);
+ menu = (MENU *) 0;
+ }
+ else
+ err = E_OK;
+ }
+ }
+
+ if (!menu)
+ SET_ERROR(err);
+
+ returnMenu(menu);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : MENU *new_menu(ITEM **items)
+|
+| Description : Creates a new menu connected to the item pointer
+| array items and returns a pointer to the new menu.
+| The new menu is initialized with the values from the
+| default menu.
+|
+| Return Values : NULL on error
++--------------------------------------------------------------------------*/
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(MENU *)
+new_menu(ITEM ** items)
+{
+ return NCURSES_SP_NAME(new_menu) (CURRENT_SCREEN, items);
+}
+#endif
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int free_menu(MENU *menu)
+|
+| Description : Disconnects menu from its associated item pointer
+| array and frees the storage allocated for the menu.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - Invalid menu pointer passed
+| E_POSTED - Menu is already posted
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+free_menu(MENU * menu)
+{
+ T((T_CALLED("free_menu(%p)"), (void *)menu));
+ if (!menu)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (menu->status & _POSTED)
+ RETURN(E_POSTED);
+
+ if (menu->items)
+ _nc_Disconnect_Items(menu);
+
+ if ((menu->status & _MARK_ALLOCATED) && menu->mark)
+ free(menu->mark);
+
+ free(menu);
+ RETURN(E_OK);
+}
+
+/* m_new.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_opts.c b/payloads/libpayload/curses/menu/m_opts.c
new file mode 100644
index 0000000000..bc6924b651
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_opts.c
@@ -0,0 +1,183 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_opts *
+* Menus option routines *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_opts.c,v 1.20 2010/01/23 21:20:10 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_opts(MENU *menu, Menu_Options opts)
+|
+| Description : Set the options for this menu. If the new settings
+| end up in a change of the geometry of the menu, it
+| will be recalculated. This operation is forbidden if
+| the menu is already posted.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid menu options
+| E_POSTED - menu is already posted
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_menu_opts(MENU * menu, Menu_Options opts)
+{
+ T((T_CALLED("set_menu_opts(%p,%d)"), (void *)menu, opts));
+
+ opts &= ALL_MENU_OPTS;
+
+ if (opts & ~ALL_MENU_OPTS)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (menu)
+ {
+ if (menu->status & _POSTED)
+ RETURN(E_POSTED);
+
+ if ((opts & O_ROWMAJOR) != (menu->opt & O_ROWMAJOR))
+ {
+ /* we need this only if the layout really changed ... */
+ if (menu->items && menu->items[0])
+ {
+ menu->toprow = 0;
+ menu->curitem = menu->items[0];
+ assert(menu->curitem);
+ set_menu_format(menu, menu->frows, menu->fcols);
+ }
+ }
+
+ menu->opt = opts;
+
+ if (opts & O_ONEVALUE)
+ {
+ ITEM **item;
+
+ if (((item = menu->items) != (ITEM **) 0))
+ for (; *item; item++)
+ (*item)->value = FALSE;
+ }
+
+ if (opts & O_SHOWDESC) /* this also changes the geometry */
+ _nc_Calculate_Item_Length_and_Width(menu);
+ }
+ else
+ _nc_Default_Menu.opt = opts;
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int menu_opts_off(MENU *menu, Menu_Options opts)
+|
+| Description : Switch off the options for this menu. If the new settings
+| end up in a change of the geometry of the menu, it
+| will be recalculated. This operation is forbidden if
+| the menu is already posted.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid options
+| E_POSTED - menu is already posted
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+menu_opts_off(MENU * menu, Menu_Options opts)
+{
+ MENU *cmenu = menu; /* use a copy because set_menu_opts must detect
+
+ NULL menu itself to adjust its behavior */
+
+ T((T_CALLED("menu_opts_off(%p,%d)"), (void *)menu, opts));
+
+ opts &= ALL_MENU_OPTS;
+ if (opts & ~ALL_MENU_OPTS)
+ RETURN(E_BAD_ARGUMENT);
+ else
+ {
+ Normalize_Menu(cmenu);
+ opts = cmenu->opt & ~opts;
+ returnCode(set_menu_opts(menu, opts));
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int menu_opts_on(MENU *menu, Menu_Options opts)
+|
+| Description : Switch on the options for this menu. If the new settings
+| end up in a change of the geometry of the menu, it
+| will be recalculated. This operation is forbidden if
+| the menu is already posted.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid menu options
+| E_POSTED - menu is already posted
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+menu_opts_on(MENU * menu, Menu_Options opts)
+{
+ MENU *cmenu = menu; /* use a copy because set_menu_opts must detect
+
+ NULL menu itself to adjust its behavior */
+
+ T((T_CALLED("menu_opts_on(%p,%d)"), (void *)menu, opts));
+
+ opts &= ALL_MENU_OPTS;
+ if (opts & ~ALL_MENU_OPTS)
+ RETURN(E_BAD_ARGUMENT);
+ else
+ {
+ Normalize_Menu(cmenu);
+ opts = cmenu->opt | opts;
+ returnCode(set_menu_opts(menu, opts));
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : Menu_Options menu_opts(const MENU *menu)
+|
+| Description : Return the options for this menu.
+|
+| Return Values : Menu options
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(Menu_Options)
+menu_opts(const MENU * menu)
+{
+ T((T_CALLED("menu_opts(%p)"), (const void *)menu));
+ returnMenuOpts(ALL_MENU_OPTS & Normalize_Menu(menu)->opt);
+}
+
+/* m_opts.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_pad.c b/payloads/libpayload/curses/menu/m_pad.c
new file mode 100644
index 0000000000..caa2f9e207
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_pad.c
@@ -0,0 +1,95 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_pad *
+* Control menus padding character *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_pad.c,v 1.12 2010/01/23 21:20:10 tom Exp $")
+
+/* Macro to redraw menu if it is posted and changed */
+#define Refresh_Menu(menu) \
+ if ( (menu) && ((menu)->status & _POSTED) )\
+ {\
+ _nc_Draw_Menu( menu );\
+ _nc_Show_Menu( menu ); \
+ }
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_pad(MENU* menu, int pad)
+|
+| Description : Set the character to be used to separate the item name
+| from its description. This must be a printable
+| character.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - an invalid value has been passed
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_menu_pad(MENU * menu, int pad)
+{
+ bool do_refresh = (menu != (MENU *) 0);
+
+ T((T_CALLED("set_menu_pad(%p,%d)"), (void *)menu, pad));
+
+ if (!isprint(UChar(pad)))
+ RETURN(E_BAD_ARGUMENT);
+
+ Normalize_Menu(menu);
+ menu->pad = pad;
+
+ if (do_refresh)
+ Refresh_Menu(menu);
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int menu_pad(const MENU *menu)
+|
+| Description : Return the value of the padding character
+|
+| Return Values : The pad character
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+menu_pad(const MENU * menu)
+{
+ T((T_CALLED("menu_pad(%p)"), (const void *)menu));
+ returnCode(Normalize_Menu(menu)->pad);
+}
+
+/* m_pad.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_pattern.c b/payloads/libpayload/curses/menu/m_pattern.c
new file mode 100644
index 0000000000..1764d05fbc
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_pattern.c
@@ -0,0 +1,124 @@
+/****************************************************************************
+ * Copyright (c) 1998-2006,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_pattern *
+* Pattern matching handling *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_pattern.c,v 1.16 2010/01/23 21:20:10 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : char *menu_pattern(const MENU *menu)
+|
+| Description : Return the value of the pattern buffer.
+|
+| Return Values : NULL - if there is no pattern buffer allocated
+| EmptyString - if there is a pattern buffer but no
+| pattern is stored
+| PatternString - as expected
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(char *)
+menu_pattern(const MENU * menu)
+{
+ static char empty[] = "";
+
+ T((T_CALLED("menu_pattern(%p)"), (const void *)menu));
+ returnPtr(menu ? (menu->pattern ? menu->pattern : empty) : 0);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_pattern(MENU *menu, const char *p)
+|
+| Description : Set the match pattern for a menu and position to the
+| first item that matches.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid menu or pattern pointer
+| E_BAD_STATE - menu in user hook routine
+| E_NOT_CONNECTED - no items connected to menu
+| E_NO_MATCH - no item matches pattern
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_menu_pattern(MENU * menu, const char *p)
+{
+ ITEM *matchitem;
+ int matchpos;
+
+ T((T_CALLED("set_menu_pattern(%p,%s)"), (void *)menu, _nc_visbuf(p)));
+
+ if (!menu || !p)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (!(menu->items))
+ RETURN(E_NOT_CONNECTED);
+
+ if (menu->status & _IN_DRIVER)
+ RETURN(E_BAD_STATE);
+
+ Reset_Pattern(menu);
+
+ if (!(*p))
+ {
+ pos_menu_cursor(menu);
+ RETURN(E_OK);
+ }
+
+ if (menu->status & _LINK_NEEDED)
+ _nc_Link_Items(menu);
+
+ matchpos = menu->toprow;
+ matchitem = menu->curitem;
+ assert(matchitem);
+
+ while (*p)
+ {
+ if (!isprint(UChar(*p)) ||
+ (_nc_Match_Next_Character_In_Item_Name(menu, *p, &matchitem) != E_OK))
+ {
+ Reset_Pattern(menu);
+ pos_menu_cursor(menu);
+ RETURN(E_NO_MATCH);
+ }
+ p++;
+ }
+
+ /* This is reached if there was a match. So we position to the new item */
+ Adjust_Current_Item(menu, matchpos, matchitem);
+ RETURN(E_OK);
+}
+
+/* m_pattern.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_post.c b/payloads/libpayload/curses/menu/m_post.c
new file mode 100644
index 0000000000..007476bb4a
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_post.c
@@ -0,0 +1,377 @@
+/****************************************************************************
+ * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_post *
+* Write or erase menus from associated subwindows *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_post.c,v 1.29 2010/05/01 19:18:27 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void _nc_Post_Item(MENU *menu, ITEM *item)
+|
+| Description : Draw the item in the menus window at the current
+| window position
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(void)
+_nc_Post_Item(const MENU * menu, const ITEM * item)
+{
+ int i;
+ chtype ch;
+ int item_x, item_y;
+ int count = 0;
+ bool isfore = FALSE, isback = FALSE, isgrey = FALSE;
+ int name_len;
+ int desc_len;
+
+ assert(menu->win);
+
+ getyx(menu->win, item_y, item_x);
+
+ /* We need a marker iff
+ - it is a onevalued menu and it is the current item
+ - or it has a selection value
+ */
+ wattron(menu->win, menu->back);
+ if (item->value || (item == menu->curitem))
+ {
+ if (menu->marklen)
+ {
+ /* In a multi selection menu we use the fore attribute
+ for a selected marker that is not the current one.
+ This improves visualization of the menu, because now
+ always the 'normal' marker denotes the current
+ item. */
+ if (!(menu->opt & O_ONEVALUE) && item->value && item != menu->curitem)
+ {
+ wattron(menu->win, menu->fore);
+ isfore = TRUE;
+ }
+ waddstr(menu->win, menu->mark);
+ if (isfore)
+ {
+ wattron(menu->win, menu->fore);
+ isfore = FALSE;
+ }
+ }
+ }
+ else /* otherwise we have to wipe out the marker area */
+ for (ch = ' ', i = menu->marklen; i > 0; i--)
+ waddch(menu->win, ch);
+ wattroff(menu->win, menu->back);
+ count += menu->marklen;
+
+ /* First we have to calculate the attribute depending on selectability
+ and selection status
+ */
+ if (!(item->opt & O_SELECTABLE))
+ {
+ wattron(menu->win, menu->grey);
+ isgrey = TRUE;
+ }
+ else
+ {
+ if (item->value || item == menu->curitem)
+ {
+ wattron(menu->win, menu->fore);
+ isfore = TRUE;
+ }
+ else
+ {
+ wattron(menu->win, menu->back);
+ isback = TRUE;
+ }
+ }
+
+ waddnstr(menu->win, item->name.str, item->name.length);
+ name_len = _nc_Calculate_Text_Width(&(item->name));
+ for (ch = ' ', i = menu->namelen - name_len; i > 0; i--)
+ {
+ waddch(menu->win, ch);
+ }
+ count += menu->namelen;
+
+ /* Show description if required and available */
+ if ((menu->opt & O_SHOWDESC) && menu->desclen > 0)
+ {
+ int m = menu->spc_desc / 2;
+ int cy = -1, cx = -1;
+
+ for (ch = ' ', i = 0; i < menu->spc_desc; i++)
+ {
+ if (i == m)
+ {
+ waddch(menu->win, menu->pad);
+ getyx(menu->win, cy, cx);
+ }
+ else
+ waddch(menu->win, ch);
+ }
+ if (item->description.length)
+ waddnstr(menu->win, item->description.str, item->description.length);
+ desc_len = _nc_Calculate_Text_Width(&(item->description));
+ for (ch = ' ', i = menu->desclen - desc_len; i > 0; i--)
+ {
+ waddch(menu->win, ch);
+ }
+ count += menu->desclen + menu->spc_desc;
+
+ if (menu->spc_rows > 1)
+ {
+ int j, k, ncy, ncx;
+
+ assert(cx >= 0 && cy >= 0);
+ getyx(menu->win, ncy, ncx);
+ if (isgrey)
+ wattroff(menu->win, menu->grey);
+ else if (isfore)
+ wattroff(menu->win, menu->fore);
+ wattron(menu->win, menu->back);
+ for (j = 1; j < menu->spc_rows; j++)
+ {
+ if ((item_y + j) < getmaxy(menu->win))
+ {
+ wmove(menu->win, item_y + j, item_x);
+ for (k = 0; k < count; k++)
+ waddch(menu->win, ' ');
+ }
+ if ((cy + j) < getmaxy(menu->win))
+ (void)mvwaddch(menu->win, cy + j, cx - 1, menu->pad);
+ }
+ wmove(menu->win, ncy, ncx);
+ if (!isback)
+ wattroff(menu->win, menu->back);
+ }
+ }
+
+ /* Remove attributes */
+ if (isfore)
+ wattroff(menu->win, menu->fore);
+ if (isback)
+ wattroff(menu->win, menu->back);
+ if (isgrey)
+ wattroff(menu->win, menu->grey);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void _nc_Draw_Menu(const MENU *)
+|
+| Description : Display the menu in its windows
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(void)
+_nc_Draw_Menu(const MENU * menu)
+{
+ ITEM *item = menu->items[0];
+ ITEM *lasthor, *lastvert;
+ ITEM *hitem;
+ int y = 0;
+ chtype s_bkgd;
+
+ assert(item && menu->win);
+
+ s_bkgd = getbkgd(menu->win);
+ wbkgdset(menu->win, menu->back);
+ werase(menu->win);
+ wbkgdset(menu->win, s_bkgd);
+
+ lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *) 0 : item;
+
+ do
+ {
+ wmove(menu->win, y, 0);
+
+ hitem = item;
+ lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *) 0 : hitem;
+
+ do
+ {
+ _nc_Post_Item(menu, hitem);
+
+ wattron(menu->win, menu->back);
+ if (((hitem = hitem->right) != lasthor) && hitem)
+ {
+ int i, j, cy, cx;
+ chtype ch = ' ';
+
+ getyx(menu->win, cy, cx);
+ for (j = 0; j < menu->spc_rows; j++)
+ {
+ wmove(menu->win, cy + j, cx);
+ for (i = 0; i < menu->spc_cols; i++)
+ {
+ waddch(menu->win, ch);
+ }
+ }
+ wmove(menu->win, cy, cx + menu->spc_cols);
+ }
+ }
+ while (hitem && (hitem != lasthor));
+ wattroff(menu->win, menu->back);
+
+ item = item->down;
+ y += menu->spc_rows;
+
+ }
+ while (item && (item != lastvert));
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int post_menu(MENU* menu)
+|
+| Description : Post a menu to the screen. This makes it visible.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - not a valid menu pointer
+| E_SYSTEM_ERROR - error in lower layers
+| E_NOT_CONNECTED - No items connected to menu
+| E_BAD_STATE - Menu in userexit routine
+| E_POSTED - Menu already posted
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+post_menu(MENU * menu)
+{
+ T((T_CALLED("post_menu(%p)"), (void *)menu));
+
+ if (!menu)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (menu->status & _IN_DRIVER)
+ RETURN(E_BAD_STATE);
+
+ if (menu->status & _POSTED)
+ RETURN(E_POSTED);
+
+ if (menu->items && *(menu->items))
+ {
+ int y;
+ int h = 1 + menu->spc_rows * (menu->rows - 1);
+
+ WINDOW *win = Get_Menu_Window(menu);
+ int maxy = getmaxy(win);
+
+ if ((menu->win = newpad(h+2, menu->width+2)))
+ {
+ y = (maxy >= h) ? h : maxy;
+ if (y >= menu->height)
+ y = menu->height;
+ if (!(menu->sub = subpad(menu->win, y, menu->width, 0, 0)))
+ RETURN(E_SYSTEM_ERROR);
+ }
+ else
+ RETURN(E_SYSTEM_ERROR);
+
+ if (menu->status & _LINK_NEEDED)
+ _nc_Link_Items(menu);
+ }
+ else
+ RETURN(E_NOT_CONNECTED);
+
+ menu->status |= _POSTED;
+
+ if (!(menu->opt & O_ONEVALUE))
+ {
+ ITEM **items;
+
+ for (items = menu->items; *items; items++)
+ {
+ (*items)->value = FALSE;
+ }
+ }
+
+ _nc_Draw_Menu(menu);
+
+ Call_Hook(menu, menuinit);
+ Call_Hook(menu, iteminit);
+
+ _nc_Show_Menu(menu);
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int unpost_menu(MENU*)
+|
+| Description : Detach menu from screen
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - not a valid menu pointer
+| E_BAD_STATE - menu in userexit routine
+| E_NOT_POSTED - menu is not posted
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+unpost_menu(MENU * menu)
+{
+ WINDOW *win;
+
+ T((T_CALLED("unpost_menu(%p)"), (void *)menu));
+
+ if (!menu)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (menu->status & _IN_DRIVER)
+ RETURN(E_BAD_STATE);
+
+ if (!(menu->status & _POSTED))
+ RETURN(E_NOT_POSTED);
+
+ Call_Hook(menu, itemterm);
+ Call_Hook(menu, menuterm);
+
+ win = Get_Menu_Window(menu);
+ werase(win);
+ wsyncup(win);
+
+ assert(menu->sub);
+ delwin(menu->sub);
+ menu->sub = (WINDOW *)0;
+
+ assert(menu->win);
+ delwin(menu->win);
+ menu->win = (WINDOW *)0;
+
+ menu->status &= ~_POSTED;
+
+ RETURN(E_OK);
+}
+
+/* m_post.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_req_name.c b/payloads/libpayload/curses/menu/m_req_name.c
new file mode 100644
index 0000000000..cad8758020
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_req_name.c
@@ -0,0 +1,125 @@
+/****************************************************************************
+ * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_request_name *
+* Routines to handle external names of menu requests *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_req_name.c,v 1.21 2009/10/10 16:17:23 tom Exp $")
+
+static const char *request_names[MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1] =
+{
+ "LEFT_ITEM",
+ "RIGHT_ITEM",
+ "UP_ITEM",
+ "DOWN_ITEM",
+ "SCR_ULINE",
+ "SCR_DLINE",
+ "SCR_DPAGE",
+ "SCR_UPAGE",
+ "FIRST_ITEM",
+ "LAST_ITEM",
+ "NEXT_ITEM",
+ "PREV_ITEM",
+ "TOGGLE_ITEM",
+ "CLEAR_PATTERN",
+ "BACK_PATTERN",
+ "NEXT_MATCH",
+ "PREV_MATCH"
+};
+
+#define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : const char * menu_request_name (int request);
+|
+| Description : Get the external name of a menu request.
+|
+| Return Values : Pointer to name - on success
+| NULL - on invalid request code
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(const char *)
+menu_request_name(int request)
+{
+ T((T_CALLED("menu_request_name(%d)"), request));
+ if ((request < MIN_MENU_COMMAND) || (request > MAX_MENU_COMMAND))
+ {
+ SET_ERROR(E_BAD_ARGUMENT);
+ returnCPtr((const char *)0);
+ }
+ else
+ returnCPtr(request_names[request - MIN_MENU_COMMAND]);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int menu_request_by_name (const char *str);
+|
+| Description : Search for a request with this name.
+|
+| Return Values : Request Id - on success
+| E_NO_MATCH - request not found
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+menu_request_by_name(const char *str)
+{
+ /* because the table is so small, it doesn't really hurt
+ to run sequentially through it.
+ */
+ unsigned int i = 0;
+ char buf[16];
+
+ T((T_CALLED("menu_request_by_name(%s)"), _nc_visbuf(str)));
+
+ if (str)
+ {
+ strncpy(buf, str, sizeof(buf));
+ while ((i < sizeof(buf)) && (buf[i] != '\0'))
+ {
+ buf[i] = (char)toupper(UChar(buf[i]));
+ i++;
+ }
+
+ for (i = 0; i < A_SIZE; i++)
+ {
+ if (strncmp(request_names[i], buf, sizeof(buf)) == 0)
+ returnCode(MIN_MENU_COMMAND + (int)i);
+ }
+ }
+ RETURN(E_NO_MATCH);
+}
+
+/* m_req_name.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_scale.c b/payloads/libpayload/curses/menu/m_scale.c
new file mode 100644
index 0000000000..068a1cc8c5
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_scale.c
@@ -0,0 +1,76 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_scale *
+* Menu scaling routine *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_scale.c,v 1.10 2010/01/23 21:20:10 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int scale_menu(const MENU *menu)
+|
+| Description : Returns the minimum window size necessary for the
+| subwindow of menu.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid menu pointer
+| E_NOT_CONNECTED - no items are connected to menu
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+scale_menu(const MENU * menu, int *rows, int *cols)
+{
+ T((T_CALLED("scale_menu(%p,%p,%p)"),
+ (const void *)menu,
+ (void *)rows,
+ (void *)cols));
+
+ if (!menu)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (menu->items && *(menu->items))
+ {
+ if (rows)
+ *rows = menu->height;
+ if (cols)
+ *cols = menu->width;
+ RETURN(E_OK);
+ }
+ else
+ RETURN(E_NOT_CONNECTED);
+}
+
+/* m_scale.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_spacing.c b/payloads/libpayload/curses/menu/m_spacing.c
new file mode 100644
index 0000000000..1cfa2e1665
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_spacing.c
@@ -0,0 +1,113 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_spacing *
+* Routines to handle spacing between entries *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_spacing.c,v 1.18 2010/01/23 21:20:10 tom Exp $")
+
+#define MAX_SPC_DESC ((TABSIZE) ? (TABSIZE) : 8)
+#define MAX_SPC_COLS ((TABSIZE) ? (TABSIZE) : 8)
+#define MAX_SPC_ROWS (3)
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_spacing(MENU *menu,int desc, int r, int c);
+|
+| Description : Set the spacing between entries
+|
+| Return Values : E_OK - on success
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_menu_spacing(MENU * menu, int s_desc, int s_row, int s_col)
+{
+ MENU *m; /* split for ATAC workaround */
+
+ T((T_CALLED("set_menu_spacing(%p,%d,%d,%d)"),
+ (void *)menu, s_desc, s_row, s_col));
+
+ m = Normalize_Menu(menu);
+
+ assert(m);
+ if (m->status & _POSTED)
+ RETURN(E_POSTED);
+
+ if (((s_desc < 0) || (s_desc > MAX_SPC_DESC)) ||
+ ((s_row < 0) || (s_row > MAX_SPC_ROWS)) ||
+ ((s_col < 0) || (s_col > MAX_SPC_COLS)))
+ RETURN(E_BAD_ARGUMENT);
+
+ m->spc_desc = s_desc ? s_desc : 1;
+ m->spc_rows = s_row ? s_row : 1;
+ m->spc_cols = s_col ? s_col : 1;
+ _nc_Calculate_Item_Length_and_Width(m);
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int menu_spacing (const MENU *,int *,int *,int *);
+|
+| Description : Retrieve info about spacing between the entries
+|
+| Return Values : E_OK - on success
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+menu_spacing(const MENU * menu, int *s_desc, int *s_row, int *s_col)
+{
+ const MENU *m; /* split for ATAC workaround */
+
+ T((T_CALLED("menu_spacing(%p,%p,%p,%p)"),
+ (const void *)menu,
+ (void *)s_desc,
+ (void *)s_row,
+ (void *)s_col));
+
+ m = Normalize_Menu(menu);
+
+ assert(m);
+ if (s_desc)
+ *s_desc = m->spc_desc;
+ if (s_row)
+ *s_row = m->spc_rows;
+ if (s_col)
+ *s_col = m->spc_cols;
+
+ RETURN(E_OK);
+}
+
+/* m_spacing.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_sub.c b/payloads/libpayload/curses/menu/m_sub.c
new file mode 100644
index 0000000000..27123586bc
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_sub.c
@@ -0,0 +1,100 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_sub *
+* Menus subwindow association routines *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_sub.c,v 1.12 2010/01/23 21:20:11 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_sub(MENU *menu, WINDOW *win)
+|
+| Description : Sets the subwindow of the menu.
+|
+| Return Values : E_OK - success
+| E_POSTED - menu is already posted
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_menu_sub(MENU * menu, WINDOW *win)
+{
+ T((T_CALLED("set_menu_sub(%p,%p)"), (void *)menu, (void *)win));
+
+ if (menu)
+ {
+ if (menu->status & _POSTED)
+ RETURN(E_POSTED);
+ else
+#if NCURSES_SP_FUNCS
+ {
+ /* We ensure that usersub is never null. So even if a null
+ WINDOW parameter is passed, we store the SCREENS stdscr.
+ The only MENU that can have a null usersub is the static
+ _nc_default_Menu.
+ */
+ SCREEN *sp = _nc_screen_of(menu->usersub);
+
+ menu->usersub = win ? win : stdscr;
+ _nc_Calculate_Item_Length_and_Width(menu);
+ }
+#else
+ menu->usersub = win;
+#endif
+ }
+ else
+ _nc_Default_Menu.usersub = win;
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : WINDOW* menu_sub(const MENU *menu)
+|
+| Description : Returns a pointer to the subwindow of the menu
+|
+| Return Values : NULL on error, otherwise a pointer to the window
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(WINDOW *)
+menu_sub(const MENU * menu)
+{
+ const MENU *m = Normalize_Menu(menu);
+
+ T((T_CALLED("menu_sub(%p)"), (const void *)menu));
+ returnWin(Get_Menu_Window(m));
+}
+
+/* m_sub.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_trace.c b/payloads/libpayload/curses/menu/m_trace.c
new file mode 100644
index 0000000000..094ff86c67
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_trace.c
@@ -0,0 +1,77 @@
+/****************************************************************************
+ * Copyright (c) 2004-2005,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey *
+ ****************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_trace.c,v 1.4 2010/01/23 21:20:10 tom Exp $")
+
+NCURSES_EXPORT(ITEM *)
+_nc_retrace_item(ITEM * code)
+{
+ T((T_RETURN("%p"), (void *)code));
+ return code;
+}
+
+NCURSES_EXPORT(ITEM **)
+_nc_retrace_item_ptr(ITEM ** code)
+{
+ T((T_RETURN("%p"), (void *)code));
+ return code;
+}
+
+NCURSES_EXPORT(Item_Options)
+_nc_retrace_item_opts(Item_Options code)
+{
+ T((T_RETURN("%d"), code));
+ return code;
+}
+
+NCURSES_EXPORT(MENU *)
+_nc_retrace_menu(MENU * code)
+{
+ T((T_RETURN("%p"), (void *)code));
+ return code;
+}
+
+NCURSES_EXPORT(Menu_Hook)
+_nc_retrace_menu_hook(Menu_Hook code)
+{
+ T((T_RETURN("%p"), code));
+ return code;
+}
+
+NCURSES_EXPORT(Menu_Options)
+_nc_retrace_menu_opts(Menu_Options code)
+{
+ T((T_RETURN("%d"), code));
+ return code;
+}
diff --git a/payloads/libpayload/curses/menu/m_userptr.c b/payloads/libpayload/curses/menu/m_userptr.c
new file mode 100644
index 0000000000..a7359c99d0
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_userptr.c
@@ -0,0 +1,76 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_userptr *
+* Associate application data with menus *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_userptr.c,v 1.17 2010/01/23 21:20:10 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_userptr(MENU *menu, void *userptr)
+|
+| Description : Set the pointer that is reserved in any menu to store
+| application relevant informations.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_menu_userptr(MENU * menu, void *userptr)
+{
+ T((T_CALLED("set_menu_userptr(%p,%p)"), (void *)menu, (void *)userptr));
+ Normalize_Menu(menu)->userptr = userptr;
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void *menu_userptr(const MENU *menu)
+|
+| Description : Return the pointer that is reserved in any menu to
+| store application relevant informations.
+|
+| Return Values : Value of the pointer. If no such pointer has been set,
+| NULL is returned
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(void *)
+menu_userptr(const MENU * menu)
+{
+ T((T_CALLED("menu_userptr(%p)"), (const void *)menu));
+ returnVoidPtr(Normalize_Menu(menu)->userptr);
+}
+
+/* m_userptr.c ends here */
diff --git a/payloads/libpayload/curses/menu/m_win.c b/payloads/libpayload/curses/menu/m_win.c
new file mode 100644
index 0000000000..5ddb1af9d3
--- /dev/null
+++ b/payloads/libpayload/curses/menu/m_win.c
@@ -0,0 +1,100 @@
+/****************************************************************************
+ * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/***************************************************************************
+* Module m_win *
+* Menus window association routines *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_win.c,v 1.17 2010/01/23 21:20:11 tom Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_win(MENU *menu, WINDOW *win)
+|
+| Description : Sets the window of the menu.
+|
+| Return Values : E_OK - success
+| E_POSTED - menu is already posted
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+set_menu_win(MENU * menu, WINDOW *win)
+{
+ T((T_CALLED("set_menu_win(%p,%p)"), (void *)menu, (void *)win));
+
+ if (menu)
+ {
+ if (menu->status & _POSTED)
+ RETURN(E_POSTED);
+ else
+#if NCURSES_SP_FUNCS
+ {
+ /* We ensure that userwin is never null. So even if a null
+ WINDOW parameter is passed, we store the SCREENS stdscr.
+ The only MENU that can have a null userwin is the static
+ _nc_default_Menu.
+ */
+ SCREEN *sp = _nc_screen_of(menu->userwin);
+
+ menu->userwin = win ? win : stdscr;
+ _nc_Calculate_Item_Length_and_Width(menu);
+ }
+#else
+ menu->userwin = win;
+#endif
+ }
+ else
+ _nc_Default_Menu.userwin = win;
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : WINDOW* menu_win(const MENU*)
+|
+| Description : Returns pointer to the window of the menu
+|
+| Return Values : NULL on error, otherwise pointer to window
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(WINDOW *)
+menu_win(const MENU * menu)
+{
+ const MENU *m = Normalize_Menu(menu);
+
+ T((T_CALLED("menu_win(%p)"), (const void *)menu));
+ returnWin(Get_Menu_UserWin(m));
+}
+
+/* m_win.c ends here */
diff --git a/payloads/libpayload/curses/menu/menu.h b/payloads/libpayload/curses/menu/menu.h
new file mode 100644
index 0000000000..67396f7637
--- /dev/null
+++ b/payloads/libpayload/curses/menu/menu.h
@@ -0,0 +1,261 @@
+/****************************************************************************
+ * Copyright (c) 1998-2007,2009 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/* $Id: menu.h,v 1.20 2009/04/05 00:28:07 tom Exp $ */
+
+#ifndef ETI_MENU
+#define ETI_MENU
+
+#ifdef AMIGA
+#define TEXT TEXT_ncurses
+#endif
+
+#include <curses.h>
+#include <eti.h>
+#include <ncurses_cfg.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef int Menu_Options;
+typedef int Item_Options;
+
+/* Menu options: */
+#define O_ONEVALUE (0x01)
+#define O_SHOWDESC (0x02)
+#define O_ROWMAJOR (0x04)
+#define O_IGNORECASE (0x08)
+#define O_SHOWMATCH (0x10)
+#define O_NONCYCLIC (0x20)
+
+/* Item options: */
+#define O_SELECTABLE (0x01)
+
+typedef struct
+{
+ const char* str;
+ unsigned short length;
+} TEXT;
+
+typedef struct tagITEM
+{
+ TEXT name; /* name of menu item */
+ TEXT description; /* description of item, optional in display */
+ struct tagMENU *imenu; /* Pointer to parent menu */
+ void *userptr; /* Pointer to user defined per item data */
+ Item_Options opt; /* Item options */
+ short index; /* Item number if connected to a menu */
+ short y; /* y and x location of item in menu */
+ short x;
+ bool value; /* Selection value */
+
+ struct tagITEM *left; /* neighbor items */
+ struct tagITEM *right;
+ struct tagITEM *up;
+ struct tagITEM *down;
+
+} ITEM;
+
+typedef void (*Menu_Hook)(struct tagMENU *);
+
+typedef struct tagMENU
+{
+ short height; /* Nr. of chars high */
+ short width; /* Nr. of chars wide */
+ short rows; /* Nr. of items high */
+ short cols; /* Nr. of items wide */
+ short frows; /* Nr. of formatted items high */
+ short fcols; /* Nr. of formatted items wide */
+ short arows; /* Nr. of items high (actual) */
+ short namelen; /* Max. name length */
+ short desclen; /* Max. description length */
+ short marklen; /* Length of mark, if any */
+ short itemlen; /* Length of one item */
+ short spc_desc; /* Spacing for descriptor */
+ short spc_cols; /* Spacing for columns */
+ short spc_rows; /* Spacing for rows */
+ char *pattern; /* Buffer to store match chars */
+ short pindex; /* Index into pattern buffer */
+ WINDOW *win; /* Window containing menu */
+ WINDOW *sub; /* Subwindow for menu display */
+ WINDOW *userwin; /* User's window */
+ WINDOW *usersub; /* User's subwindow */
+ ITEM **items; /* array of items */
+ short nitems; /* Nr. of items in menu */
+ ITEM *curitem; /* Current item */
+ short toprow; /* Top row of menu */
+ chtype fore; /* Selection attribute */
+ chtype back; /* Nonselection attribute */
+ chtype grey; /* Inactive attribute */
+ unsigned char pad; /* Pad character */
+
+ Menu_Hook menuinit; /* User hooks */
+ Menu_Hook menuterm;
+ Menu_Hook iteminit;
+ Menu_Hook itemterm;
+
+ void *userptr; /* Pointer to menus user data */
+ char *mark; /* Pointer to marker string */
+
+ Menu_Options opt; /* Menu options */
+ unsigned short status; /* Internal state of menu */
+
+} MENU;
+
+
+/* Define keys */
+
+#define REQ_LEFT_ITEM (KEY_MAX + 1)
+#define REQ_RIGHT_ITEM (KEY_MAX + 2)
+#define REQ_UP_ITEM (KEY_MAX + 3)
+#define REQ_DOWN_ITEM (KEY_MAX + 4)
+#define REQ_SCR_ULINE (KEY_MAX + 5)
+#define REQ_SCR_DLINE (KEY_MAX + 6)
+#define REQ_SCR_DPAGE (KEY_MAX + 7)
+#define REQ_SCR_UPAGE (KEY_MAX + 8)
+#define REQ_FIRST_ITEM (KEY_MAX + 9)
+#define REQ_LAST_ITEM (KEY_MAX + 10)
+#define REQ_NEXT_ITEM (KEY_MAX + 11)
+#define REQ_PREV_ITEM (KEY_MAX + 12)
+#define REQ_TOGGLE_ITEM (KEY_MAX + 13)
+#define REQ_CLEAR_PATTERN (KEY_MAX + 14)
+#define REQ_BACK_PATTERN (KEY_MAX + 15)
+#define REQ_NEXT_MATCH (KEY_MAX + 16)
+#define REQ_PREV_MATCH (KEY_MAX + 17)
+
+#define MIN_MENU_COMMAND (KEY_MAX + 1)
+#define MAX_MENU_COMMAND (KEY_MAX + 17)
+
+/*
+ * Some AT&T code expects MAX_COMMAND to be out-of-band not
+ * just for menu commands but for forms ones as well.
+ */
+#if defined(MAX_COMMAND)
+# if (MAX_MENU_COMMAND > MAX_COMMAND)
+# error Something is wrong -- MAX_MENU_COMMAND is greater than MAX_COMMAND
+# elif (MAX_COMMAND != (KEY_MAX + 128))
+# error Something is wrong -- MAX_COMMAND is already inconsistently defined.
+# endif
+#else
+# define MAX_COMMAND (KEY_MAX + 128)
+#endif
+
+
+/* --------- prototypes for libmenu functions ----------------------------- */
+
+extern NCURSES_EXPORT(ITEM **) menu_items (const MENU *);
+extern NCURSES_EXPORT(ITEM *) current_item (const MENU *);
+extern NCURSES_EXPORT(ITEM *) new_item (const char *,const char *);
+
+extern NCURSES_EXPORT(MENU *) new_menu (ITEM **);
+
+extern NCURSES_EXPORT(Item_Options) item_opts (const ITEM *);
+extern NCURSES_EXPORT(Menu_Options) menu_opts (const MENU *);
+
+extern NCURSES_EXPORT(Menu_Hook) item_init (const MENU *);
+extern NCURSES_EXPORT(Menu_Hook) item_term (const MENU *);
+extern NCURSES_EXPORT(Menu_Hook) menu_init (const MENU *);
+extern NCURSES_EXPORT(Menu_Hook) menu_term (const MENU *);
+
+extern NCURSES_EXPORT(WINDOW *) menu_sub (const MENU *);
+extern NCURSES_EXPORT(WINDOW *) menu_win (const MENU *);
+
+extern NCURSES_EXPORT(const char *) item_description (const ITEM *);
+extern NCURSES_EXPORT(const char *) item_name (const ITEM *);
+extern NCURSES_EXPORT(const char *) menu_mark (const MENU *);
+extern NCURSES_EXPORT(const char *) menu_request_name (int);
+
+extern NCURSES_EXPORT(char *) menu_pattern (const MENU *);
+
+extern NCURSES_EXPORT(void *) menu_userptr (const MENU *);
+extern NCURSES_EXPORT(void *) item_userptr (const ITEM *);
+
+extern NCURSES_EXPORT(chtype) menu_back (const MENU *);
+extern NCURSES_EXPORT(chtype) menu_fore (const MENU *);
+extern NCURSES_EXPORT(chtype) menu_grey (const MENU *);
+
+extern NCURSES_EXPORT(int) free_item (ITEM *);
+extern NCURSES_EXPORT(int) free_menu (MENU *);
+extern NCURSES_EXPORT(int) item_count (const MENU *);
+extern NCURSES_EXPORT(int) item_index (const ITEM *);
+extern NCURSES_EXPORT(int) item_opts_off (ITEM *,Item_Options);
+extern NCURSES_EXPORT(int) item_opts_on (ITEM *,Item_Options);
+extern NCURSES_EXPORT(int) menu_driver (MENU *,int);
+extern NCURSES_EXPORT(int) menu_opts_off (MENU *,Menu_Options);
+extern NCURSES_EXPORT(int) menu_opts_on (MENU *,Menu_Options);
+extern NCURSES_EXPORT(int) menu_pad (const MENU *);
+extern NCURSES_EXPORT(int) pos_menu_cursor (const MENU *);
+extern NCURSES_EXPORT(int) post_menu (MENU *);
+extern NCURSES_EXPORT(int) scale_menu (const MENU *,int *,int *);
+extern NCURSES_EXPORT(int) set_current_item (MENU *menu,ITEM *item);
+extern NCURSES_EXPORT(int) set_item_init (MENU *, Menu_Hook);
+extern NCURSES_EXPORT(int) set_item_opts (ITEM *,Item_Options);
+extern NCURSES_EXPORT(int) set_item_term (MENU *, Menu_Hook);
+extern NCURSES_EXPORT(int) set_item_userptr (ITEM *, void *);
+extern NCURSES_EXPORT(int) set_item_value (ITEM *,bool);
+extern NCURSES_EXPORT(int) set_menu_back (MENU *,chtype);
+extern NCURSES_EXPORT(int) set_menu_fore (MENU *,chtype);
+extern NCURSES_EXPORT(int) set_menu_format (MENU *,int,int);
+extern NCURSES_EXPORT(int) set_menu_grey (MENU *,chtype);
+extern NCURSES_EXPORT(int) set_menu_init (MENU *, Menu_Hook);
+extern NCURSES_EXPORT(int) set_menu_items (MENU *,ITEM **);
+extern NCURSES_EXPORT(int) set_menu_mark (MENU *, const char *);
+extern NCURSES_EXPORT(int) set_menu_opts (MENU *,Menu_Options);
+extern NCURSES_EXPORT(int) set_menu_pad (MENU *,int);
+extern NCURSES_EXPORT(int) set_menu_pattern (MENU *,const char *);
+extern NCURSES_EXPORT(int) set_menu_sub (MENU *,WINDOW *);
+extern NCURSES_EXPORT(int) set_menu_term (MENU *, Menu_Hook);
+extern NCURSES_EXPORT(int) set_menu_userptr (MENU *,void *);
+extern NCURSES_EXPORT(int) set_menu_win (MENU *,WINDOW *);
+extern NCURSES_EXPORT(int) set_top_row (MENU *,int);
+extern NCURSES_EXPORT(int) top_row (const MENU *);
+extern NCURSES_EXPORT(int) unpost_menu (MENU *);
+extern NCURSES_EXPORT(int) menu_request_by_name (const char *);
+extern NCURSES_EXPORT(int) set_menu_spacing (MENU *,int,int,int);
+extern NCURSES_EXPORT(int) menu_spacing (const MENU *,int *,int *,int *);
+
+
+extern NCURSES_EXPORT(bool) item_value (const ITEM *);
+extern NCURSES_EXPORT(bool) item_visible (const ITEM *);
+
+extern NCURSES_EXPORT(void) menu_format (const MENU *,int *,int *);
+
+#if NCURSES_SP_FUNCS
+extern NCURSES_EXPORT(MENU *) NCURSES_SP_NAME(new_menu) (SCREEN*, ITEM **);
+#endif
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* ETI_MENU */
diff --git a/payloads/libpayload/curses/menu/menu.priv.h b/payloads/libpayload/curses/menu/menu.priv.h
new file mode 100644
index 0000000000..4cfcd8d7a5
--- /dev/null
+++ b/payloads/libpayload/curses/menu/menu.priv.h
@@ -0,0 +1,156 @@
+/****************************************************************************
+ * Copyright (c) 1998-2005,2009 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/* $Id: menu.priv.h,v 1.23 2009/02/28 21:02:57 juergen Exp $ */
+
+/***************************************************************************
+* Module menu.priv.h *
+* Top level private header file for all libnmenu modules *
+***************************************************************************/
+
+#ifndef MENU_PRIV_H_incl
+#define MENU_PRIV_H_incl 1
+
+#include "curspriv.h"
+#include "mf_common.h"
+#include "menu.h"
+
+/* Backspace code */
+#define BS (8)
+
+extern NCURSES_EXPORT_VAR(ITEM) _nc_Default_Item;
+extern NCURSES_EXPORT_VAR(MENU) _nc_Default_Menu;
+
+/* Normalize item to default if none was given */
+#define Normalize_Item( item ) ((item)=(item)?(item):&_nc_Default_Item)
+
+/* Normalize menu to default if none was given */
+#define Normalize_Menu( menu ) ((menu)=(menu)?(menu):&_nc_Default_Menu)
+
+#define Get_Menu_Screen( menu ) (menu->userwin ? \
+ _nc_screen_of(menu->userwin) : CURRENT_SCREEN)
+
+/* Get the user defined (framing) window of the menu */
+#define Get_Menu_UserWin(menu) ((menu)->userwin ? \
+ (menu)->userwin : stdscr)
+
+/* Normalize menu window */
+#define Get_Menu_Window( menu ) \
+ ((menu)->usersub ? (menu)->usersub : Get_Menu_UserWin(menu))
+
+/* menu specific status flags */
+#define _LINK_NEEDED (0x04)
+#define _MARK_ALLOCATED (0x08)
+
+#define ALL_MENU_OPTS ( \
+ O_ONEVALUE | \
+ O_SHOWDESC | \
+ O_ROWMAJOR | \
+ O_IGNORECASE | \
+ O_SHOWMATCH | \
+ O_NONCYCLIC )
+
+#define ALL_ITEM_OPTS (O_SELECTABLE)
+
+/* Move to the window position of an item and draw it */
+#define Move_And_Post_Item(menu,item) \
+ {wmove((menu)->win,(menu)->spc_rows*(item)->y,((menu)->itemlen+(menu)->spc_cols)*(item)->x);\
+ _nc_Post_Item((menu),(item));}
+
+#define Move_To_Current_Item(menu,item) \
+ if ( (item) != (menu)->curitem)\
+ {\
+ Move_And_Post_Item(menu,item);\
+ Move_And_Post_Item(menu,(menu)->curitem);\
+ }
+
+/* This macro ensures, that the item becomes visible, if possible with the
+ specified row as the top row of the window. If this is not possible,
+ the top row will be adjusted and the value is stored in the row argument.
+*/
+#define Adjust_Current_Item(menu,row,item) \
+ { if ((item)->y < row) \
+ row = (item)->y;\
+ if ( (item)->y >= (row + (menu)->arows) )\
+ row = ( (item)->y < ((menu)->rows - row) ) ? \
+ (item)->y : (menu)->rows - (menu)->arows;\
+ _nc_New_TopRow_and_CurrentItem(menu,row,item); }
+
+/* Reset the match pattern buffer */
+#define Reset_Pattern(menu) \
+ { (menu)->pindex = 0; \
+ (menu)->pattern[0] = '\0'; }
+
+#define UChar(c) ((unsigned char)(c))
+
+/* Internal functions. */
+extern NCURSES_EXPORT(void) _nc_Draw_Menu (const MENU *);
+extern NCURSES_EXPORT(void) _nc_Show_Menu (const MENU *);
+extern NCURSES_EXPORT(void) _nc_Calculate_Item_Length_and_Width (MENU *);
+extern NCURSES_EXPORT(int) _nc_Calculate_Text_Width(const TEXT *);
+extern NCURSES_EXPORT(void) _nc_Post_Item (const MENU *, const ITEM *);
+extern NCURSES_EXPORT(bool) _nc_Connect_Items (MENU *, ITEM **);
+extern NCURSES_EXPORT(void) _nc_Disconnect_Items (MENU *);
+extern NCURSES_EXPORT(void) _nc_New_TopRow_and_CurrentItem (MENU *,int, ITEM *);
+extern NCURSES_EXPORT(void) _nc_Link_Items (MENU *);
+extern NCURSES_EXPORT(int) _nc_Match_Next_Character_In_Item_Name (MENU*,int,ITEM**);
+extern NCURSES_EXPORT(int) _nc_menu_cursor_pos (const MENU* menu, const ITEM* item,
+ int* pY, int* pX);
+
+#ifdef TRACE
+
+#define returnItem(code) TRACE_RETURN(code,item)
+#define returnItemPtr(code) TRACE_RETURN(code,item_ptr)
+#define returnItemOpts(code) TRACE_RETURN(code,item_opts)
+#define returnMenu(code) TRACE_RETURN(code,menu)
+#define returnMenuHook(code) TRACE_RETURN(code,menu_hook)
+#define returnMenuOpts(code) TRACE_RETURN(code,menu_opts)
+
+extern NCURSES_EXPORT(ITEM *) _nc_retrace_item (ITEM *);
+extern NCURSES_EXPORT(ITEM **) _nc_retrace_item_ptr (ITEM **);
+extern NCURSES_EXPORT(Item_Options) _nc_retrace_item_opts (Item_Options);
+extern NCURSES_EXPORT(MENU *) _nc_retrace_menu (MENU *);
+extern NCURSES_EXPORT(Menu_Hook) _nc_retrace_menu_hook (Menu_Hook);
+extern NCURSES_EXPORT(Menu_Options) _nc_retrace_menu_opts (Menu_Options);
+
+#else /* !TRACE */
+
+#define returnItem(code) return code
+#define returnItemPtr(code) return code
+#define returnItemOpts(code) return code
+#define returnMenu(code) return code
+#define returnMenuHook(code) return code
+#define returnMenuOpts(code) return code
+
+#endif /* TRACE/!TRACE */
+
+#endif /* MENU_PRIV_H_incl */
diff --git a/payloads/libpayload/curses/menu/mf_common.h b/payloads/libpayload/curses/menu/mf_common.h
new file mode 100644
index 0000000000..681672dc34
--- /dev/null
+++ b/payloads/libpayload/curses/menu/mf_common.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer, 1995,1997 *
+ ****************************************************************************/
+
+/* $Id: mf_common.h,v 0.22 2005/11/26 15:26:52 tom Exp $ */
+
+/* Common internal header for menu and form library */
+
+#ifndef MF_COMMON_H_incl
+#define MF_COMMON_H_incl 1
+
+#include <ncurses_cfg.h>
+#include <curses.h>
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+
+#if DECL_ERRNO
+extern int errno;
+#endif
+
+/* in case of debug version we ignore the suppression of assertions */
+#ifdef TRACE
+# ifdef NDEBUG
+# undef NDEBUG
+# endif
+#endif
+
+#include <nc_alloc.h>
+
+#if USE_RCS_IDS
+#define MODULE_ID(id) static const char Ident[] = id;
+#else
+#define MODULE_ID(id) /*nothing*/
+#endif
+
+
+/* Maximum regular 8-bit character code */
+#define MAX_REGULAR_CHARACTER (0xff)
+
+#define SET_ERROR(code) (errno=(code))
+#define GET_ERROR() (errno)
+
+#ifdef TRACE
+#define RETURN(code) returnCode( SET_ERROR(code) )
+#else
+#define RETURN(code) return( SET_ERROR(code) )
+#endif
+
+/* The few common values in the status fields for menus and forms */
+#define _POSTED (0x01U) /* menu or form is posted */
+#define _IN_DRIVER (0x02U) /* menu or form is processing hook routine */
+
+/* Call object hook */
+#define Call_Hook( object, handler ) \
+ if ( (object) != 0 && ((object)->handler) != (void *) 0 )\
+ {\
+ (object)->status |= _IN_DRIVER;\
+ (object)->handler(object);\
+ (object)->status &= ~_IN_DRIVER;\
+ }
+
+#endif /* MF_COMMON_H_incl */
diff --git a/payloads/libpayload/curses/menu/modules b/payloads/libpayload/curses/menu/modules
new file mode 100644
index 0000000000..fac8fceba1
--- /dev/null
+++ b/payloads/libpayload/curses/menu/modules
@@ -0,0 +1,63 @@
+# $Id: modules,v 1.18 2010/01/23 16:36:23 tom Exp $
+##############################################################################
+# Copyright (c) 1998-2006,2010 Free Software Foundation, Inc. #
+# #
+# Permission is hereby granted, free of charge, to any person obtaining a #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation #
+# the rights to use, copy, modify, merge, publish, distribute, distribute #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the #
+# following conditions: #
+# #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software. #
+# #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
+# DEALINGS IN THE SOFTWARE. #
+# #
+# Except as contained in this notice, the name(s) of the above copyright #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written #
+# authorization. #
+##############################################################################
+#
+# Author: Thomas E. Dickey 1996-on
+#
+
+@ base
+# Library objects
+m_attribs lib $(srcdir) $(HEADER_DEPS)
+m_cursor lib $(srcdir) $(HEADER_DEPS)
+m_driver lib $(srcdir) $(HEADER_DEPS)
+m_format lib $(srcdir) $(HEADER_DEPS)
+m_global lib $(srcdir) $(HEADER_DEPS)
+m_hook lib $(srcdir) $(HEADER_DEPS)
+m_item_cur lib $(srcdir) $(HEADER_DEPS)
+m_item_nam lib $(srcdir) $(HEADER_DEPS)
+m_item_new lib $(srcdir) $(HEADER_DEPS)
+m_item_opt lib $(srcdir) $(HEADER_DEPS)
+m_item_top lib $(srcdir) $(HEADER_DEPS)
+m_item_use lib $(srcdir) $(HEADER_DEPS)
+m_item_val lib $(srcdir) $(HEADER_DEPS)
+m_item_vis lib $(srcdir) $(HEADER_DEPS)
+m_items lib $(srcdir) $(HEADER_DEPS)
+m_new lib $(srcdir) $(HEADER_DEPS)
+m_opts lib $(srcdir) $(HEADER_DEPS)
+m_pad lib $(srcdir) $(HEADER_DEPS)
+m_pattern lib $(srcdir) $(HEADER_DEPS)
+m_post lib $(srcdir) $(HEADER_DEPS)
+m_req_name lib $(srcdir) $(HEADER_DEPS)
+m_scale lib $(srcdir) $(HEADER_DEPS)
+m_spacing lib $(srcdir) $(HEADER_DEPS)
+m_sub lib $(srcdir) $(HEADER_DEPS)
+m_trace lib $(srcdir) $(HEADER_DEPS)
+m_userptr lib $(srcdir) $(HEADER_DEPS)
+m_win lib $(srcdir) $(HEADER_DEPS)
+
+# vile:makemode
diff --git a/payloads/libpayload/curses/pdcurses-backend/config.h b/payloads/libpayload/curses/pdcurses-backend/config.h
new file mode 100644
index 0000000000..a338593473
--- /dev/null
+++ b/payloads/libpayload/curses/pdcurses-backend/config.h
@@ -0,0 +1,134 @@
+/* config.h. Generated from config.h.in by configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define if you have the <DECkeySym.h> header file */
+/* #undef HAVE_DECKEYSYM_H */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+/* #undef HAVE_DLFCN_H */
+
+/* Define to 1 if you have the <dl.h> header file. */
+/* #undef HAVE_DL_H */
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+/* #undef HAVE_FCNTL_H */
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `poll' function. */
+/* #undef HAVE_POLL */
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define if you have the <Sunkeysym.h> header file */
+/* #undef HAVE_SUNKEYSYM_H */
+
+/* Define to 1 if you have the <sys/select.h> header file. */
+/* #undef HAVE_SYS_SELECT_H */
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+/* #undef HAVE_SYS_STAT_H */
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+/* #undef HAVE_SYS_TIME_H */
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the `usleep' function. */
+#define HAVE_USLEEP 1
+
+/* Define to 1 if you have the `vsnprintf' function. */
+#define HAVE_VSNPRINTF 1
+
+/* Define to 1 if you have the `vsscanf' function. */
+#define HAVE_VSSCANF 1
+
+/* Define if you have this defined in <keysym.h> */
+/* #undef HAVE_XK_KP_BEGIN */
+
+/* Define if you have this defined in <keysym.h> */
+/* #undef HAVE_XK_KP_DELETE */
+
+/* Define if you have this defined in <keysym.h> */
+/* #undef HAVE_XK_KP_DOWN */
+
+/* Define if you have this defined in <keysym.h> */
+/* #undef HAVE_XK_KP_END */
+
+/* Define if you have this defined in <keysym.h> */
+/* #undef HAVE_XK_KP_HOME */
+
+/* Define if you have this defined in <keysym.h> */
+/* #undef HAVE_XK_KP_INSERT */
+
+/* Define if you have this defined in <keysym.h> */
+/* #undef HAVE_XK_KP_LEFT */
+
+/* Define if you have this defined in <keysym.h> */
+/* #undef HAVE_XK_KP_NEXT */
+
+/* Define if you have this defined in <keysym.h> */
+/* #undef HAVE_XK_KP_PRIOR */
+
+/* Define if you have this defined in <keysym.h> */
+/* #undef HAVE_XK_KP_RIGHT */
+
+/* Define if you have this defined in <keysym.h> */
+/* #undef HAVE_XK_KP_UP */
+
+/* Define if you have the <xpm.h> header file */
+/* #undef HAVE_XPM_H */
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "coreboot@coreboot.org"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "PDCurses"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "PDCurses 3.4+libpayload"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "PDCurses"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "3.4+libpayload"
+
+/* Define as the system defined limit for number of signals */
+#define PDC_MAX_SIGNALS NSIG
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#define RETSIGTYPE void
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#define TIME_WITH_SYS_TIME 1
+
+/* Define if you want to use neXtaw library */
+/* #undef USE_NEXTAW */
+
+/* Define if you want to use Xaw3d library */
+/* #undef USE_XAW3D */
+
+/* Define XPointer is typedefed in X11/Xlib.h */
+/* #undef XPOINTER_TYPEDEFED */
diff --git a/payloads/libpayload/curses/pdcurses-backend/lppdc.h b/payloads/libpayload/curses/pdcurses-backend/lppdc.h
new file mode 100644
index 0000000000..56330a9336
--- /dev/null
+++ b/payloads/libpayload/curses/pdcurses-backend/lppdc.h
@@ -0,0 +1,10 @@
+#include <libpayload-config.h>
+#include <curses.h>
+#include <curspriv.h>
+
+extern int curses_flags;
+extern unsigned char *pdc_atrtab;
+extern short curstoreal[16], realtocurs[16];
+
+#define F_ENABLE_CONSOLE 1
+#define F_ENABLE_SERIAL 2
diff --git a/payloads/libpayload/curses/pdcurses-backend/nc_alloc.h b/payloads/libpayload/curses/pdcurses-backend/nc_alloc.h
new file mode 100644
index 0000000000..95d41f9aa9
--- /dev/null
+++ b/payloads/libpayload/curses/pdcurses-backend/nc_alloc.h
@@ -0,0 +1,4 @@
+#define typeMalloc(type,elts) (type *)malloc((elts)*sizeof(type))
+#define typeCalloc(type,elts) (type *)calloc((elts),sizeof(type))
+#define typeRealloc(type,elts,ptr) (type *)_nc_doalloc(ptr, (elts)*sizeof(type))
+
diff --git a/payloads/libpayload/curses/pdcurses-backend/ncurses_cfg.h b/payloads/libpayload/curses/pdcurses-backend/ncurses_cfg.h
new file mode 100644
index 0000000000..c6184bebc5
--- /dev/null
+++ b/payloads/libpayload/curses/pdcurses-backend/ncurses_cfg.h
@@ -0,0 +1,40 @@
+#define USE_RCS_IDS 0
+#define USE_WIDEC_SUPPORT 0
+#define NCURSES_SP_FUNCS 0
+#define DECL_ERRNO 0
+#define NCURSES_INTEROP_FUNCS 0
+
+#define NCURSES_API
+#define NCURSES_IMPEXP
+#define NCURSES_INLINE
+#define NCURSES_SP_DCLx
+#define NCURSES_SP_NAME(x) x
+#define NCURSES_EXPORT_VAR(x) x
+#define NCURSES_EXPORT(x) x
+
+#define SP_PARM SP
+#define CURRENT_SCREEN SP
+#define StdScreen(x) stdscr
+
+#define T(x)
+#define T_CALLED(x...)
+
+#define GCC_UNUSED __attribute__((unused))
+
+#define BLANK (' '|A_NORMAL)
+#define ZEROS ('\0'|A_NORMAL)
+#define ISBLANK isblank
+
+#define ChCharOf(c) ((c) & (chtype)A_CHARTEXT)
+#define CharOf(c) ChCharOf(c)
+
+#define WINDOW_ATTRS(x) ((x)->_attrs)
+#define IsValidScreen(x) 1
+
+#define returnCode return
+#define returnWin return
+#define returnCPtr return
+#define returnVoidPtr return
+#define returnPtr return
+#define returnAttr return
+#define returnBool return
diff --git a/payloads/libpayload/curses/pdcurses-backend/pdcdisp.c b/payloads/libpayload/curses/pdcurses-backend/pdcdisp.c
new file mode 100644
index 0000000000..80073ac73a
--- /dev/null
+++ b/payloads/libpayload/curses/pdcurses-backend/pdcdisp.c
@@ -0,0 +1,247 @@
+/* Public Domain Curses */
+/* This file is BSD licensed, Copyright 2011 secunet AG */
+
+#include "lppdc.h"
+#include <libpayload.h>
+
+/* ACS definitions originally by jshumate@wrdis01.robins.af.mil -- these
+ match code page 437 and compatible pages (CP850, CP852, etc.) */
+
+#ifdef CHTYPE_LONG
+
+# define A(x) ((chtype)x | A_ALTCHARSET)
+
+chtype acs_map[128] =
+{
+ A(0), A(1), A(2), A(3), A(4), A(5), A(6), A(7), A(8), A(9), A(10),
+ A(11), A(12), A(13), A(14), A(15), A(16), A(17), A(18), A(19),
+ A(20), A(21), A(22), A(23), A(24), A(25), A(26), A(27), A(28),
+ A(29), A(30), A(31), ' ', '!', '"', '#', '$', '%', '&', '\'', '(',
+ ')', '*',
+
+ A(0x1a), A(0x1b), A(0x18), A(0x19),
+
+ '/',
+
+ 0xdb,
+
+ '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=',
+ '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
+ 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+ 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
+
+ A(0x04), 0xb1,
+
+ 'b', 'c', 'd', 'e',
+
+ 0xf8, 0xf1, 0xb0, A(0x0f), 0xd9, 0xbf, 0xda, 0xc0, 0xc5, 0x2d, 0x2d,
+ 0xc4, 0x2d, 0x5f, 0xc3, 0xb4, 0xc1, 0xc2, 0xb3, 0xf3, 0xf2, 0xe3,
+ 0xd8, 0x9c, 0xf9,
+
+ A(127)
+};
+
+# undef A
+
+#endif
+
+/* See terminfo(5). */
+chtype fallback_acs_map[128] =
+ {
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', ' ', ' ', '>', '<', '^', 'v', ' ',
+ '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
+ '+', ':', ' ', ' ', ' ', ' ', '\\', '#',
+ '#', '#', '+', '+', '+', '+', '+', '~',
+ '-', '-', '-', '_', '+', '+', '+', '+',
+ '|', '<', '>', '*', '!', 'f', 'o', ' ',
+ };
+
+#ifdef CONFIG_SERIAL_CONSOLE
+#ifdef CONFIG_SERIAL_ACS_FALLBACK
+chtype serial_acs_map[128];
+#else
+/* See acsc of vt100. */
+chtype serial_acs_map[128] =
+ {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ '`', 'a', 0, 0, 0, 0, 'f', 'g',
+ 0, 0, 'j', 'k', 'l', 'm', 'n', 'o',
+ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
+ 'x', 'y', 'z', '{', '|', '}', '~', 0,
+ };
+#endif
+#endif
+
+#ifdef CONFIG_VIDEO_CONSOLE
+/* See acsc of linux. */
+chtype console_acs_map[128] =
+ {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, '\020', '\021', '\030', '\031', 0,
+ '\333', 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ '\004', '\261', 0, 0, 0, 0, '\370', '\361',
+ '\260', '\316', '\331', '\277', '\332', '\300', '\305', '~',
+ '\304', '\304', '\304', '_', '\303', '\264', '\301', '\302',
+ '\263', '\363', '\362', '\343', '\330', '\234', '\376', 0,
+ };
+#endif
+
+/* position hardware cursor at (y, x) */
+
+void PDC_gotoyx(int row, int col)
+{
+ PDC_LOG(("PDC_gotoyx() - called: row %d col %d\n", row, col));
+
+#ifdef CONFIG_SERIAL_CONSOLE
+ serial_set_cursor(col, row);
+#endif
+#ifdef CONFIG_VIDEO_CONSOLE
+ video_console_set_cursor(col, row);
+#endif
+}
+
+/* update the given physical line to look like the corresponding line in
+ curscr */
+
+void PDC_transform_line(int lineno, int x, int len, const chtype *srcp)
+{
+ int j, ch, attr;
+
+ PDC_LOG(("PDC_transform_line() - called: line %d, len %d, curses_flags %d\n", lineno, len, curses_flags));
+
+#ifdef CONFIG_SERIAL_CONSOLE
+ int serial_is_bold = 0;
+ int serial_is_reverse = 0;
+ int serial_is_altcharset = 0;
+ int serial_cur_pair = 0;
+ int need_altcharset;
+
+ if (curses_flags & F_ENABLE_SERIAL) {
+ serial_end_bold();
+ serial_end_altcharset();
+ serial_set_cursor(lineno, x);
+ }
+#endif
+
+ for (j = 0; j < len; j++)
+ {
+ ch = srcp[j];
+ attr = ch;
+#ifdef CONFIG_SERIAL_CONSOLE
+ if (curses_flags & F_ENABLE_SERIAL) {
+ if (attr & A_BOLD) {
+ if (!serial_is_bold) {
+ serial_start_bold();
+ serial_is_bold = 1;
+ }
+ } else {
+ if (serial_is_bold) {
+ serial_end_bold();
+ serial_is_bold = 0;
+ /* work around serial.c
+ * shortcoming:
+ */
+ serial_is_reverse = 0;
+ serial_cur_pair = 0;
+ }
+ }
+
+ if (attr & A_REVERSE) {
+ if (!serial_is_reverse) {
+ serial_start_reverse();
+ serial_is_reverse = 1;
+ }
+ } else {
+ if (serial_is_reverse) {
+ serial_end_reverse();
+ serial_is_reverse = 0;
+ /* work around serial.c
+ * shortcoming:
+ */
+ serial_is_bold = 0;
+ serial_cur_pair = 0;
+ }
+ }
+
+ need_altcharset = 0;
+ if (attr & A_ALTCHARSET) {
+ if (serial_acs_map[ch & 0x7f]) {
+ ch = serial_acs_map[ch & 0x7f];
+ need_altcharset = 1;
+ } else
+ ch = fallback_acs_map[ch & 0x7f];
+ }
+ if (need_altcharset && !serial_is_altcharset) {
+ serial_start_altcharset();
+ serial_is_altcharset = 1;
+ }
+ if (!need_altcharset && serial_is_altcharset) {
+ serial_end_altcharset();
+ serial_is_altcharset = 0;
+ }
+
+ if (serial_cur_pair != PAIR_NUMBER(attr)) {
+ short int fg, bg;
+ pair_content(PAIR_NUMBER(attr),
+ &fg, &bg);
+ serial_set_color(fg, bg);
+ serial_cur_pair = PAIR_NUMBER(attr);
+ }
+
+ serial_putchar(ch & 0xff);
+
+ }
+#endif
+#ifdef CONFIG_VIDEO_CONSOLE
+ unsigned char c = pdc_atrtab[srcp[j] >> PDC_ATTR_SHIFT];
+
+ if (curses_flags & F_ENABLE_CONSOLE) {
+ if (attr & A_ALTCHARSET) {
+ if (console_acs_map[ch & 0x7f])
+ ch = console_acs_map[ch & 0x7f];
+ else
+ ch = fallback_acs_map[ch & 0x7f];
+ }
+
+ /*
+ * FIXME: Somewhere along the line, the
+ * character value is getting sign-extented.
+ * For now grab just the 8 bit character,
+ * but this will break wide characters!
+ */
+ video_console_putc(lineno, x + j, (c << 8) | ( ch & 0xff));
+ }
+#endif
+ }
+}
+
diff --git a/payloads/libpayload/curses/pdcurses-backend/pdcgetsc.c b/payloads/libpayload/curses/pdcurses-backend/pdcgetsc.c
new file mode 100644
index 0000000000..835b840fba
--- /dev/null
+++ b/payloads/libpayload/curses/pdcurses-backend/pdcgetsc.c
@@ -0,0 +1,48 @@
+/* Public Domain Curses */
+/* This file is BSD licensed, Copyright 2011 secunet AG */
+
+#include "lppdc.h"
+
+#include <stdlib.h>
+
+/* return width of screen/viewport */
+
+int PDC_get_columns(void)
+{
+ int cols;
+
+ PDC_LOG(("PDC_get_columns() - called\n"));
+
+ /* hardcode to 80 */
+ cols = 80;
+
+ PDC_LOG(("PDC_get_columns() - returned: cols %d\n", cols));
+
+ return cols;
+}
+
+/* get the cursor size/shape */
+
+int PDC_get_cursor_mode(void)
+{
+ PDC_LOG(("PDC_get_cursor_mode() - called\n"));
+
+ /* only have one cursor type */
+ return SP->visibility;
+}
+
+/* return number of screen rows */
+
+int PDC_get_rows(void)
+{
+ int rows;
+
+ PDC_LOG(("PDC_get_rows() - called\n"));
+
+ /* hardcode to 25 */
+ rows = 25;
+
+ PDC_LOG(("PDC_get_rows() - returned: rows %d\n", rows));
+
+ return rows;
+}
diff --git a/payloads/libpayload/curses/pdcurses-backend/pdckbd.c b/payloads/libpayload/curses/pdcurses-backend/pdckbd.c
new file mode 100644
index 0000000000..4a039ffbc4
--- /dev/null
+++ b/payloads/libpayload/curses/pdcurses-backend/pdckbd.c
@@ -0,0 +1,194 @@
+/* Public Domain Curses */
+
+#include "lppdc.h"
+#include <usb/usb.h>
+
+unsigned long pdc_key_modifiers = 0L;
+
+#ifdef CONFIG_SERIAL_CONSOLE
+/* We treat serial like a vt100 terminal. For now we
+ do the cooking in here, but we should probably eventually
+ pass it to dedicated vt100 code */
+
+static int getkeyseq(char *buffer, int len, int max)
+{
+ int i;
+
+ while (1) {
+ for(i = 0; i < 75; i++) {
+ if (serial_havechar())
+ break;
+ mdelay(1);
+ }
+
+ if (i == 75)
+ return len;
+
+ buffer[len++] = serial_getchar();
+ if (len == max)
+ return len;
+ }
+}
+
+static struct {
+ const char *seq;
+ int key;
+} escape_codes[] = {
+ { "[A", KEY_UP },
+ { "[B", KEY_DOWN },
+ { "[C", KEY_RIGHT },
+ { "[D", KEY_LEFT },
+ { "[F", KEY_END },
+ { "[H", KEY_HOME },
+ { "[2~", KEY_IC },
+ { "[3~", KEY_DC },
+ { "[5~", KEY_PPAGE },
+ { "[6~", KEY_NPAGE },
+ { "OP", KEY_F(1) },
+ { "OQ", KEY_F(2) },
+ { "OR", KEY_F(3) },
+ { "OS", KEY_F(4) },
+ { "[15~", KEY_F(5) },
+ { "[17~", KEY_F(6) },
+ { "[18~", KEY_F(7) },
+ { "[19~", KEY_F(8) },
+ { "[20~", KEY_F(9) },
+ { "[21~", KEY_F(10) },
+ { "[23~", KEY_F(11) },
+ { "[24~", KEY_F(12) },
+ { NULL },
+};
+
+static int handle_escape(void)
+{
+ char buffer[5];
+ int len = getkeyseq(buffer, 0, sizeof(buffer));
+ int i, t;
+
+ if (len == 0)
+ return 27;
+
+ for(i = 0; escape_codes[i].seq != NULL; i++) {
+ const char *p = escape_codes[i].seq;
+
+ for(t = 0; t < len; t++) {
+ if (!*p || *p != buffer[t])
+ break;
+ p++;
+ }
+
+ if (t == len)
+ return escape_codes[i].key;
+ }
+
+ return 0;
+}
+
+static int cook_serial(unsigned char ch)
+{
+ switch(ch) {
+ case 8:
+ return KEY_BACKSPACE;
+
+ case 27:
+ return handle_escape();
+
+ default:
+ return ch;
+ }
+}
+#endif
+
+void PDC_set_keyboard_binary(bool on)
+{
+ PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
+}
+
+/* check if a key event is waiting */
+
+bool PDC_check_key(void)
+{
+#ifdef CONFIG_USB_HID
+ usb_poll();
+ if ((curses_flags & F_ENABLE_CONSOLE) &&
+ usbhid_havechar()) {
+ return TRUE;
+ }
+#endif
+
+#ifdef CONFIG_PC_KEYBOARD
+ if ((curses_flags & F_ENABLE_CONSOLE) &&
+ keyboard_havechar()) {
+ return TRUE;
+ }
+#endif
+
+#ifdef CONFIG_SERIAL_CONSOLE
+ if ((curses_flags & F_ENABLE_SERIAL) &&
+ serial_havechar()) {
+ return TRUE;
+ }
+#endif
+
+ return FALSE;
+}
+
+/* return the next available key event */
+
+int PDC_get_key(void)
+{
+ int c = 0;
+
+#ifdef CONFIG_USB_HID
+ usb_poll();
+ if ((curses_flags & F_ENABLE_CONSOLE) &&
+ usbhid_havechar()) {
+ c = usbhid_getchar();
+ }
+#endif
+
+#ifdef CONFIG_PC_KEYBOARD
+ if ((curses_flags & F_ENABLE_CONSOLE) &&
+ keyboard_havechar()) {
+ c = keyboard_getchar();
+ }
+#endif
+
+#ifdef CONFIG_SERIAL_CONSOLE
+ if ((curses_flags & F_ENABLE_SERIAL) &&
+ serial_havechar()) {
+ c = cook_serial(serial_getchar());
+ }
+#endif
+
+ SP->key_code = FALSE;
+
+ if (c == 0) {
+ c = ERR;
+ }
+ if (c >= KEY_MIN) {
+ SP->key_code = TRUE;
+ }
+
+ return c;
+}
+
+/* discard any pending keyboard input -- this is the core
+ routine for flushinp() */
+
+void PDC_flushinp(void)
+{
+ PDC_LOG(("PDC_flushinp() - called\n"));
+
+ while (PDC_check_key()) PDC_get_key();
+}
+
+int PDC_mouse_set(void)
+{
+ return ERR;
+}
+
+int PDC_modifiers_set(void)
+{
+ return OK;
+}
diff --git a/payloads/libpayload/curses/pdcurses-backend/pdcscrn.c b/payloads/libpayload/curses/pdcurses-backend/pdcscrn.c
new file mode 100644
index 0000000000..b8d9e4e3d6
--- /dev/null
+++ b/payloads/libpayload/curses/pdcurses-backend/pdcscrn.c
@@ -0,0 +1,161 @@
+/* Public Domain Curses */
+
+#include "lppdc.h"
+
+#include <stdlib.h>
+
+#ifdef CHTYPE_LONG
+# define PDC_OFFSET 32
+#else
+# define PDC_OFFSET 8
+#endif
+
+/* COLOR_PAIR to attribute encoding table. */
+
+unsigned char *pdc_atrtab = (unsigned char *)NULL;
+
+short curstoreal[16], realtocurs[16] =
+{
+ COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, COLOR_RED,
+ COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE, COLOR_BLACK + 8,
+ COLOR_BLUE + 8, COLOR_GREEN + 8, COLOR_CYAN + 8, COLOR_RED + 8,
+ COLOR_MAGENTA + 8, COLOR_YELLOW + 8, COLOR_WHITE + 8
+};
+
+/* close the physical screen -- may restore the screen to its state
+ before PDC_scr_open(); miscellaneous cleanup */
+
+void PDC_scr_close(void)
+{
+ PDC_LOG(("PDC_scr_close() - called\n"));
+
+ reset_shell_mode();
+
+ if (SP->visibility != 1)
+ curs_set(1);
+
+ /* Position cursor to the bottom left of the screen. */
+
+ PDC_gotoyx(PDC_get_rows() - 2, 0);
+}
+
+void PDC_scr_free(void)
+{
+ if (SP)
+ free(SP);
+ if (pdc_atrtab)
+ free(pdc_atrtab);
+
+ pdc_atrtab = (unsigned char *)NULL;
+}
+
+/* open the physical screen -- allocate SP, miscellaneous intialization,
+ and may save the existing screen for later restoration */
+
+int PDC_scr_open(int argc, char **argv)
+{
+ int i;
+
+ PDC_LOG(("PDC_scr_open() - called\n"));
+
+ SP = calloc(1, sizeof(SCREEN));
+ pdc_atrtab = calloc(PDC_COLOR_PAIRS * PDC_OFFSET, 1);
+
+ if (!SP || !pdc_atrtab)
+ return ERR;
+
+ for (i = 0; i < 16; i++)
+ curstoreal[realtocurs[i]] = i;
+
+ SP->orig_attr = FALSE;
+
+ SP->lines = PDC_get_rows();
+ SP->cols = PDC_get_columns();
+
+#if CONFIG_SPEAKER
+ SP->audible = TRUE;
+#endif
+
+ return OK;
+}
+
+/* the core of resize_term() */
+
+int PDC_resize_screen(int nlines, int ncols)
+{
+ PDC_LOG(("PDC_resize_screen() - called. Lines: %d Cols: %d\n",
+ nlines, ncols));
+
+ return ERR;
+}
+
+void PDC_reset_prog_mode(void)
+{
+ PDC_LOG(("PDC_reset_prog_mode() - called.\n"));
+}
+
+void PDC_reset_shell_mode(void)
+{
+ PDC_LOG(("PDC_reset_shell_mode() - called.\n"));
+}
+
+void PDC_restore_screen_mode(int i)
+{
+}
+
+void PDC_save_screen_mode(int i)
+{
+}
+
+void PDC_init_pair(short pair, short fg, short bg)
+{
+ unsigned char att, temp_bg;
+ chtype i;
+
+ fg = curstoreal[fg];
+ bg = curstoreal[bg];
+
+ for (i = 0; i < PDC_OFFSET; i++)
+ {
+ att = fg | (bg << 4);
+
+ if (i & (A_REVERSE >> PDC_ATTR_SHIFT))
+ att = bg | (fg << 4);
+ if (i & (A_UNDERLINE >> PDC_ATTR_SHIFT))
+ att = 1;
+ if (i & (A_INVIS >> PDC_ATTR_SHIFT))
+ {
+ temp_bg = att >> 4;
+ att = temp_bg << 4 | temp_bg;
+ }
+ if (i & (A_BOLD >> PDC_ATTR_SHIFT))
+ att |= 8;
+ if (i & (A_BLINK >> PDC_ATTR_SHIFT))
+ att |= 128;
+
+ pdc_atrtab[pair * PDC_OFFSET + i] = att;
+ }
+}
+
+int PDC_pair_content(short pair, short *fg, short *bg)
+{
+ *fg = realtocurs[pdc_atrtab[pair * PDC_OFFSET] & 0x0F];
+ *bg = realtocurs[(pdc_atrtab[pair * PDC_OFFSET] & 0xF0) >> 4];
+
+ return OK;
+}
+
+bool PDC_can_change_color(void)
+{
+ return FALSE;
+}
+
+int PDC_color_content(short color, short *red, short *green, short *blue)
+{
+ return ERR;
+}
+
+int PDC_init_color(short color, short red, short green, short blue)
+{
+ return ERR;
+}
diff --git a/payloads/libpayload/curses/pdcurses-backend/pdcsetsc.c b/payloads/libpayload/curses/pdcurses-backend/pdcsetsc.c
new file mode 100644
index 0000000000..49d66abcb9
--- /dev/null
+++ b/payloads/libpayload/curses/pdcurses-backend/pdcsetsc.c
@@ -0,0 +1,32 @@
+/* Public Domain Curses */
+/* This file is BSD licensed, Copyright 2011 secunet AG */
+
+#include "lppdc.h"
+
+int PDC_curs_set(int visibility)
+{
+ int ret_vis;
+
+ PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
+
+ ret_vis = SP->visibility;
+ SP->visibility = visibility;
+
+#ifdef CONFIG_SERIAL_CONSOLE
+ if (curses_flags & F_ENABLE_SERIAL) {
+ serial_cursor_enable(visibility);
+ }
+#endif
+#ifdef CONFIG_VIDEO_CONSOLE
+ if (curses_flags & F_ENABLE_CONSOLE) {
+ video_console_cursor_enable(visibility);
+ }
+#endif
+
+ return ret_vis;
+}
+
+int PDC_set_blink(bool blinkon)
+{
+ return ERR;
+}
diff --git a/payloads/libpayload/curses/pdcurses-backend/pdcutil.c b/payloads/libpayload/curses/pdcurses-backend/pdcutil.c
new file mode 100644
index 0000000000..8fb3e161d7
--- /dev/null
+++ b/payloads/libpayload/curses/pdcurses-backend/pdcutil.c
@@ -0,0 +1,49 @@
+/* Public Domain Curses */
+/* This file is BSD licensed, Copyright 2011 secunet AG */
+
+#include "lppdc.h"
+#include <libpayload.h>
+
+int curses_flags = F_ENABLE_SERIAL | F_ENABLE_CONSOLE;
+
+void PDC_beep(void)
+{
+ PDC_LOG(("PDC_beep() - called\n"));
+
+#ifdef CONFIG_SPEAKER
+ speaker_tone(1760, 500); /* 1760 == note A6 */
+#endif
+}
+
+void PDC_napms(int ms)
+{
+ PDC_LOG(("PDC_napms() - called: ms=%d\n", ms));
+
+ mdelay(ms);
+}
+
+const char *PDC_sysname(void)
+{
+ return "LIBPAYLOAD";
+}
+
+void curses_enable_serial(int enable)
+{
+ curses_flags = (curses_flags & ~F_ENABLE_SERIAL) | (enable * F_ENABLE_SERIAL);
+}
+
+void curses_enable_vga(int enable)
+{
+ curses_flags = (curses_flags & ~F_ENABLE_CONSOLE) | (enable * F_ENABLE_CONSOLE);
+}
+
+int curses_serial_enabled()
+{
+ return !!(curses_flags & F_ENABLE_SERIAL);
+}
+
+int curses_vga_enabled()
+{
+ return !!(curses_flags & F_ENABLE_CONSOLE);
+}
+
diff --git a/payloads/libpayload/include/panel.h b/payloads/libpayload/include/panel.h
new file mode 100644
index 0000000000..1d7cacef94
--- /dev/null
+++ b/payloads/libpayload/include/panel.h
@@ -0,0 +1,58 @@
+/* Public Domain Curses */
+
+/* $Id: panel.h,v 1.19 2008/07/13 16:08:16 wmcbrine Exp $ */
+
+/*----------------------------------------------------------------------*
+ * Panels for PDCurses *
+ *----------------------------------------------------------------------*/
+
+#ifndef __PDCURSES_PANEL_H__
+#define __PDCURSES_PANEL_H__ 1
+
+#include <curses.h>
+
+#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
+extern "C"
+{
+#endif
+
+typedef struct panelobs
+{
+ struct panelobs *above;
+ struct panel *pan;
+} PANELOBS;
+
+typedef struct panel
+{
+ WINDOW *win;
+ int wstarty;
+ int wendy;
+ int wstartx;
+ int wendx;
+ struct panel *below;
+ struct panel *above;
+ const void *user;
+ struct panelobs *obscure;
+} PANEL;
+
+int bottom_panel(PANEL *pan);
+int del_panel(PANEL *pan);
+int hide_panel(PANEL *pan);
+int move_panel(PANEL *pan, int starty, int startx);
+PANEL *new_panel(WINDOW *win);
+PANEL *panel_above(const PANEL *pan);
+PANEL *panel_below(const PANEL *pan);
+int panel_hidden(const PANEL *pan);
+const void *panel_userptr(const PANEL *pan);
+WINDOW *panel_window(const PANEL *pan);
+int replace_panel(PANEL *pan, WINDOW *win);
+int set_panel_userptr(PANEL *pan, const void *uptr);
+int show_panel(PANEL *pan);
+int top_panel(PANEL *pan);
+void update_panels(void);
+
+#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
+}
+#endif
+
+#endif /* __PDCURSES_PANEL_H__ */
diff --git a/payloads/libpayload/include/term.h b/payloads/libpayload/include/term.h
new file mode 100644
index 0000000000..ce6bc4fae6
--- /dev/null
+++ b/payloads/libpayload/include/term.h
@@ -0,0 +1,57 @@
+/* Public Domain Curses */
+
+/* $Id: term.h,v 1.16 2008/07/13 16:08:16 wmcbrine Exp $ */
+
+/* PDCurses doesn't operate with terminfo, but we need these functions for
+ compatibility, to allow some things (notably, interface libraries for
+ other languages) to be compiled. Anyone who tries to actually _use_
+ them will be disappointed, since they only return ERR. */
+
+#ifndef __PDCURSES_TERM_H__
+#define __PDCURSES_TERM_H__ 1
+
+#include <curses.h>
+
+#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
+extern "C"
+{
+#endif
+
+typedef struct
+{
+ const char *_termname;
+} TERMINAL;
+
+#ifdef PDC_DLL_BUILD
+# ifndef CURSES_LIBRARY
+__declspec(dllimport) TERMINAL *cur_term;
+# else
+__declspec(dllexport) extern TERMINAL *cur_term;
+# endif
+#else
+extern TERMINAL *cur_term;
+#endif
+
+int del_curterm(TERMINAL *);
+int putp(const char *);
+int restartterm(const char *, int, int *);
+TERMINAL *set_curterm(TERMINAL *);
+int setterm(const char *);
+int setupterm(const char *, int, int *);
+int tgetent(char *, const char *);
+int tgetflag(const char *);
+int tgetnum(const char *);
+char *tgetstr(const char *, char **);
+char *tgoto(const char *, int, int);
+int tigetflag(const char *);
+int tigetnum(const char *);
+char *tigetstr(const char *);
+char *tparm(const char *, long, long, long, long, long,
+ long, long, long, long);
+int tputs(const char *, int, int (*)(int));
+
+#if defined(__cplusplus) || defined(__cplusplus__) || defined(__CPLUSPLUS)
+}
+#endif
+
+#endif /* __PDCURSES_TERM_H__ */